pub struct CatalogClient { /* private fields */ }Expand description
Async client for the Catalog API.
Holds an Arc<Configuration> so it’s cheap to clone and share across
tasks. Every method is async and returns Result<_, CatalogError>.
Implementations§
Source§impl CatalogClient
impl CatalogClient
Sourcepub fn new(configuration: Arc<Configuration>) -> Self
pub fn new(configuration: Arc<Configuration>) -> Self
Construct a new client from a shared Configuration.
Sourcepub async fn search(
&self,
params: SearchParams,
) -> Result<SearchResponse, CatalogError>
pub async fn search( &self, params: SearchParams, ) -> Result<SearchResponse, CatalogError>
Search datasets. See the module docs for parameters.
§Errors
Returns CatalogError::ApiError if the server returns non-2xx,
CatalogError::RequestError for network/TLS failure, and
CatalogError::ParseError if the response isn’t a valid
SearchResponse.
Sourcepub async fn dataset_by_slug(
&self,
slug: &str,
) -> Result<Option<SearchHit>, CatalogError>
pub async fn dataset_by_slug( &self, slug: &str, ) -> Result<Option<SearchHit>, CatalogError>
Fetch a single dataset by its data.gov slug.
Returns Ok(None) if no dataset with that slug exists. The returned
SearchHit carries the denormalized fields and a
nested dcat record with the full DCAT-US 3 metadata.
§Notes
The Catalog API does not actually honor a slug= query parameter
today — it returns the top relevance hit regardless of the value.
We work around this by using a full-text query (q=<slug>) and then
scanning the first page for a hit whose slug exactly matches.
Slug-shaped queries reliably rank the exact match first when it
exists; we look at the top 20 results to leave headroom for ties.
Sourcepub async fn organizations(&self) -> Result<OrganizationsResponse, CatalogError>
pub async fn organizations(&self) -> Result<OrganizationsResponse, CatalogError>
List all organizations known to the catalog.
The endpoint returns the full list in one response; there is no pagination today.
Sourcepub async fn keywords(
&self,
size: Option<i32>,
min_count: Option<i32>,
) -> Result<KeywordsResponse, CatalogError>
pub async fn keywords( &self, size: Option<i32>, min_count: Option<i32>, ) -> Result<KeywordsResponse, CatalogError>
Return the top keywords ranked by document frequency.
size caps the number of rows (server default 100, max 1000).
min_count drops keywords with fewer than that many datasets.
Sourcepub async fn locations_search(
&self,
q: &str,
size: Option<i32>,
) -> Result<LocationsResponse, CatalogError>
pub async fn locations_search( &self, q: &str, size: Option<i32>, ) -> Result<LocationsResponse, CatalogError>
Autocomplete against known locations.
Sourcepub async fn location_geometry(&self, id: &str) -> Result<Value, CatalogError>
pub async fn location_geometry(&self, id: &str) -> Result<Value, CatalogError>
Fetch the GeoJSON geometry for a given location id.
The response is returned as a raw serde_json::Value because the
shape is unconstrained GeoJSON and callers typically hand it straight
to a mapping library.
Sourcepub async fn harvest_record(
&self,
id: &str,
) -> Result<HarvestRecord, CatalogError>
pub async fn harvest_record( &self, id: &str, ) -> Result<HarvestRecord, CatalogError>
Retrieve a harvest record’s metadata envelope.
Sourcepub async fn harvest_record_raw(&self, id: &str) -> Result<Value, CatalogError>
pub async fn harvest_record_raw(&self, id: &str) -> Result<Value, CatalogError>
Retrieve the raw (pre-transform) payload a harvester ingested.
The payload is not constrained to a single shape — agencies post JSON,
XML fragments, and DCAT records through the same surface — so the
result is returned as serde_json::Value.
Sourcepub async fn harvest_record_transformed(
&self,
id: &str,
) -> Result<Dataset, CatalogError>
pub async fn harvest_record_transformed( &self, id: &str, ) -> Result<Dataset, CatalogError>
Retrieve the DCAT-US 3 transform of a harvest record.