client

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: Apache-2.0 Imports: 16 Imported by: 4

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

View Source
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+).

View Source
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+.

View Source
const (
	LineageDirectionUpstream   = "UPSTREAM"
	LineageDirectionDownstream = "DOWNSTREAM"
)

Constants for lineage directions.

View Source
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.

View Source
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+.

View Source
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)
}
`
)
View Source
const APIVersionV1 = "v1"

APIVersionV1 selects the legacy Rest.li API endpoints (DataHub <= 1.3.x).

View Source
const APIVersionV3 = "v3"

APIVersionV3 selects the OpenAPI v3 endpoints (DataHub >= 1.4.0).

View Source
const DefaultEntityType = "DATASET"

DefaultEntityType is the entity type used when none is specified.

View Source
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.

View Source
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+).

View Source
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.

View Source
const SemanticSearchQuery = SearchAcrossEntitiesQuery

SemanticSearchQuery is an alias for SearchAcrossEntitiesQuery. SemanticSearch uses the same GraphQL query but adds searchFlags.fulltext=true.

Variables

View Source
var (
	// ErrUnauthorized indicates invalid or missing authentication token.
	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.

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

func BuildChartURN(platform, chartID string) string

BuildChartURN constructs a chart URN.

func BuildDashboardURN

func BuildDashboardURN(platform, dashboardID string) string

BuildDashboardURN constructs a dashboard URN.

func BuildDataFlowURN

func BuildDataFlowURN(orchestrator, flowID, cluster string) string

BuildDataFlowURN constructs a data flow URN.

func BuildDataJobURN

func BuildDataJobURN(dataFlowURN, jobID string) string

BuildDataJobURN constructs a data job URN.

func BuildDatasetURN

func BuildDatasetURN(platform, qualifiedName, env string) string

BuildDatasetURN constructs a dataset URN.

func BuildDocumentURN added in v1.6.0

func BuildDocumentURN(documentID string) string

BuildDocumentURN constructs a document URN.

func BuildDomainURN

func BuildDomainURN(domainID string) string

BuildDomainURN constructs a domain URN.

func BuildGlossaryTermURN

func BuildGlossaryTermURN(termPath string) string

BuildGlossaryTermURN constructs a glossary term URN.

func BuildTagURN

func BuildTagURN(tagName string) string

BuildTagURN constructs a tag URN.

func ParseURN

func ParseURN(urn string) (*types.ParsedURN, error)

ParseURN parses a DataHub URN into its components.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a GraphQL client for DataHub.

func New

func New(cfg Config) (*Client, error)

New creates a new DataHub client with the given configuration.

func NewFromEnv

func NewFromEnv() (*Client, error)

NewFromEnv creates a new DataHub client from environment variables.

func (*Client) AddGlossaryTerm added in v0.5.0

func (c *Client) AddGlossaryTerm(ctx context.Context, urn, termURN string) error

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 (c *Client) AddLink(ctx context.Context, urn, linkURL, description string) error

AddLink adds a link to an entity using read-modify-write on institutionalMemory.

func (*Client) AddOwner added in v1.5.0

func (c *Client) AddOwner(ctx context.Context, urn, ownerURN, ownershipType string) error

AddOwner adds an owner to an entity.

func (*Client) AddTag added in v0.5.0

func (c *Client) AddTag(ctx context.Context, urn, tagURN string) error

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

func (c *Client) Close() error

Close closes the client.

func (*Client) Config

func (c *Client) Config() Config

Config returns the client configuration.

func (*Client) CreateApplication added in v1.5.0

func (c *Client) CreateApplication(ctx context.Context, name, description string) (string, error)

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

func (c *Client) CreateDomain(ctx context.Context, name, description string) (string, error)

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

func (c *Client) CreateQuery(ctx context.Context, input CreateQueryInput) (*types.Query, error)

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) CreateTag added in v1.5.0

func (c *Client) CreateTag(ctx context.Context, name, description string) (string, error)

CreateTag creates a new tag entity in DataHub.

func (*Client) DeleteApplication added in v1.5.0

func (c *Client) DeleteApplication(ctx context.Context, urn string) error

DeleteApplication deletes an application entity.

func (*Client) DeleteContextDocument added in v1.6.0

func (c *Client) DeleteContextDocument(ctx context.Context, documentID string) error

DeleteContextDocument removes a context document by its ID.

func (*Client) DeleteDataProduct added in v1.5.0

func (c *Client) DeleteDataProduct(ctx context.Context, urn string) error

DeleteDataProduct deletes a data product entity.

func (*Client) DeleteDocument added in v1.5.0

func (c *Client) DeleteDocument(ctx context.Context, urn string) error

DeleteDocument deletes a document entity.

func (*Client) DeleteDomain added in v1.5.0

func (c *Client) DeleteDomain(ctx context.Context, urn string) error

DeleteDomain deletes a domain entity.

func (*Client) DeleteGlossaryEntity added in v1.5.0

func (c *Client) DeleteGlossaryEntity(ctx context.Context, urn string) error

DeleteGlossaryEntity deletes a glossary term or node.

func (*Client) DeleteQuery added in v0.8.0

func (c *Client) DeleteQuery(ctx context.Context, urn string) error

DeleteQuery deletes a Query entity from DataHub.

func (*Client) DeleteStructuredProperty added in v1.5.0

func (c *Client) DeleteStructuredProperty(ctx context.Context, urn string) error

DeleteStructuredProperty deletes a structured property definition.

func (*Client) DeleteTag added in v1.5.0

func (c *Client) DeleteTag(ctx context.Context, urn string) error

DeleteTag deletes a tag entity.

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

func (c *Client) GetColumnLineage(ctx context.Context, urn string) (*types.ColumnLineage, error)

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

func (c *Client) GetDataProduct(ctx context.Context, urn string) (*types.DataProduct, error)

GetDataProduct retrieves a data product by URN.

func (*Client) GetDocument added in v1.5.0

func (c *Client) GetDocument(ctx context.Context, urn string) (*types.Document, error)

GetDocument retrieves a document by URN.

func (*Client) GetEntity

func (c *Client) GetEntity(ctx context.Context, urn string) (*types.Entity, error)

GetEntity retrieves a single entity by URN.

func (*Client) GetGlossaryTerm

func (c *Client) GetGlossaryTerm(ctx context.Context, urn string) (*types.GlossaryTerm, error)

GetGlossaryTerm retrieves a glossary term by URN.

func (*Client) GetIncidents added in v1.4.0

func (c *Client) GetIncidents(ctx context.Context, urn string) (*types.IncidentResult, error)

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

func (c *Client) GetQueries(ctx context.Context, urn string) (*types.QueryList, error)

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

func (c *Client) GetRelatedDocuments(ctx context.Context, urn string) ([]types.Document, error)

GetRelatedDocuments retrieves documents linked to an entity.

func (*Client) GetSchema

func (c *Client) GetSchema(ctx context.Context, urn string) (*types.SchemaMetadata, error)

GetSchema retrieves schema metadata for a dataset.

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

func (c *Client) ListDataProducts(ctx context.Context) ([]types.DataProduct, error)

ListDataProducts lists all data products. Uses search API as fallback if listDataProducts query is not available.

func (*Client) ListDomains

func (c *Client) ListDomains(ctx context.Context) ([]types.Domain, error)

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

func (c *Client) ListTags(ctx context.Context, filter string) ([]types.Tag, error)

ListTags lists all tags, optionally filtered.

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) error

Ping tests the connection to DataHub.

func (*Client) RaiseIncident added in v1.4.0

func (c *Client) RaiseIncident(ctx context.Context, input types.RaiseIncidentInput) (string, error)

RaiseIncident creates a new incident on entities.

func (*Client) RemoveGlossaryTerm added in v0.5.0

func (c *Client) RemoveGlossaryTerm(ctx context.Context, urn, termURN string) error

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 (c *Client) RemoveLink(ctx context.Context, urn, linkURL string) error

RemoveLink removes a link from an entity by URL using read-modify-write.

func (*Client) RemoveOwner added in v1.5.0

func (c *Client) RemoveOwner(ctx context.Context, urn, ownerURN string) error

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

func (c *Client) RemoveTag(ctx context.Context, urn, tagURN string) error

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

func (c *Client) ResolveIncident(ctx context.Context, incidentURN, message string) error

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) SetDomain added in v1.5.0

func (c *Client) SetDomain(ctx context.Context, entityURN, domainURN string) error

SetDomain assigns a domain to an entity.

func (*Client) UnsetDomain added in v1.5.0

func (c *Client) UnsetDomain(ctx context.Context, entityURN string) error

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

func (c *Client) UpdateDescription(ctx context.Context, urn, description string) error

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

func (c *Client) UpdateDocumentContents(ctx context.Context, urn, title, text string) error

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

func (c *Client) UpdateDocumentStatus(ctx context.Context, urn, status string) error

UpdateDocumentStatus updates the publication status of a document.

func (*Client) UpdateDocumentSubType added in v1.5.0

func (c *Client) UpdateDocumentSubType(ctx context.Context, urn, subType string) error

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

func (c *Client) UpdateQuery(ctx context.Context, input UpdateQueryInput) (*types.Query, error)

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.

func FromEnv

func FromEnv() (Config, error)

FromEnv creates a Config from environment variables.

func (Config) Validate

func (c Config) Validate() error

Validate checks if the configuration is valid.

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

type DescriptionAspectInfo struct {
	AspectName string
	FieldName  string
}

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.

func (NopLogger) Debug added in v0.4.2

func (NopLogger) Debug(_ string, _ ...any)

Debug implements Logger.

func (NopLogger) Error added in v0.4.2

func (NopLogger) Error(_ string, _ ...any)

Error implements Logger.

func (NopLogger) Info added in v0.4.2

func (NopLogger) Info(_ string, _ ...any)

Info implements Logger.

func (NopLogger) Warn added in v0.4.2

func (NopLogger) Warn(_ string, _ ...any)

Warn implements Logger.

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

func NewStdLogger(debug bool) *StdLogger

NewStdLogger creates a new StdLogger. If debug is true, Debug messages are logged; otherwise they are discarded.

func (*StdLogger) Debug added in v0.4.2

func (l *StdLogger) Debug(msg string, args ...any)

Debug implements Logger.

func (*StdLogger) Error added in v0.4.2

func (l *StdLogger) Error(msg string, args ...any)

Error implements Logger.

func (*StdLogger) Info added in v0.4.2

func (l *StdLogger) Info(msg string, args ...any)

Info implements Logger.

func (*StdLogger) Warn added in v0.4.2

func (l *StdLogger) Warn(msg string, args ...any)

Warn implements Logger.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL