#[non_exhaustive]pub struct MarpleDB { /* private fields */ }Expand description
Client for the MarpleDB API.
Implementations§
Source§impl MarpleDB
impl MarpleDB
Sourcepub fn new(url: &str, token: &str) -> Result<Self>
pub fn new(url: &str, token: &str) -> Result<Self>
Creates a new client for url using a bearer API token.
The URL should point at the MarpleDB API root and usually ends in
/api/v1, for example https://db.marpledata.com/api/v1.
Sourcepub fn builder() -> MarpleDBBuilder
pub fn builder() -> MarpleDBBuilder
Creates a builder for configuring a client.
Use the builder when you need custom timeouts, a user agent, or
preconfigured reqwest::Client instances.
Sourcepub fn storage_client(&self) -> &Client
pub fn storage_client(&self) -> &Client
Returns the header-free storage client used for pre-signed download and upload URLs.
Direct storage URLs are already authenticated by the URL itself. This client intentionally does not include MarpleDB authorization headers.
Sourcepub async fn get<Q, R>(&self, endpoint: &str, query: &Q) -> Result<R>
pub async fn get<Q, R>(&self, endpoint: &str, query: &Q) -> Result<R>
Sends a GET request and deserializes the JSON response.
Use &() for endpoints without query parameters. The response type is
inferred from assignment or turbofish annotations.
Sourcepub async fn post<B, R>(&self, endpoint: &str, body: &B) -> Result<R>
pub async fn post<B, R>(&self, endpoint: &str, body: &B) -> Result<R>
Sends a POST request with a JSON body and deserializes the JSON response.
The body may be any serializable value. Use serde_json::Value as the
response type when calling untyped endpoints.
Sourcepub async fn delete<B, R>(&self, endpoint: &str, body: &B) -> Result<R>
pub async fn delete<B, R>(&self, endpoint: &str, body: &B) -> Result<R>
Sends a DELETE request with a JSON body and deserializes the JSON response.
The body may be any serializable value. Pass &serde_json::json!({})
when the endpoint expects an empty JSON object.
Sourcepub async fn health(&self) -> Result<HealthResponse>
pub async fn health(&self) -> Result<HealthResponse>
Checks MarpleDB API health.
Sourcepub async fn get_streams(&self) -> Result<Vec<Stream>>
pub async fn get_streams(&self) -> Result<Vec<Stream>>
Lists all streams visible to the token.
Sourcepub async fn get_stream(&self, stream_name: &str) -> Result<Stream>
pub async fn get_stream(&self, stream_name: &str) -> Result<Stream>
Finds a stream by name.
Sourcepub async fn create_stream<S: Serialize + ?Sized>(
&self,
stream_name: &str,
options: &S,
) -> Result<Stream>
pub async fn create_stream<S: Serialize + ?Sized>( &self, stream_name: &str, options: &S, ) -> Result<Stream>
Creates a stream with a name and serializable options object.
options must serialize to a JSON object. The SDK adds the name
field before sending the request.
Sourcepub async fn update_stream<S: Serialize + ?Sized>(
&self,
stream_id: i32,
options: &S,
) -> Result<Stream>
pub async fn update_stream<S: Serialize + ?Sized>( &self, stream_id: i32, options: &S, ) -> Result<Stream>
Updates a stream with a serializable options object.
options must serialize to the JSON object expected by the MarpleDB
stream update endpoint.
Sourcepub async fn get_datasets(&self, stream_id: i32) -> Result<Vec<Dataset>>
pub async fn get_datasets(&self, stream_id: i32) -> Result<Vec<Dataset>>
Lists datasets in a stream.
Sourcepub async fn get_datapool_datasets(&self, pool: &str) -> Result<Vec<Dataset>>
pub async fn get_datapool_datasets(&self, pool: &str) -> Result<Vec<Dataset>>
Lists all datasets in a datapool.
Sourcepub async fn get_datapool_ingest_queue(
&self,
pool: &str,
) -> Result<Vec<Dataset>>
pub async fn get_datapool_ingest_queue( &self, pool: &str, ) -> Result<Vec<Dataset>>
Lists datasets currently in the ingest queue for a datapool.
Sourcepub async fn get_dataset(
&self,
stream_id: i32,
dataset_id: i32,
) -> Result<Dataset>
pub async fn get_dataset( &self, stream_id: i32, dataset_id: i32, ) -> Result<Dataset>
Fetches a dataset by stream id and dataset id.
Sourcepub async fn get_download_link(&self, dataset: &Dataset) -> Result<Url>
pub async fn get_download_link(&self, dataset: &Dataset) -> Result<Url>
Returns a pre-signed URL for downloading a dataset’s original uploaded file.
The returned URL is already authenticated and may expire. Use
MarpleDB::storage_client or another header-free HTTP client to fetch it.
Sourcepub async fn wait_for_import(
&self,
stream_id: i32,
dataset_id: i32,
timeout: Duration,
) -> Result<Dataset>
pub async fn wait_for_import( &self, stream_id: i32, dataset_id: i32, timeout: Duration, ) -> Result<Dataset>
Waits until an import reaches a terminal status or times out.
Polls every 500ms. Finished and Live return the dataset, while
Failed and PostprocessingFailed return Error::ImportFailed.