Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use serde::de::DeserializeOwned;
use tracing::{info, instrument};
use uuid::Uuid;

use crate::model::{app, run};
use crate::model::{app, event_stream, run};

pub type ClientResult<T> = Result<T, ClientError>;

Expand All @@ -28,6 +28,14 @@ impl TiledClient {
pub async fn run_metadata(&self, id: Uuid) -> ClientResult<run::RunMetadataRoot> {
self.request(&format!("/api/v1/metadata/{id}")).await
}
pub async fn event_stream_metadata(
&self,
id: Uuid,
stream: String,
) -> ClientResult<event_stream::EventStreamMetadataRoot> {
self.request(&format!("/api/v1/metadata/{id}/{stream}"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be ok for now but we should probably parse/validate/check the stream before sticking it on the end of the URL before this is made user-facing.

.await
}
}

#[derive(Debug)]
Expand Down
9 changes: 9 additions & 0 deletions src/model.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub(crate) mod app;
pub(crate) mod container;
pub(crate) mod event_stream;
pub(crate) mod node;
pub(crate) mod run;

Expand All @@ -24,6 +25,14 @@ impl TiledQuery {
) -> async_graphql::Result<run::RunMetadataRoot, ClientError> {
self.0.run_metadata(id).await
}
#[instrument(skip(self))]
async fn event_stream_metadata(
&self,
id: Uuid,
stream: String,
) -> async_graphql::Result<event_stream::EventStreamMetadataRoot, ClientError> {
self.0.event_stream_metadata(id, stream).await
}
}

#[cfg(test)]
Expand Down
45 changes: 45 additions & 0 deletions src/model/event_stream.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
use std::collections::HashMap;

use async_graphql::SimpleObject;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use uuid::Uuid;

use crate::model::{container, node};

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, SimpleObject)]
pub struct EventStreamMetadataRoot {
pub data: EventStreamData,
pub error: Value,
pub links: Option<node::Links>,
pub meta: Value,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, SimpleObject)]
pub struct EventStreamData {
pub id: String,
pub attributes: EventStreamContainerAttributes,
pub links: node::Links,
pub meta: Value,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, SimpleObject)]
pub struct EventStreamContainerAttributes {
pub ancestors: Vec<Value>,
pub structure_family: String,
pub specs: Vec<container::Specs>,
pub metadata: EventStreamMetadata,
pub structure: container::Structure,
pub access_blob: Value,
pub sorting: Option<Vec<container::Sorting>>,
pub data_sources: Value,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, SimpleObject)]
pub struct EventStreamMetadata {
configuration: HashMap<String, HashMap<String, Value>>,
data_keys: HashMap<String, HashMap<String, Value>>,
time: f64,
uid: Uuid,
hints: HashMap<String, Value>,
}
Loading