Add field endpoint
Some checks failed
CI / Typos (push) Successful in 21s
CI / Clippy (push) Successful in 3m23s
CI / Build and test (push) Failing after 3m16s
CI / Build and test (all features) (push) Failing after 9m17s

This commit is contained in:
2026-03-24 09:19:15 -07:00
parent f7ea25f059
commit 32e606c30e
5 changed files with 207 additions and 46 deletions

View File

@@ -140,8 +140,8 @@ impl DatasetClient {
Ok(Box::pin(check_status(resp).await?.bytes_stream()))
}
/// `GET /field` — extract a field from an item by object path (e.g. `$.flac.title`).
pub async fn get_field(
/// `GET /extract` — extract a field from an item by object path (e.g. `$.flac.title`).
pub async fn get_extract(
&self,
source: &str,
key: &str,
@@ -149,7 +149,7 @@ impl DatasetClient {
) -> Result<FieldResponse, ClientError> {
let resp = self
.client
.get(format!("{}/field", self.base_url))
.get(format!("{}/extract", self.base_url))
.query(&[("source", source), ("key", key), ("path", path)])
.send()
.await?;
@@ -168,6 +168,34 @@ impl DatasetClient {
Ok(FieldResponse { content_type, data })
}
/// `GET /field` — get a field from an item's schema
pub async fn get_field(
&self,
source: &str,
key: &str,
field: &str,
) -> Result<FieldResponse, ClientError> {
let resp = self
.client
.get(format!("{}/field", self.base_url))
.query(&[("source", source), ("key", key), ("field", field)])
.send()
.await?;
let resp = check_status(resp).await?;
let content_type = resp
.headers()
.get(header::CONTENT_TYPE)
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream")
.to_owned();
let data = resp.bytes().await?;
Ok(FieldResponse { content_type, data })
}
/// `GET /items` — paginate over all items in this dataset, ordered by (source, key).
pub async fn list_items(
&self,