worterbuch_openapi/apis/
default_api.rs

1/*
2 * Worterbuch
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 0.34.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`delete_key_delete`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum DeleteKeyDeleteError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`get_key_get`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetKeyGetError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`ls_get`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum LsGetError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`ls_key_get`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum LsKeyGetError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`pdelete_pattern_delete`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum PdeletePatternDeleteError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`pget_pattern_get`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum PgetPatternGetError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`publish_key_post`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum PublishKeyPostError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`set_key_post`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum SetKeyPostError {
71    UnknownValue(serde_json::Value),
72}
73
74
75pub async fn delete_key_delete(configuration: &configuration::Configuration, key: &str) -> Result<crate::models::KeyValuePair, Error<DeleteKeyDeleteError>> {
76    let local_var_configuration = configuration;
77
78    let local_var_client = &local_var_configuration.client;
79
80    let local_var_uri_str = format!("{}/delete/{key}", local_var_configuration.base_path, key=crate::apis::urlencode(key));
81    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
82
83    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
84        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
85    }
86
87    let local_var_req = local_var_req_builder.build()?;
88    let local_var_resp = local_var_client.execute(local_var_req).await?;
89
90    let local_var_status = local_var_resp.status();
91    let local_var_content = local_var_resp.text().await?;
92
93    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
94        serde_json::from_str(&local_var_content).map_err(Error::from)
95    } else {
96        let local_var_entity: Option<DeleteKeyDeleteError> = serde_json::from_str(&local_var_content).ok();
97        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
98        Err(Error::ResponseError(local_var_error))
99    }
100}
101
102pub async fn get_key_get(configuration: &configuration::Configuration, key: &str) -> Result<crate::models::KeyValuePair, Error<GetKeyGetError>> {
103    let local_var_configuration = configuration;
104
105    let local_var_client = &local_var_configuration.client;
106
107    let local_var_uri_str = format!("{}/get/{key}", local_var_configuration.base_path, key=crate::apis::urlencode(key));
108    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
109
110    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
111        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
112    }
113
114    let local_var_req = local_var_req_builder.build()?;
115    let local_var_resp = local_var_client.execute(local_var_req).await?;
116
117    let local_var_status = local_var_resp.status();
118    let local_var_content = local_var_resp.text().await?;
119
120    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
121        serde_json::from_str(&local_var_content).map_err(Error::from)
122    } else {
123        let local_var_entity: Option<GetKeyGetError> = serde_json::from_str(&local_var_content).ok();
124        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
125        Err(Error::ResponseError(local_var_error))
126    }
127}
128
129pub async fn ls_get(configuration: &configuration::Configuration, ) -> Result<Vec<String>, Error<LsGetError>> {
130    let local_var_configuration = configuration;
131
132    let local_var_client = &local_var_configuration.client;
133
134    let local_var_uri_str = format!("{}/ls", local_var_configuration.base_path);
135    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
136
137    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
138        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
139    }
140
141    let local_var_req = local_var_req_builder.build()?;
142    let local_var_resp = local_var_client.execute(local_var_req).await?;
143
144    let local_var_status = local_var_resp.status();
145    let local_var_content = local_var_resp.text().await?;
146
147    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
148        serde_json::from_str(&local_var_content).map_err(Error::from)
149    } else {
150        let local_var_entity: Option<LsGetError> = serde_json::from_str(&local_var_content).ok();
151        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
152        Err(Error::ResponseError(local_var_error))
153    }
154}
155
156pub async fn ls_key_get(configuration: &configuration::Configuration, key: &str) -> Result<Vec<String>, Error<LsKeyGetError>> {
157    let local_var_configuration = configuration;
158
159    let local_var_client = &local_var_configuration.client;
160
161    let local_var_uri_str = format!("{}/ls/{key}", local_var_configuration.base_path, key=crate::apis::urlencode(key));
162    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
163
164    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
165        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
166    }
167
168    let local_var_req = local_var_req_builder.build()?;
169    let local_var_resp = local_var_client.execute(local_var_req).await?;
170
171    let local_var_status = local_var_resp.status();
172    let local_var_content = local_var_resp.text().await?;
173
174    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
175        serde_json::from_str(&local_var_content).map_err(Error::from)
176    } else {
177        let local_var_entity: Option<LsKeyGetError> = serde_json::from_str(&local_var_content).ok();
178        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
179        Err(Error::ResponseError(local_var_error))
180    }
181}
182
183pub async fn pdelete_pattern_delete(configuration: &configuration::Configuration, pattern: &str) -> Result<Vec<crate::models::KeyValuePair>, Error<PdeletePatternDeleteError>> {
184    let local_var_configuration = configuration;
185
186    let local_var_client = &local_var_configuration.client;
187
188    let local_var_uri_str = format!("{}/pdelete/{pattern}", local_var_configuration.base_path, pattern=crate::apis::urlencode(pattern));
189    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
190
191    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
192        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
193    }
194
195    let local_var_req = local_var_req_builder.build()?;
196    let local_var_resp = local_var_client.execute(local_var_req).await?;
197
198    let local_var_status = local_var_resp.status();
199    let local_var_content = local_var_resp.text().await?;
200
201    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
202        serde_json::from_str(&local_var_content).map_err(Error::from)
203    } else {
204        let local_var_entity: Option<PdeletePatternDeleteError> = serde_json::from_str(&local_var_content).ok();
205        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
206        Err(Error::ResponseError(local_var_error))
207    }
208}
209
210pub async fn pget_pattern_get(configuration: &configuration::Configuration, pattern: &str) -> Result<Vec<crate::models::KeyValuePair>, Error<PgetPatternGetError>> {
211    let local_var_configuration = configuration;
212
213    let local_var_client = &local_var_configuration.client;
214
215    let local_var_uri_str = format!("{}/pget/{pattern}", local_var_configuration.base_path, pattern=crate::apis::urlencode(pattern));
216    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
217
218    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
219        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
220    }
221
222    let local_var_req = local_var_req_builder.build()?;
223    let local_var_resp = local_var_client.execute(local_var_req).await?;
224
225    let local_var_status = local_var_resp.status();
226    let local_var_content = local_var_resp.text().await?;
227
228    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
229        serde_json::from_str(&local_var_content).map_err(Error::from)
230    } else {
231        let local_var_entity: Option<PgetPatternGetError> = serde_json::from_str(&local_var_content).ok();
232        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
233        Err(Error::ResponseError(local_var_error))
234    }
235}
236
237pub async fn publish_key_post(configuration: &configuration::Configuration, key: &str, body: Option<serde_json::Value>) -> Result<String, Error<PublishKeyPostError>> {
238    let local_var_configuration = configuration;
239
240    let local_var_client = &local_var_configuration.client;
241
242    let local_var_uri_str = format!("{}/publish/{key}", local_var_configuration.base_path, key=crate::apis::urlencode(key));
243    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
244
245    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
246        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
247    }
248    local_var_req_builder = local_var_req_builder.json(&body);
249
250    let local_var_req = local_var_req_builder.build()?;
251    let local_var_resp = local_var_client.execute(local_var_req).await?;
252
253    let local_var_status = local_var_resp.status();
254    let local_var_content = local_var_resp.text().await?;
255
256    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
257        serde_json::from_str(&local_var_content).map_err(Error::from)
258    } else {
259        let local_var_entity: Option<PublishKeyPostError> = serde_json::from_str(&local_var_content).ok();
260        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
261        Err(Error::ResponseError(local_var_error))
262    }
263}
264
265pub async fn set_key_post(configuration: &configuration::Configuration, key: &str, body: Option<serde_json::Value>) -> Result<String, Error<SetKeyPostError>> {
266    let local_var_configuration = configuration;
267
268    let local_var_client = &local_var_configuration.client;
269
270    let local_var_uri_str = format!("{}/set/{key}", local_var_configuration.base_path, key=crate::apis::urlencode(key));
271    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
272
273    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
274        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
275    }
276    local_var_req_builder = local_var_req_builder.json(&body);
277
278    let local_var_req = local_var_req_builder.build()?;
279    let local_var_resp = local_var_client.execute(local_var_req).await?;
280
281    let local_var_status = local_var_resp.status();
282    let local_var_content = local_var_resp.text().await?;
283
284    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
285        serde_json::from_str(&local_var_content).map_err(Error::from)
286    } else {
287        let local_var_entity: Option<SetKeyPostError> = serde_json::from_str(&local_var_content).ok();
288        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
289        Err(Error::ResponseError(local_var_error))
290    }
291}
292