Documentation
¶
Overview ¶
Package client provides a GraphQL client for DataHub. It handles authentication, retries, and provides methods for all DataHub operations used by the MCP tools.
Index ¶
- Constants
- Variables
- func BuildChartURN(platform, chartID string) string
- func BuildDashboardURN(platform, dashboardID string) string
- func BuildDataFlowURN(orchestrator, flowID, cluster string) string
- func BuildDataJobURN(dataFlowURN, jobID string) string
- func BuildDatasetURN(platform, qualifiedName, env string) string
- func BuildDocumentURN(documentID string) string
- func BuildDomainURN(domainID string) string
- func BuildGlossaryTermURN(termPath string) string
- func BuildTagURN(tagName string) string
- func ParseURN(urn string) (*types.ParsedURN, error)
- type Client
- func (c *Client) AddGlossaryTerm(ctx context.Context, urn, termURN string) error
- func (c *Client) AddLink(ctx context.Context, urn, linkURL, description string) error
- func (c *Client) AddOwner(ctx context.Context, urn, ownerURN, ownershipType string) error
- func (c *Client) AddTag(ctx context.Context, urn, tagURN string) error
- func (c *Client) Close() error
- func (c *Client) Config() Config
- func (c *Client) CreateApplication(ctx context.Context, name, description string) (string, error)
- func (c *Client) CreateDataProduct(ctx context.Context, name, description, domainURN string) (string, error)
- func (c *Client) CreateDocument(ctx context.Context, input types.CreateDocumentInput) (string, error)
- func (c *Client) CreateDomain(ctx context.Context, name, description string) (string, error)
- func (c *Client) CreateGlossaryTerm(ctx context.Context, name, description, parentNode string) (string, error)
- func (c *Client) CreateQuery(ctx context.Context, input CreateQueryInput) (*types.Query, error)
- func (c *Client) CreateStructuredProperty(ctx context.Context, input types.CreateStructuredPropertyInput) (string, error)
- func (c *Client) CreateTag(ctx context.Context, name, description string) (string, error)
- func (c *Client) DeleteApplication(ctx context.Context, urn string) error
- func (c *Client) DeleteContextDocument(ctx context.Context, documentID string) error
- func (c *Client) DeleteDataProduct(ctx context.Context, urn string) error
- func (c *Client) DeleteDocument(ctx context.Context, urn string) error
- func (c *Client) DeleteDomain(ctx context.Context, urn string) error
- func (c *Client) DeleteGlossaryEntity(ctx context.Context, urn string) error
- func (c *Client) DeleteQuery(ctx context.Context, urn string) error
- func (c *Client) DeleteStructuredProperty(ctx context.Context, urn string) error
- func (c *Client) DeleteTag(ctx context.Context, urn string) error
- func (c *Client) Execute(ctx context.Context, query string, variables map[string]any, result any) error
- func (c *Client) GetColumnLineage(ctx context.Context, urn string) (*types.ColumnLineage, error)
- func (c *Client) GetContextDocuments(ctx context.Context, urn string) ([]types.ContextDocument, error)
- func (c *Client) GetDataContract(ctx context.Context, datasetURN string) (*types.DataContract, error)
- func (c *Client) GetDataProduct(ctx context.Context, urn string) (*types.DataProduct, error)
- func (c *Client) GetDocument(ctx context.Context, urn string) (*types.Document, error)
- func (c *Client) GetEntity(ctx context.Context, urn string) (*types.Entity, error)
- func (c *Client) GetGlossaryTerm(ctx context.Context, urn string) (*types.GlossaryTerm, error)
- func (c *Client) GetIncidents(ctx context.Context, urn string) (*types.IncidentResult, error)
- func (c *Client) GetLineage(ctx context.Context, urn string, opts ...LineageOption) (*types.LineageResult, error)
- func (c *Client) GetQueries(ctx context.Context, urn string) (*types.QueryList, error)
- func (c *Client) GetRelatedDocuments(ctx context.Context, urn string) ([]types.Document, error)
- func (c *Client) GetSchema(ctx context.Context, urn string) (*types.SchemaMetadata, error)
- func (c *Client) GetSchemas(ctx context.Context, urns []string) (map[string]*types.SchemaMetadata, error)
- func (c *Client) GetStructuredProperties(ctx context.Context, urn string) ([]types.StructuredPropertyValue, error)
- func (c *Client) ListDataProducts(ctx context.Context) ([]types.DataProduct, error)
- func (c *Client) ListDomains(ctx context.Context) ([]types.Domain, error)
- func (c *Client) ListStructuredPropertyDefinitions(ctx context.Context) ([]types.StructuredPropertyDefinition, error)
- func (c *Client) ListTags(ctx context.Context, filter string) ([]types.Tag, error)
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) RaiseIncident(ctx context.Context, input types.RaiseIncidentInput) (string, error)
- func (c *Client) RemoveGlossaryTerm(ctx context.Context, urn, termURN string) error
- func (c *Client) RemoveLink(ctx context.Context, urn, linkURL string) error
- func (c *Client) RemoveOwner(ctx context.Context, urn, ownerURN string) error
- func (c *Client) RemoveStructuredProperties(ctx context.Context, urn string, propertyURNs []string) error
- func (c *Client) RemoveTag(ctx context.Context, urn, tagURN string) error
- func (c *Client) ResolveIncident(ctx context.Context, incidentURN, message string) error
- func (c *Client) Search(ctx context.Context, query string, opts ...SearchOption) (*types.SearchResult, error)
- func (c *Client) SearchAcrossEntities(ctx context.Context, query string, opts ...SearchOption) (*types.SearchResult, error)
- func (c *Client) SemanticSearch(ctx context.Context, query string, opts ...SearchOption) (*types.SearchResult, error)
- func (c *Client) SetDomain(ctx context.Context, entityURN, domainURN string) error
- func (c *Client) UnsetDomain(ctx context.Context, entityURN string) error
- func (c *Client) UpdateColumnDescription(ctx context.Context, urn, fieldPath, description string) error
- func (c *Client) UpdateDescription(ctx context.Context, urn, description string) error
- func (c *Client) UpdateDocumentContents(ctx context.Context, urn, title, text string) error
- func (c *Client) UpdateDocumentRelatedEntities(ctx context.Context, urn string, entityURNs []string) error
- func (c *Client) UpdateDocumentStatus(ctx context.Context, urn, status string) error
- func (c *Client) UpdateDocumentSubType(ctx context.Context, urn, subType string) error
- func (c *Client) UpdateIncident(ctx context.Context, urn string, input types.UpdateIncidentInput) error
- func (c *Client) UpdateIncidentStatus(ctx context.Context, incidentURN, state, message string) error
- func (c *Client) UpdateQuery(ctx context.Context, input UpdateQueryInput) (*types.Query, error)
- func (c *Client) UpdateStructuredProperty(ctx context.Context, urn string, input types.UpdateStructuredPropertyInput) error
- func (c *Client) UpsertContextDocument(ctx context.Context, entityURN string, doc types.ContextDocumentInput) (*types.ContextDocument, error)
- func (c *Client) UpsertDataContract(ctx context.Context, input types.UpsertDataContractInput) (string, error)
- func (c *Client) UpsertStructuredProperties(ctx context.Context, urn string, properties []types.StructuredPropertyInput) error
- type Config
- type CreateQueryInput
- type DescriptionAspectInfo
- type LineageOption
- type Logger
- type NopLogger
- type SearchFilter
- type SearchOption
- func WithEntityType(entityType string) SearchOption
- func WithFilters(filters map[string][]string) SearchOptiondeprecated
- func WithLimit(limit int) SearchOption
- func WithOffset(offset int) SearchOption
- func WithSearchFilters(filters []SearchFilter) SearchOption
- func WithTypes(types []string) SearchOption
- type StdLogger
- type UpdateQueryInput
Constants ¶
const ( // GetDocumentQuery retrieves a single document by URN. GetDocumentQuery = `` /* 1319-byte string literal not displayed */ // GetRelatedDocumentsQuery retrieves documents linked to an entity. // The relatedDocuments field is repeated per entity type because GraphQL // inline fragments require each concrete type to declare its own fields — // there is no shared interface to query against. Only entity types that // support relatedDocuments in DataHub are included: Dataset, GlossaryTerm, // GlossaryNode, and Container. GetRelatedDocumentsQuery = `` /* 1352-byte string literal not displayed */ )
GraphQL queries for context documents (DataHub 1.4.x+).
const ( // GetIncidentsQuery retrieves active incidents for an entity. // Uses a named fragment to avoid duplicating the incident field selection // across each entity type inline fragment. GetIncidentsQuery = `` /* 941-byte string literal not displayed */ // RaiseIncidentMutation creates a new incident on entities. RaiseIncidentMutation = ` mutation raiseIncident($input: RaiseIncidentInput!) { raiseIncident(input: $input) } ` // UpdateIncidentStatusMutation resolves or reactivates an incident. UpdateIncidentStatusMutation = `` /* 129-byte string literal not displayed */ )
GraphQL queries and mutations for incidents. All incident queries and mutations (raiseIncident, updateIncidentStatus, updateIncident) require DataHub 1.3.x+.
const ( LineageDirectionUpstream = "UPSTREAM" LineageDirectionDownstream = "DOWNSTREAM" )
Constants for lineage directions.
const ( // SearchQuery searches for entities. SearchQuery = `` /* 1923-byte string literal not displayed */ // GetEntityQuery retrieves a single entity by URN. GetEntityQuery = `` /* 1647-byte string literal not displayed */ // GetSchemaQuery retrieves schema for a dataset. GetSchemaQuery = `` /* 1189-byte string literal not displayed */ // GetLineageQuery retrieves lineage for an entity. // Note: maxHops parameter was removed from DataHub's SearchAcrossLineageInput. // Depth filtering should be done client-side using the returned degree values. GetLineageQuery = `` /* 599-byte string literal not displayed */ // GetQueriesQuery retrieves saved Query entities associated with a dataset. GetQueriesQuery = `` /* 387-byte string literal not displayed */ // GetUsageStatsQueriesQuery retrieves queries from usage stats (fallback for older DataHub). GetUsageStatsQueriesQuery = `` /* 205-byte string literal not displayed */ // GetGlossaryTermQuery retrieves a glossary term. GetGlossaryTermQuery = `` /* 488-byte string literal not displayed */ // ListTagsQuery lists all tags. ListTagsQuery = `` /* 289-byte string literal not displayed */ // ListDomainsQuery lists all domains. ListDomainsQuery = `` /* 425-byte string literal not displayed */ // PingQuery is a simple query to test connectivity. PingQuery = ` query ping { __typename } ` // ListDataProductsQuery lists all data products. ListDataProductsQuery = `` /* 637-byte string literal not displayed */ // GetDataProductQuery retrieves a single data product by URN. GetDataProductQuery = `` /* 627-byte string literal not displayed */ // GetColumnLineageQuery retrieves fine-grained column-level lineage for a dataset. // Uses SchemaFieldRef.urn (available in DataHub v1.3.x+) to get the dataset URN. GetColumnLineageQuery = `` /* 243-byte string literal not displayed */ // CreateQueryMutation creates a new Query entity. CreateQueryMutation = `` /* 326-byte string literal not displayed */ // UpdateQueryMutation updates an existing Query entity. UpdateQueryMutation = `` /* 244-byte string literal not displayed */ // DeleteQueryMutation deletes a Query entity. DeleteQueryMutation = ` mutation deleteQuery($urn: String!) { deleteQuery(urn: $urn) } ` // BatchGetSchemasQuery retrieves schemas for multiple datasets by URN. BatchGetSchemasQuery = `` /* 1377-byte string literal not displayed */ )
GraphQL query templates for DataHub operations.
const ( // GetStructuredPropertiesQuery reads structured property values assigned to an entity. // Uses a named fragment to avoid duplicating the field selection across entity types. GetStructuredPropertiesQuery = `` /* 1360-byte string literal not displayed */ // ListStructuredPropertyDefinitionsQuery searches for all structured property definitions. ListStructuredPropertyDefinitionsQuery = `` /* 825-byte string literal not displayed */ // UpsertStructuredPropertiesMutation sets or updates structured property values on an entity. // The mutation returns StructuredProperties! which requires a selection set. UpsertStructuredPropertiesMutation = `` /* 203-byte string literal not displayed */ // RemoveStructuredPropertiesMutation removes structured property values from an entity. // The mutation returns StructuredProperties! which requires a selection set. RemoveStructuredPropertiesMutation = `` /* 203-byte string literal not displayed */ )
GraphQL queries and mutations for structured properties. All structured property queries and CRUD mutations require DataHub 1.3.x+.
const ( // AddTagMutation adds a tag to any entity via GraphQL. // Signature: addTag(input: TagAssociationInput!): Boolean. AddTagMutation = ` mutation addTag($input: TagAssociationInput!) { addTag(input: $input) } ` // RemoveTagMutation removes a tag from any entity via GraphQL. // Signature: removeTag(input: TagAssociationInput!): Boolean. RemoveTagMutation = ` mutation removeTag($input: TagAssociationInput!) { removeTag(input: $input) } ` // AddTermMutation adds a glossary term to any entity via GraphQL. // Signature: addTerm(input: TermAssociationInput!): Boolean. AddTermMutation = ` mutation addTerm($input: TermAssociationInput!) { addTerm(input: $input) } ` // RemoveTermMutation removes a glossary term from any entity via GraphQL. // Signature: removeTerm(input: TermAssociationInput!): Boolean. RemoveTermMutation = ` mutation removeTerm($input: TermAssociationInput!) { removeTerm(input: $input) } ` // UpdateDescriptionMutation updates the description of any entity via GraphQL. // Signature: updateDescription(input: DescriptionUpdateInput!): Boolean. UpdateDescriptionMutation = ` mutation updateDescription($input: DescriptionUpdateInput!) { updateDescription(input: $input) } ` )
const APIVersionV1 = "v1"
APIVersionV1 selects the legacy Rest.li API endpoints (DataHub <= 1.3.x).
const APIVersionV3 = "v3"
APIVersionV3 selects the OpenAPI v3 endpoints (DataHub >= 1.4.0).
const DefaultEntityType = "DATASET"
DefaultEntityType is the entity type used when none is specified.
const GetContextDocumentsQuery = `
query getContextDocuments($urn: String!, $input: RelatedDocumentsInput!) {
entity(urn: $urn) {
... on Dataset {
relatedDocuments(input: $input) {
documents ` + contextDocFields + `
}
}
... on GlossaryTerm {
relatedDocuments(input: $input) {
documents ` + contextDocFields + `
}
}
... on GlossaryNode {
relatedDocuments(input: $input) {
documents ` + contextDocFields + `
}
}
... on Container {
relatedDocuments(input: $input) {
documents ` + contextDocFields + `
}
}
}
}
`
GetContextDocumentsQuery retrieves context documents linked to an entity. Uses inline fragments because the relatedDocuments field must be declared per concrete type — there is no shared GraphQL interface.
Covers Dataset, GlossaryTerm, GlossaryNode, and Container. Other entity types (Dashboard, Chart, DataFlow, DataJob, DataProduct, etc.) are not included — if they gain relatedDocuments support, add fragments here.
const ( // GetDataContractQuery retrieves the data contract for a dataset. // DataContract has properties (assertion references by category) and // status (overall state). Each category contains assertions with URNs. GetDataContractQuery = `` /* 421-byte string literal not displayed */ )
GraphQL query for data contracts (DataHub 1.3.x+).
const SearchAcrossEntitiesQuery = `` /* 1965-byte string literal not displayed */
SearchAcrossEntitiesQuery searches across multiple entity types with advanced filtering. Uses the searchAcrossEntities GraphQL endpoint which supports orFilters and multi-type search. Shared by both SearchAcrossEntities (keyword) and SemanticSearch (fulltext) methods.
const SemanticSearchQuery = SearchAcrossEntitiesQuery
SemanticSearchQuery is an alias for SearchAcrossEntitiesQuery. SemanticSearch uses the same GraphQL query but adds searchFlags.fulltext=true.
Variables ¶
var ( ErrUnauthorized = errors.New("unauthorized: invalid or missing token") // ErrForbidden indicates insufficient permissions. ErrForbidden = errors.New("forbidden: insufficient permissions") // ErrNotFound indicates the requested entity was not found. ErrNotFound = errors.New("entity not found") // ErrInvalidURN indicates the URN format is invalid. ErrInvalidURN = errors.New("invalid DataHub URN format") // ErrTimeout indicates the request timed out. ErrTimeout = errors.New("request timed out") // ErrRateLimited indicates rate limiting by DataHub. ErrRateLimited = errors.New("rate limited by DataHub") // ErrNotConfigured indicates the client is not properly configured. ErrNotConfigured = errors.New("datahub client not configured") // ErrWriteDisabled indicates write operations are not enabled. ErrWriteDisabled = errors.New("write operations are disabled: set WriteEnabled to true in config") // ErrUnsupportedTagEntity indicates the entity type does not support tag operations. ErrUnsupportedTagEntity = errors.New("entity type does not support tag operations") // ErrUnsupportedGlossaryTermEntity indicates the entity type does not support glossary term associations. ErrUnsupportedGlossaryTermEntity = errors.New("entity type does not support glossary term operations") // ErrUnsupportedLinkEntity indicates the entity type does not support link operations. ErrUnsupportedLinkEntity = errors.New("entity type does not support link operations") )
Sentinel errors for DataHub operations.
var ErrUnsupportedEntityType = errors.New("unsupported entity type for description update")
ErrUnsupportedEntityType is returned when an entity type does not support description updates. Entity types intentionally excluded (no editable description aspect in DataHub): tag, corpuser, corpGroup, mlModel, mlModelGroup, notebook.
Functions ¶
func BuildChartURN ¶
BuildChartURN constructs a chart URN.
func BuildDashboardURN ¶
BuildDashboardURN constructs a dashboard URN.
func BuildDataFlowURN ¶
BuildDataFlowURN constructs a data flow URN.
func BuildDataJobURN ¶
BuildDataJobURN constructs a data job URN.
func BuildDatasetURN ¶
BuildDatasetURN constructs a dataset URN.
func BuildDocumentURN ¶ added in v1.6.0
BuildDocumentURN constructs a document URN.
func BuildDomainURN ¶
BuildDomainURN constructs a domain URN.
func BuildGlossaryTermURN ¶
BuildGlossaryTermURN constructs a glossary term URN.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a GraphQL client for DataHub.
func NewFromEnv ¶
NewFromEnv creates a new DataHub client from environment variables.
func (*Client) AddGlossaryTerm ¶ added in v0.5.0
AddGlossaryTerm adds a glossary term to an entity. Uses GraphQL for domain, glossaryTerm, and glossaryNode entities because the REST API does not register glossaryTerms as an aspect for these types. Uses REST read-modify-write for all other entity types.
func (*Client) AddLink ¶ added in v0.5.0
AddLink adds a link to an entity using read-modify-write on institutionalMemory.
func (*Client) AddTag ¶ added in v0.5.0
AddTag adds a tag to an entity. Uses GraphQL for domain, glossaryTerm, and glossaryNode entities because the REST API does not register globalTags as an aspect for these types. Uses REST read-modify-write for all other entity types.
func (*Client) CreateApplication ¶ added in v1.5.0
CreateApplication creates a new application entity in DataHub.
func (*Client) CreateDataProduct ¶ added in v1.5.0
func (c *Client) CreateDataProduct(ctx context.Context, name, description, domainURN string) (string, error)
CreateDataProduct creates a new data product entity in DataHub.
func (*Client) CreateDocument ¶ added in v1.5.0
func (c *Client) CreateDocument(ctx context.Context, input types.CreateDocumentInput) (string, error)
CreateDocument creates a new context document entity in DataHub.
func (*Client) CreateDomain ¶ added in v1.5.0
CreateDomain creates a new domain entity in DataHub.
func (*Client) CreateGlossaryTerm ¶ added in v1.5.0
func (c *Client) CreateGlossaryTerm(ctx context.Context, name, description, parentNode string) (string, error)
CreateGlossaryTerm creates a new glossary term entity in DataHub.
func (*Client) CreateQuery ¶ added in v0.8.0
CreateQuery creates a new Query entity in DataHub.
func (*Client) CreateStructuredProperty ¶ added in v1.5.0
func (c *Client) CreateStructuredProperty(ctx context.Context, input types.CreateStructuredPropertyInput) (string, error)
CreateStructuredProperty creates a new structured property definition in DataHub.
func (*Client) DeleteApplication ¶ added in v1.5.0
DeleteApplication deletes an application entity.
func (*Client) DeleteContextDocument ¶ added in v1.6.0
DeleteContextDocument removes a context document by its ID.
func (*Client) DeleteDataProduct ¶ added in v1.5.0
DeleteDataProduct deletes a data product entity.
func (*Client) DeleteDocument ¶ added in v1.5.0
DeleteDocument deletes a document entity.
func (*Client) DeleteDomain ¶ added in v1.5.0
DeleteDomain deletes a domain entity.
func (*Client) DeleteGlossaryEntity ¶ added in v1.5.0
DeleteGlossaryEntity deletes a glossary term or node.
func (*Client) DeleteQuery ¶ added in v0.8.0
DeleteQuery deletes a Query entity from DataHub.
func (*Client) DeleteStructuredProperty ¶ added in v1.5.0
DeleteStructuredProperty deletes a structured property definition.
func (*Client) Execute ¶
func (c *Client) Execute(ctx context.Context, query string, variables map[string]any, result any) error
Execute executes a GraphQL query and unmarshals the response into result.
func (*Client) GetColumnLineage ¶ added in v0.4.0
GetColumnLineage retrieves fine-grained column-level lineage for a dataset. Returns empty result if fine-grained lineage is not available for the dataset.
func (*Client) GetContextDocuments ¶ added in v1.6.0
func (c *Client) GetContextDocuments(ctx context.Context, urn string) ([]types.ContextDocument, error)
GetContextDocuments retrieves context documents linked to an entity. Results are capped at MaxLimit; no pagination is performed. If an entity has more context documents than MaxLimit, excess documents are truncated.
Only Dataset, GlossaryTerm, GlossaryNode, and Container entity types are supported. For unsupported entity types the GraphQL query returns an empty entity object and this method returns (nil, nil) — indistinguishable from an entity that simply has no context documents.
func (*Client) GetDataContract ¶ added in v1.4.0
func (c *Client) GetDataContract(ctx context.Context, datasetURN string) (*types.DataContract, error)
GetDataContract retrieves the data contract status for a dataset. Returns nil (not an error) when data contracts are not available.
func (*Client) GetDataProduct ¶
GetDataProduct retrieves a data product by URN.
func (*Client) GetDocument ¶ added in v1.5.0
GetDocument retrieves a document by URN.
func (*Client) GetGlossaryTerm ¶
GetGlossaryTerm retrieves a glossary term by URN.
func (*Client) GetIncidents ¶ added in v1.4.0
GetIncidents retrieves active incidents for an entity. Returns empty results (not an error) when incidents are not available, which is common on DataHub versions before 1.3.x.
func (*Client) GetLineage ¶
func (c *Client) GetLineage(ctx context.Context, urn string, opts ...LineageOption) (*types.LineageResult, error)
GetLineage retrieves lineage for an entity.
func (*Client) GetQueries ¶
GetQueries retrieves saved Query entities associated with a dataset. Falls back to usage stats queries if the listQueries API is not available.
func (*Client) GetRelatedDocuments ¶ added in v1.5.0
GetRelatedDocuments retrieves documents linked to an entity.
func (*Client) GetSchemas ¶ added in v0.4.0
func (c *Client) GetSchemas(ctx context.Context, urns []string) (map[string]*types.SchemaMetadata, error)
GetSchemas retrieves schema metadata for multiple datasets by URN. Returns a map of URN to schema metadata. Datasets without schemas are omitted.
func (*Client) GetStructuredProperties ¶ added in v1.4.0
func (c *Client) GetStructuredProperties(ctx context.Context, urn string) ([]types.StructuredPropertyValue, error)
GetStructuredProperties retrieves structured property values assigned to an entity. Returns empty results (not an error) when structured properties are not available, which is common on DataHub versions before 1.3.x.
func (*Client) ListDataProducts ¶
ListDataProducts lists all data products. Uses search API as fallback if listDataProducts query is not available.
func (*Client) ListDomains ¶
ListDomains lists all domains.
func (*Client) ListStructuredPropertyDefinitions ¶ added in v1.4.0
func (c *Client) ListStructuredPropertyDefinitions(ctx context.Context) ([]types.StructuredPropertyDefinition, error)
ListStructuredPropertyDefinitions retrieves all structured property definitions. Returns empty results (not an error) when structured properties are not available, which is common on DataHub versions before 1.3.x.
func (*Client) RaiseIncident ¶ added in v1.4.0
RaiseIncident creates a new incident on entities.
func (*Client) RemoveGlossaryTerm ¶ added in v0.5.0
RemoveGlossaryTerm removes a glossary term from an entity. Uses GraphQL for domain, glossaryTerm, and glossaryNode entities because the REST API does not register glossaryTerms as an aspect for these types. Uses REST read-modify-write for all other entity types.
func (*Client) RemoveLink ¶ added in v0.5.0
RemoveLink removes a link from an entity by URL using read-modify-write.
func (*Client) RemoveOwner ¶ added in v1.5.0
RemoveOwner removes an owner from an entity.
func (*Client) RemoveStructuredProperties ¶ added in v1.4.0
func (c *Client) RemoveStructuredProperties(ctx context.Context, urn string, propertyURNs []string) error
RemoveStructuredProperties removes structured properties from an entity.
func (*Client) RemoveTag ¶ added in v0.5.0
RemoveTag removes a tag from an entity. Uses GraphQL for domain, glossaryTerm, and glossaryNode entities because the REST API does not register globalTags as an aspect for these types. Uses REST read-modify-write for all other entity types.
func (*Client) ResolveIncident ¶ added in v1.4.0
ResolveIncident marks an incident as resolved. It delegates to UpdateIncidentStatus.
func (*Client) Search ¶
func (c *Client) Search(ctx context.Context, query string, opts ...SearchOption) (*types.SearchResult, error)
Search searches for entities in DataHub.
func (*Client) SearchAcrossEntities ¶ added in v1.8.0
func (c *Client) SearchAcrossEntities(ctx context.Context, query string, opts ...SearchOption) (*types.SearchResult, error)
SearchAcrossEntities searches across entity types with optional advanced filtering. Supports multi-type search and field-level filters (e.g., fieldPaths, fieldTags, platform). Available in DataHub 1.3.x+.
func (*Client) SemanticSearch ¶ added in v1.4.0
func (c *Client) SemanticSearch(ctx context.Context, query string, opts ...SearchOption) (*types.SearchResult, error)
SemanticSearch performs fulltext search across entities. Uses searchAcrossEntities with fulltext mode for broader natural language matching. Returns an error (not empty results) when not supported because the caller explicitly chose semantic mode and should know it's unavailable.
func (*Client) UnsetDomain ¶ added in v1.5.0
UnsetDomain removes the domain from an entity.
func (*Client) UpdateColumnDescription ¶ added in v0.7.2
func (c *Client) UpdateColumnDescription(ctx context.Context, urn, fieldPath, description string) error
UpdateColumnDescription sets the editable description for a specific column using read-modify-write on the editableSchemaMetadata aspect.
func (*Client) UpdateDescription ¶ added in v0.5.0
UpdateDescription sets the editable description for any entity. Uses GraphQL for domain, glossaryTerm, and glossaryNode entities because the REST API does not support their description aspects. Uses REST read-modify-write for all other entity types. Document entities are not supported — use the DataHub document API.
func (*Client) UpdateDocumentContents ¶ added in v1.5.0
UpdateDocumentContents updates the title and text of a document.
func (*Client) UpdateDocumentRelatedEntities ¶ added in v1.5.0
func (c *Client) UpdateDocumentRelatedEntities(ctx context.Context, urn string, entityURNs []string) error
UpdateDocumentRelatedEntities updates entities related to a document.
func (*Client) UpdateDocumentStatus ¶ added in v1.5.0
UpdateDocumentStatus updates the publication status of a document.
func (*Client) UpdateDocumentSubType ¶ added in v1.5.0
UpdateDocumentSubType updates the sub-type of a document.
func (*Client) UpdateIncident ¶ added in v1.5.0
func (c *Client) UpdateIncident(ctx context.Context, urn string, input types.UpdateIncidentInput) error
UpdateIncident updates an existing incident.
func (*Client) UpdateIncidentStatus ¶ added in v1.5.0
func (c *Client) UpdateIncidentStatus(ctx context.Context, incidentURN, state, message string) error
UpdateIncidentStatus changes the state of an incident (ACTIVE or RESOLVED).
func (*Client) UpdateQuery ¶ added in v0.8.0
UpdateQuery updates an existing Query entity in DataHub.
func (*Client) UpdateStructuredProperty ¶ added in v1.5.0
func (c *Client) UpdateStructuredProperty(ctx context.Context, urn string, input types.UpdateStructuredPropertyInput) error
UpdateStructuredProperty updates a structured property definition.
func (*Client) UpsertContextDocument ¶ added in v1.6.0
func (c *Client) UpsertContextDocument( ctx context.Context, entityURN string, doc types.ContextDocumentInput, ) (*types.ContextDocument, error)
UpsertContextDocument creates or updates a context document on an entity. If doc.ID is empty, creates a new document linked to entityURN. If doc.ID is set, updates the existing document. The entityURN parameter is only used for create (linking the document to an entity); updates modify the document in place without changing entity associations.
The update path is non-atomic: it calls UpdateDocumentContents, then optionally UpdateDocumentSubType, then GetDocument. If UpdateDocumentSubType fails after contents were already committed, the document is left with new contents but the old category. The returned error indicates which step failed.
func (*Client) UpsertDataContract ¶ added in v1.5.0
func (c *Client) UpsertDataContract(ctx context.Context, input types.UpsertDataContractInput) (string, error)
UpsertDataContract creates or updates a data contract for a dataset.
func (*Client) UpsertStructuredProperties ¶ added in v1.4.0
func (c *Client) UpsertStructuredProperties(ctx context.Context, urn string, properties []types.StructuredPropertyInput) error
UpsertStructuredProperties sets or updates structured property values on an entity.
type Config ¶
type Config struct {
// URL is the DataHub GMS URL (required).
URL string
// Token is the personal access token (required).
Token string
// Timeout is the request timeout. Default: 30s.
Timeout time.Duration
// RetryMax is the maximum retry attempts. Default: 3.
RetryMax int
// DefaultLimit is the default search result limit. Default: 10.
DefaultLimit int
// MaxLimit is the maximum allowed limit. Default: 100.
MaxLimit int
// MaxLineageDepth is the maximum lineage traversal depth. Default: 5.
MaxLineageDepth int
// APIVersion selects the REST API version: "v1" (legacy Rest.li, default)
// or "v3" (OpenAPI v3, DataHub >= 1.4.0).
APIVersion string
// Debug enables debug logging. Default: false.
Debug bool
// Logger is the logger for debug output. If nil, a NopLogger is used.
// When Debug is true and Logger is nil, a StdLogger is created automatically.
Logger Logger
}
Config holds the DataHub client configuration.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with default values.
type CreateQueryInput ¶ added in v0.8.0
type CreateQueryInput struct {
// Name is an optional human-readable name for the query.
Name string
// Description is an optional description of the query.
Description string
// Statement is the SQL query text (required).
Statement string
// Language is the query language (default: "SQL").
Language string
// DatasetURNs are optional dataset URNs to associate with the query.
DatasetURNs []string
}
CreateQueryInput holds the parameters for creating a new Query entity.
type DescriptionAspectInfo ¶ added in v1.2.1
DescriptionAspectInfo holds the aspect name and field name for updating an entity's description. The field is "description" for most entity types, but "definition" for glossary entities.
func LookupDescriptionAspect ¶ added in v1.2.1
func LookupDescriptionAspect(entityType string) (DescriptionAspectInfo, error)
LookupDescriptionAspect returns the aspect info for updating the description of the given entity type.
type LineageOption ¶
type LineageOption func(*lineageOptions)
LineageOption configures lineage queries.
func WithDepth ¶
func WithDepth(depth int) LineageOption
WithDepth sets the maximum lineage traversal depth.
func WithDirection ¶
func WithDirection(dir string) LineageOption
WithDirection sets the lineage direction (UPSTREAM or DOWNSTREAM). The direction is normalized to uppercase.
type Logger ¶ added in v0.4.2
type Logger interface {
Debug(msg string, args ...any)
Info(msg string, args ...any)
Warn(msg string, args ...any)
Error(msg string, args ...any)
}
Logger defines the interface for debug logging. Compatible with slog.Logger and other structured loggers.
type NopLogger ¶ added in v0.4.2
type NopLogger struct{}
NopLogger is a logger that discards all output.
type SearchFilter ¶ added in v1.8.0
type SearchFilter struct {
// Field is the filter field name (e.g., "fieldPaths", "fieldTags", "platform", "owners").
Field string
// Values are the values to match against.
Values []string
// Condition is the filter operator: CONTAIN, EQUAL (default), IN, EXISTS, etc.
Condition string
// Negated inverts the filter (exclude matching entities).
Negated bool
}
SearchFilter represents a single filter criterion for advanced search. Filters are AND'd together within a single search request.
type SearchOption ¶
type SearchOption func(*searchOptions)
SearchOption configures search behavior.
func WithEntityType ¶
func WithEntityType(entityType string) SearchOption
WithEntityType filters search by entity type. Valid types: DATASET, DASHBOARD, DATA_FLOW, DATA_JOB, CONTAINER, DOMAIN, TAG, GLOSSARY_TERM, CORP_USER, CORP_GROUP, DATA_PRODUCT, etc. The entity type is normalized to SCREAMING_SNAKE_CASE (e.g., glossaryTerm -> GLOSSARY_TERM).
func WithFilters
deprecated
func WithFilters(filters map[string][]string) SearchOption
WithFilters adds search filters.
Deprecated: Use WithSearchFilters for advanced filtering with searchAcrossEntities.
func WithLimit ¶
func WithLimit(limit int) SearchOption
WithLimit sets the maximum number of results.
func WithOffset ¶
func WithOffset(offset int) SearchOption
WithOffset sets the result offset for pagination.
func WithSearchFilters ¶ added in v1.8.0
func WithSearchFilters(filters []SearchFilter) SearchOption
WithSearchFilters sets advanced search filters for searchAcrossEntities. All filters are AND'd together (all conditions must match).
func WithTypes ¶ added in v1.8.0
func WithTypes(types []string) SearchOption
WithTypes sets the entity types to search across. Valid types: DATASET, DASHBOARD, DATA_FLOW, DATA_JOB, CONTAINER, DOMAIN, TAG, GLOSSARY_TERM, CORP_USER, CORP_GROUP, DATA_PRODUCT, etc. Each type is normalized to SCREAMING_SNAKE_CASE.
type StdLogger ¶ added in v0.4.2
type StdLogger struct {
// contains filtered or unexported fields
}
StdLogger wraps the standard library logger.
func NewStdLogger ¶ added in v0.4.2
NewStdLogger creates a new StdLogger. If debug is true, Debug messages are logged; otherwise they are discarded.
type UpdateQueryInput ¶ added in v0.8.0
type UpdateQueryInput struct {
// URN is the query URN (required).
URN string
// Name is an optional updated name. Empty string means no change.
Name string
// Description is an optional updated description. Empty string means no change.
Description string
// Statement is an optional updated SQL text. Empty string means no change.
Statement string
// Language is an optional updated language. Empty string means no change.
Language string
// DatasetURNs are optional updated dataset associations. Nil means no change.
DatasetURNs []string
}
UpdateQueryInput holds the parameters for updating an existing Query entity.
Source Files
¶
- client.go
- config.go
- context_documents.go
- data_contracts.go
- doc.go
- documents.go
- errors.go
- incidents.go
- logger.go
- options.go
- queries.go
- rest.go
- schema_helpers.go
- search_across.go
- search_helpers.go
- semantic_search.go
- structured_properties.go
- urn.go
- write.go
- write_delete.go
- write_documents.go
- write_domains.go
- write_entities.go
- write_graphql.go
- write_incidents.go
- write_owners.go
- write_queries.go
- write_structured_properties_crud.go