dune_api/pipelines/
types.rs1use serde::{Deserialize, Serialize};
4use std::collections::HashMap;
5
6#[derive(Debug, Clone, Serialize)]
8pub struct ExecutePipelineRequest {
9 pub pipeline: Pipeline,
11 #[serde(skip_serializing_if = "Option::is_none")]
13 pub query_parameters: Option<HashMap<String, String>>,
14 #[serde(skip_serializing_if = "Option::is_none")]
16 pub performance: Option<String>,
17}
18
19#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct Pipeline {
22 pub nodes: Vec<PipelineNode>,
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
28pub struct PipelineNode {
29 #[serde(rename = "type")]
31 pub node_type: String,
32 pub query_id: Option<i64>,
34 pub matview_name: Option<String>,
36 #[serde(default)]
38 pub depends_on: Vec<String>,
39 pub id: Option<String>,
41}
42
43impl PipelineNode {
44 pub fn query(query_id: i64) -> Self {
46 Self {
47 node_type: "query_execution".to_string(),
48 query_id: Some(query_id),
49 matview_name: None,
50 depends_on: vec![],
51 id: None,
52 }
53 }
54
55 pub fn matview(name: &str) -> Self {
57 Self {
58 node_type: "materialized_view_refresh".to_string(),
59 query_id: None,
60 matview_name: Some(name.to_string()),
61 depends_on: vec![],
62 id: None,
63 }
64 }
65
66 pub fn with_id(mut self, id: &str) -> Self {
68 self.id = Some(id.to_string());
69 self
70 }
71
72 pub fn depends_on(mut self, deps: Vec<String>) -> Self {
74 self.depends_on = deps;
75 self
76 }
77}
78
79#[derive(Debug, Clone, Deserialize, Serialize)]
81pub struct ExecutePipelineResponse {
82 pub pipeline_execution_id: Option<String>,
84 #[serde(default)]
86 pub node_executions: Vec<NodeExecution>,
87}
88
89#[derive(Debug, Clone, Deserialize, Serialize)]
91pub struct NodeExecution {
92 pub node_id: Option<String>,
94 pub execution_id: Option<String>,
96 pub state: Option<String>,
98}
99
100#[derive(Debug, Clone, Deserialize, Serialize)]
102pub struct PipelineExecutionStatus {
103 pub pipeline_execution_id: Option<String>,
105 pub state: Option<String>,
107 pub is_execution_finished: Option<bool>,
109 #[serde(default)]
111 pub node_executions: Vec<NodeExecutionStatus>,
112}
113
114#[derive(Debug, Clone, Deserialize, Serialize)]
116pub struct NodeExecutionStatus {
117 pub node_id: Option<String>,
119 #[serde(rename = "type")]
121 pub node_type: Option<String>,
122 pub execution_id: Option<String>,
124 pub state: Option<String>,
126 pub query_id: Option<i64>,
128 pub matview_name: Option<String>,
130}