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