Skip to main content

headwaters_client/
types.rs

1//! The read-API message types, re-exported from [`headwaters_proto`].
2//!
3//! These are the owned proto messages the [`HeadwatersClient`](crate::HeadwatersClient)
4//! returns. Their open-ended `facets` / `data` / `fields` / `events` fields are
5//! `google.protobuf.Struct`; [`struct_to_json`] converts one to a
6//! [`serde_json::Value`] so callers can read it without depending on buffa.
7
8pub use headwaters_proto::headwaters::read::v1::{
9    Dataset, DatasetType, DatasetVersion, DatasetVersionId, EntityId, EntityKind,
10    GetAssetStatsRequest, GetColumnLineageRequest, GetDatasetRequest, GetJobRequest,
11    GetJobRunsRequest, GetLineageEventStatsRequest, GetLineageRequest, GetRunFacetsRequest,
12    GetTagDownstreamRequest, JobDetail, JobType, LineageEdge, LineageGraph, LineageNode,
13    ListDatasetVersionsRequest, ListDatasetVersionsResponse, ListDatasetsRequest,
14    ListDatasetsResponse, ListEventsRequest, ListEventsResponse, ListJobsRequest, ListJobsResponse,
15    ListNamespacesRequest, ListNamespacesResponse, ListRunsResponse, ListTagsRequest,
16    ListTagsResponse, Namespace, RunDetail, RunFacetsResponse, RunState, SearchRequest,
17    SearchResponse, SearchResult, StatBucket, StatsResponse, Tag, TagPropagation, TaggedField,
18};
19
20/// The `google.protobuf.Struct` carried by open-ended fields (`facets`, `data`,
21/// schema `fields`, raw `events`).
22pub type Struct = buffa_types::google::protobuf::Struct;
23
24/// Convert an open-ended [`Struct`] into a [`serde_json::Value`] (always a JSON
25/// object). Use it to read `facets` / `data` / `fields` / `events` without
26/// touching buffa types directly.
27pub fn struct_to_json(value: &Struct) -> serde_json::Value {
28    serde_json::to_value(value).unwrap_or(serde_json::Value::Null)
29}