geoengine_api_client/apis/
workflows_api.rs1use reqwest;
12use serde::{Deserialize, Serialize, de::Error as _};
13use crate::{apis::ResponseContent, models};
14use super::{Error, configuration, ContentType};
15
16
17#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum DatasetFromWorkflowHandlerError {
21 UnknownValue(serde_json::Value),
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum GetWorkflowAllMetadataZipHandlerError {
28 UnknownValue(serde_json::Value),
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum GetWorkflowMetadataHandlerError {
35 UnknownValue(serde_json::Value),
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum GetWorkflowProvenanceHandlerError {
42 UnknownValue(serde_json::Value),
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum LoadWorkflowHandlerError {
49 UnknownValue(serde_json::Value),
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum RasterStreamWebsocketError {
56 UnknownValue(serde_json::Value),
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize)]
61#[serde(untagged)]
62pub enum RegisterWorkflowHandlerError {
63 UnknownValue(serde_json::Value),
64}
65
66
67pub async fn dataset_from_workflow_handler(configuration: &configuration::Configuration, id: &str, raster_dataset_from_workflow: models::RasterDatasetFromWorkflow) -> Result<models::TaskResponse, Error<DatasetFromWorkflowHandlerError>> {
68 let p_path_id = id;
70 let p_body_raster_dataset_from_workflow = raster_dataset_from_workflow;
71
72 let uri_str = format!("{}/datasetFromWorkflow/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
73 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
74
75 if let Some(ref user_agent) = configuration.user_agent {
76 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
77 }
78 if let Some(ref token) = configuration.bearer_access_token {
79 req_builder = req_builder.bearer_auth(token.to_owned());
80 };
81 req_builder = req_builder.json(&p_body_raster_dataset_from_workflow);
82
83 let req = req_builder.build()?;
84 let resp = configuration.client.execute(req).await?;
85
86 let status = resp.status();
87 let content_type = resp
88 .headers()
89 .get("content-type")
90 .and_then(|v| v.to_str().ok())
91 .unwrap_or("application/octet-stream");
92 let content_type = super::ContentType::from(content_type);
93
94 if !status.is_client_error() && !status.is_server_error() {
95 let content = resp.text().await?;
96 match content_type {
97 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
98 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TaskResponse`"))),
99 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TaskResponse`")))),
100 }
101 } else {
102 let content = resp.text().await?;
103 let entity: Option<DatasetFromWorkflowHandlerError> = serde_json::from_str(&content).ok();
104 Err(Error::ResponseError(ResponseContent { status, content, entity }))
105 }
106}
107
108pub async fn get_workflow_all_metadata_zip_handler(configuration: &configuration::Configuration, id: &str) -> Result<reqwest::Response, Error<GetWorkflowAllMetadataZipHandlerError>> {
109 let p_path_id = id;
111
112 let uri_str = format!("{}/workflow/{id}/allMetadata/zip", configuration.base_path, id=crate::apis::urlencode(p_path_id));
113 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
114
115 if let Some(ref user_agent) = configuration.user_agent {
116 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
117 }
118 if let Some(ref token) = configuration.bearer_access_token {
119 req_builder = req_builder.bearer_auth(token.to_owned());
120 };
121
122 let req = req_builder.build()?;
123 let resp = configuration.client.execute(req).await?;
124
125 let status = resp.status();
126
127 if !status.is_client_error() && !status.is_server_error() {
128 Ok(resp)
129 } else {
130 let content = resp.text().await?;
131 let entity: Option<GetWorkflowAllMetadataZipHandlerError> = serde_json::from_str(&content).ok();
132 Err(Error::ResponseError(ResponseContent { status, content, entity }))
133 }
134}
135
136pub async fn get_workflow_metadata_handler(configuration: &configuration::Configuration, id: &str) -> Result<models::TypedResultDescriptor, Error<GetWorkflowMetadataHandlerError>> {
137 let p_path_id = id;
139
140 let uri_str = format!("{}/workflow/{id}/metadata", configuration.base_path, id=crate::apis::urlencode(p_path_id));
141 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
142
143 if let Some(ref user_agent) = configuration.user_agent {
144 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
145 }
146 if let Some(ref token) = configuration.bearer_access_token {
147 req_builder = req_builder.bearer_auth(token.to_owned());
148 };
149
150 let req = req_builder.build()?;
151 let resp = configuration.client.execute(req).await?;
152
153 let status = resp.status();
154 let content_type = resp
155 .headers()
156 .get("content-type")
157 .and_then(|v| v.to_str().ok())
158 .unwrap_or("application/octet-stream");
159 let content_type = super::ContentType::from(content_type);
160
161 if !status.is_client_error() && !status.is_server_error() {
162 let content = resp.text().await?;
163 match content_type {
164 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
165 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TypedResultDescriptor`"))),
166 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TypedResultDescriptor`")))),
167 }
168 } else {
169 let content = resp.text().await?;
170 let entity: Option<GetWorkflowMetadataHandlerError> = serde_json::from_str(&content).ok();
171 Err(Error::ResponseError(ResponseContent { status, content, entity }))
172 }
173}
174
175pub async fn get_workflow_provenance_handler(configuration: &configuration::Configuration, id: &str) -> Result<Vec<models::ProvenanceEntry>, Error<GetWorkflowProvenanceHandlerError>> {
176 let p_path_id = id;
178
179 let uri_str = format!("{}/workflow/{id}/provenance", configuration.base_path, id=crate::apis::urlencode(p_path_id));
180 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
181
182 if let Some(ref user_agent) = configuration.user_agent {
183 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
184 }
185 if let Some(ref token) = configuration.bearer_access_token {
186 req_builder = req_builder.bearer_auth(token.to_owned());
187 };
188
189 let req = req_builder.build()?;
190 let resp = configuration.client.execute(req).await?;
191
192 let status = resp.status();
193 let content_type = resp
194 .headers()
195 .get("content-type")
196 .and_then(|v| v.to_str().ok())
197 .unwrap_or("application/octet-stream");
198 let content_type = super::ContentType::from(content_type);
199
200 if !status.is_client_error() && !status.is_server_error() {
201 let content = resp.text().await?;
202 match content_type {
203 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
204 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::ProvenanceEntry>`"))),
205 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::ProvenanceEntry>`")))),
206 }
207 } else {
208 let content = resp.text().await?;
209 let entity: Option<GetWorkflowProvenanceHandlerError> = serde_json::from_str(&content).ok();
210 Err(Error::ResponseError(ResponseContent { status, content, entity }))
211 }
212}
213
214pub async fn load_workflow_handler(configuration: &configuration::Configuration, id: &str) -> Result<models::Workflow, Error<LoadWorkflowHandlerError>> {
215 let p_path_id = id;
217
218 let uri_str = format!("{}/workflow/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
219 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
220
221 if let Some(ref user_agent) = configuration.user_agent {
222 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
223 }
224 if let Some(ref token) = configuration.bearer_access_token {
225 req_builder = req_builder.bearer_auth(token.to_owned());
226 };
227
228 let req = req_builder.build()?;
229 let resp = configuration.client.execute(req).await?;
230
231 let status = resp.status();
232 let content_type = resp
233 .headers()
234 .get("content-type")
235 .and_then(|v| v.to_str().ok())
236 .unwrap_or("application/octet-stream");
237 let content_type = super::ContentType::from(content_type);
238
239 if !status.is_client_error() && !status.is_server_error() {
240 let content = resp.text().await?;
241 match content_type {
242 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
243 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Workflow`"))),
244 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Workflow`")))),
245 }
246 } else {
247 let content = resp.text().await?;
248 let entity: Option<LoadWorkflowHandlerError> = serde_json::from_str(&content).ok();
249 Err(Error::ResponseError(ResponseContent { status, content, entity }))
250 }
251}
252
253pub async fn raster_stream_websocket(configuration: &configuration::Configuration, id: &str, spatial_bounds: models::SpatialPartition2D, time_interval: &str, attributes: &str, result_type: models::RasterStreamWebsocketResultType) -> Result<(), Error<RasterStreamWebsocketError>> {
254 let p_path_id = id;
256 let p_query_spatial_bounds = spatial_bounds;
257 let p_query_time_interval = time_interval;
258 let p_query_attributes = attributes;
259 let p_query_result_type = result_type;
260
261 let uri_str = format!("{}/workflow/{id}/rasterStream", configuration.base_path, id=crate::apis::urlencode(p_path_id));
262 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
263
264 req_builder = req_builder.query(&[("spatialBounds", &p_query_spatial_bounds.to_string())]);
265 req_builder = req_builder.query(&[("timeInterval", &p_query_time_interval.to_string())]);
266 req_builder = req_builder.query(&[("attributes", &p_query_attributes.to_string())]);
267 req_builder = req_builder.query(&[("resultType", &p_query_result_type.to_string())]);
268 if let Some(ref user_agent) = configuration.user_agent {
269 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
270 }
271 if let Some(ref token) = configuration.bearer_access_token {
272 req_builder = req_builder.bearer_auth(token.to_owned());
273 };
274
275 let req = req_builder.build()?;
276 let resp = configuration.client.execute(req).await?;
277
278 let status = resp.status();
279
280 if !status.is_client_error() && !status.is_server_error() {
281 Ok(())
282 } else {
283 let content = resp.text().await?;
284 let entity: Option<RasterStreamWebsocketError> = serde_json::from_str(&content).ok();
285 Err(Error::ResponseError(ResponseContent { status, content, entity }))
286 }
287}
288
289pub async fn register_workflow_handler(configuration: &configuration::Configuration, workflow: models::Workflow) -> Result<models::IdResponse, Error<RegisterWorkflowHandlerError>> {
290 let p_body_workflow = workflow;
292
293 let uri_str = format!("{}/workflow", configuration.base_path);
294 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
295
296 if let Some(ref user_agent) = configuration.user_agent {
297 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
298 }
299 if let Some(ref token) = configuration.bearer_access_token {
300 req_builder = req_builder.bearer_auth(token.to_owned());
301 };
302 req_builder = req_builder.json(&p_body_workflow);
303
304 let req = req_builder.build()?;
305 let resp = configuration.client.execute(req).await?;
306
307 let status = resp.status();
308 let content_type = resp
309 .headers()
310 .get("content-type")
311 .and_then(|v| v.to_str().ok())
312 .unwrap_or("application/octet-stream");
313 let content_type = super::ContentType::from(content_type);
314
315 if !status.is_client_error() && !status.is_server_error() {
316 let content = resp.text().await?;
317 match content_type {
318 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
319 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IdResponse`"))),
320 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IdResponse`")))),
321 }
322 } else {
323 let content = resp.text().await?;
324 let entity: Option<RegisterWorkflowHandlerError> = serde_json::from_str(&content).ok();
325 Err(Error::ResponseError(ResponseContent { status, content, entity }))
326 }
327}
328