artcoded_api/apis/
rdf_utils_rest_controller_api.rs

1/*
2 * Artcoded
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 1.0.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16/// struct for typed errors of method [`file_to_lang`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum FileToLangError {
20    UnknownValue(serde_json::Value),
21}
22
23/// struct for typed errors of method [`file_to_lang1`]
24#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum FileToLang1Error {
27    UnknownValue(serde_json::Value),
28}
29
30/// struct for typed errors of method [`get_allowed_extensions`]
31#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum GetAllowedExtensionsError {
34    UnknownValue(serde_json::Value),
35}
36
37/// struct for typed errors of method [`get_allowed_languages`]
38#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum GetAllowedLanguagesError {
41    UnknownValue(serde_json::Value),
42}
43
44/// struct for typed errors of method [`model_conversion1`]
45#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum ModelConversion1Error {
48    UnknownValue(serde_json::Value),
49}
50
51pub async fn file_to_lang(
52    configuration: &configuration::Configuration,
53    model_file: std::path::PathBuf,
54    shacl_file: std::path::PathBuf,
55) -> Result<String, Error<FileToLangError>> {
56    // add a prefix to parameters to efficiently prevent name collisions
57    let p_form_model_file = model_file;
58    let p_form_shacl_file = shacl_file;
59
60    let uri_str = format!(
61        "{}/api/toolbox/public/rdf/shacl-validation",
62        configuration.base_path
63    );
64    let mut req_builder = configuration
65        .client
66        .request(reqwest::Method::POST, &uri_str);
67
68    if let Some(ref user_agent) = configuration.user_agent {
69        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
70    }
71    if let Some(ref token) = configuration.bearer_access_token {
72        req_builder = req_builder.bearer_auth(token.to_owned());
73    };
74    let multipart_form = reqwest::multipart::Form::new();
75    // TODO: support file upload for 'modelFile' parameter
76    // TODO: support file upload for 'shaclFile' parameter
77    req_builder = req_builder.multipart(multipart_form);
78
79    let req = req_builder.build()?;
80    let resp = configuration.client.execute(req).await?;
81
82    let status = resp.status();
83    let content_type = resp
84        .headers()
85        .get("content-type")
86        .and_then(|v| v.to_str().ok())
87        .unwrap_or("application/octet-stream");
88    let content_type = super::ContentType::from(content_type);
89
90    if !status.is_client_error() && !status.is_server_error() {
91        let content = resp.text().await?;
92        match content_type {
93            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
94            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `String`"))),
95            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
96        }
97    } else {
98        let content = resp.text().await?;
99        let entity: Option<FileToLangError> = serde_json::from_str(&content).ok();
100        Err(Error::ResponseError(ResponseContent {
101            status,
102            content,
103            entity,
104        }))
105    }
106}
107
108pub async fn file_to_lang1(
109    configuration: &configuration::Configuration,
110    lang: &str,
111    file: std::path::PathBuf,
112) -> Result<reqwest::Response, Error<FileToLang1Error>> {
113    // add a prefix to parameters to efficiently prevent name collisions
114    let p_query_lang = lang;
115    let p_form_file = file;
116
117    let uri_str = format!(
118        "{}/api/toolbox/public/rdf/file-to-lang",
119        configuration.base_path
120    );
121    let mut req_builder = configuration
122        .client
123        .request(reqwest::Method::POST, &uri_str);
124
125    req_builder = req_builder.query(&[("lang", &p_query_lang.to_string())]);
126    if let Some(ref user_agent) = configuration.user_agent {
127        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
128    }
129    if let Some(ref token) = configuration.bearer_access_token {
130        req_builder = req_builder.bearer_auth(token.to_owned());
131    };
132    let multipart_form = reqwest::multipart::Form::new();
133    // TODO: support file upload for 'file' parameter
134    req_builder = req_builder.multipart(multipart_form);
135
136    let req = req_builder.build()?;
137    let resp = configuration.client.execute(req).await?;
138
139    let status = resp.status();
140
141    if !status.is_client_error() && !status.is_server_error() {
142        Ok(resp)
143    } else {
144        let content = resp.text().await?;
145        let entity: Option<FileToLang1Error> = serde_json::from_str(&content).ok();
146        Err(Error::ResponseError(ResponseContent {
147            status,
148            content,
149            entity,
150        }))
151    }
152}
153
154pub async fn get_allowed_extensions(
155    configuration: &configuration::Configuration,
156) -> Result<Vec<String>, Error<GetAllowedExtensionsError>> {
157    let uri_str = format!(
158        "{}/api/toolbox/public/rdf/allowed-extensions",
159        configuration.base_path
160    );
161    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
162
163    if let Some(ref user_agent) = configuration.user_agent {
164        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
165    }
166    if let Some(ref token) = configuration.bearer_access_token {
167        req_builder = req_builder.bearer_auth(token.to_owned());
168    };
169
170    let req = req_builder.build()?;
171    let resp = configuration.client.execute(req).await?;
172
173    let status = resp.status();
174    let content_type = resp
175        .headers()
176        .get("content-type")
177        .and_then(|v| v.to_str().ok())
178        .unwrap_or("application/octet-stream");
179    let content_type = super::ContentType::from(content_type);
180
181    if !status.is_client_error() && !status.is_server_error() {
182        let content = resp.text().await?;
183        match content_type {
184            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
185            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;String&gt;`"))),
186            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;String&gt;`")))),
187        }
188    } else {
189        let content = resp.text().await?;
190        let entity: Option<GetAllowedExtensionsError> = serde_json::from_str(&content).ok();
191        Err(Error::ResponseError(ResponseContent {
192            status,
193            content,
194            entity,
195        }))
196    }
197}
198
199pub async fn get_allowed_languages(
200    configuration: &configuration::Configuration,
201) -> Result<Vec<String>, Error<GetAllowedLanguagesError>> {
202    let uri_str = format!(
203        "{}/api/toolbox/public/rdf/allowed-languages",
204        configuration.base_path
205    );
206    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
207
208    if let Some(ref user_agent) = configuration.user_agent {
209        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
210    }
211    if let Some(ref token) = configuration.bearer_access_token {
212        req_builder = req_builder.bearer_auth(token.to_owned());
213    };
214
215    let req = req_builder.build()?;
216    let resp = configuration.client.execute(req).await?;
217
218    let status = resp.status();
219    let content_type = resp
220        .headers()
221        .get("content-type")
222        .and_then(|v| v.to_str().ok())
223        .unwrap_or("application/octet-stream");
224    let content_type = super::ContentType::from(content_type);
225
226    if !status.is_client_error() && !status.is_server_error() {
227        let content = resp.text().await?;
228        match content_type {
229            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
230            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;String&gt;`"))),
231            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;String&gt;`")))),
232        }
233    } else {
234        let content = resp.text().await?;
235        let entity: Option<GetAllowedLanguagesError> = serde_json::from_str(&content).ok();
236        Err(Error::ResponseError(ResponseContent {
237            status,
238            content,
239            entity,
240        }))
241    }
242}
243
244pub async fn model_conversion1(
245    configuration: &configuration::Configuration,
246    model: &str,
247    lang_of_model: &str,
248    lang: &str,
249) -> Result<String, Error<ModelConversion1Error>> {
250    // add a prefix to parameters to efficiently prevent name collisions
251    let p_query_model = model;
252    let p_query_lang_of_model = lang_of_model;
253    let p_query_lang = lang;
254
255    let uri_str = format!(
256        "{}/api/toolbox/public/rdf/model-to-lang",
257        configuration.base_path
258    );
259    let mut req_builder = configuration
260        .client
261        .request(reqwest::Method::POST, &uri_str);
262
263    req_builder = req_builder.query(&[("model", &p_query_model.to_string())]);
264    req_builder = req_builder.query(&[("langOfModel", &p_query_lang_of_model.to_string())]);
265    req_builder = req_builder.query(&[("lang", &p_query_lang.to_string())]);
266    if let Some(ref user_agent) = configuration.user_agent {
267        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
268    }
269    if let Some(ref token) = configuration.bearer_access_token {
270        req_builder = req_builder.bearer_auth(token.to_owned());
271    };
272
273    let req = req_builder.build()?;
274    let resp = configuration.client.execute(req).await?;
275
276    let status = resp.status();
277    let content_type = resp
278        .headers()
279        .get("content-type")
280        .and_then(|v| v.to_str().ok())
281        .unwrap_or("application/octet-stream");
282    let content_type = super::ContentType::from(content_type);
283
284    if !status.is_client_error() && !status.is_server_error() {
285        let content = resp.text().await?;
286        match content_type {
287            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
288            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `String`"))),
289            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
290        }
291    } else {
292        let content = resp.text().await?;
293        let entity: Option<ModelConversion1Error> = serde_json::from_str(&content).ok();
294        Err(Error::ResponseError(ResponseContent {
295            status,
296            content,
297            entity,
298        }))
299    }
300}