hab_rs_api_client/apis/
persistence_api.rs

1/*
2 * openHAB REST API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 8
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{Error, configuration};
12use crate::apis::ContentType;
13use crate::{apis::ResponseContent, models};
14use async_trait::async_trait;
15#[cfg(feature = "mockall")]
16use mockall::automock;
17use reqwest;
18use serde::{Deserialize, Serialize, de::Error as _};
19use std::sync::Arc;
20
21#[cfg_attr(feature = "mockall", automock)]
22#[async_trait]
23pub trait PersistenceApi: Send + Sync {
24    /// DELETE /persistence/items/{itemname}
25    ///
26    ///
27    async fn delete_item_from_persistence_service<'service_id, 'itemname, 'starttime, 'endtime>(
28        &self,
29        service_id: &'service_id str,
30        itemname: &'itemname str,
31        starttime: &'starttime str,
32        endtime: &'endtime str,
33    ) -> Result<Vec<String>, Error<DeleteItemFromPersistenceServiceError>>;
34
35    /// DELETE /persistence/{serviceId}
36    ///
37    ///
38    async fn delete_persistence_service_configuration<'service_id>(
39        &self,
40        service_id: &'service_id str,
41    ) -> Result<(), Error<DeletePersistenceServiceConfigurationError>>;
42
43    /// GET /persistence/items/{itemname}
44    ///
45    ///
46    async fn get_item_data_from_persistence_service<
47        'itemname,
48        'service_id,
49        'starttime,
50        'endtime,
51        'page,
52        'pagelength,
53        'boundary,
54        'item_state,
55    >(
56        &self,
57        itemname: &'itemname str,
58        service_id: Option<&'service_id str>,
59        starttime: Option<&'starttime str>,
60        endtime: Option<&'endtime str>,
61        page: Option<i32>,
62        pagelength: Option<i32>,
63        boundary: Option<bool>,
64        item_state: Option<bool>,
65    ) -> Result<models::ItemHistoryDto, Error<GetItemDataFromPersistenceServiceError>>;
66
67    /// GET /persistence/items
68    ///
69    ///
70    async fn get_items_for_persistence_service<'service_id>(
71        &self,
72        service_id: Option<&'service_id str>,
73    ) -> Result<Vec<models::PersistenceItemInfo>, Error<GetItemsForPersistenceServiceError>>;
74
75    /// GET /persistence/{serviceId}
76    ///
77    ///
78    async fn get_persistence_service_configuration<'service_id>(
79        &self,
80        service_id: &'service_id str,
81    ) -> Result<
82        models::PersistenceServiceConfigurationDto,
83        Error<GetPersistenceServiceConfigurationError>,
84    >;
85
86    /// GET /persistence
87    ///
88    ///
89    async fn get_persistence_services<'accept_language>(
90        &self,
91        accept_language: Option<&'accept_language str>,
92    ) -> Result<Vec<models::PersistenceServiceDto>, Error<GetPersistenceServicesError>>;
93
94    /// PUT /persistence/{serviceId}
95    ///
96    ///
97    async fn put_persistence_service_configuration<
98        'service_id,
99        'persistence_service_configuration_dto,
100    >(
101        &self,
102        service_id: &'service_id str,
103        persistence_service_configuration_dto: models::PersistenceServiceConfigurationDto,
104    ) -> Result<
105        models::PersistenceServiceConfigurationDto,
106        Error<PutPersistenceServiceConfigurationError>,
107    >;
108
109    /// PUT /persistence/items/{itemname}
110    ///
111    ///
112    async fn store_item_data_in_persistence_service<'itemname, 'time, 'state, 'service_id>(
113        &self,
114        itemname: &'itemname str,
115        time: &'time str,
116        state: &'state str,
117        service_id: Option<&'service_id str>,
118    ) -> Result<(), Error<StoreItemDataInPersistenceServiceError>>;
119}
120
121pub struct PersistenceApiClient {
122    configuration: Arc<configuration::Configuration>,
123}
124
125impl PersistenceApiClient {
126    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
127        Self { configuration }
128    }
129}
130
131#[async_trait]
132impl PersistenceApi for PersistenceApiClient {
133    async fn delete_item_from_persistence_service<'service_id, 'itemname, 'starttime, 'endtime>(
134        &self,
135        service_id: &'service_id str,
136        itemname: &'itemname str,
137        starttime: &'starttime str,
138        endtime: &'endtime str,
139    ) -> Result<Vec<String>, Error<DeleteItemFromPersistenceServiceError>> {
140        let local_var_configuration = &self.configuration;
141
142        let local_var_client = &local_var_configuration.client;
143
144        let local_var_uri_str = format!(
145            "{}/persistence/items/{itemname}",
146            local_var_configuration.base_path,
147            itemname = crate::apis::urlencode(itemname)
148        );
149        let mut local_var_req_builder =
150            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
151
152        local_var_req_builder =
153            local_var_req_builder.query(&[("serviceId", &service_id.to_string())]);
154        local_var_req_builder =
155            local_var_req_builder.query(&[("starttime", &starttime.to_string())]);
156        local_var_req_builder = local_var_req_builder.query(&[("endtime", &endtime.to_string())]);
157        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
158            local_var_req_builder = local_var_req_builder
159                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
160        }
161        if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
162            local_var_req_builder = local_var_req_builder.basic_auth(
163                local_var_auth_conf.0.to_owned(),
164                local_var_auth_conf.1.to_owned(),
165            );
166        };
167        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
168            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
169        };
170
171        let local_var_req = local_var_req_builder.build()?;
172        let local_var_resp = local_var_client.execute(local_var_req).await?;
173
174        let local_var_status = local_var_resp.status();
175        let local_var_content_type = local_var_resp
176            .headers()
177            .get("content-type")
178            .and_then(|v| v.to_str().ok())
179            .unwrap_or("application/octet-stream");
180        let local_var_content_type = super::ContentType::from(local_var_content_type);
181        let local_var_content = local_var_resp.text().await?;
182
183        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
184            match local_var_content_type {
185                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
186                ContentType::Text => {
187                    return Err(Error::from(serde_json::Error::custom(
188                        "Received `text/plain` content type response that cannot be converted to `Vec&lt;String&gt;`",
189                    )));
190                }
191                ContentType::Unsupported(local_var_unknown_type) => {
192                    return Err(Error::from(serde_json::Error::custom(format!(
193                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec&lt;String&gt;`"
194                    ))));
195                }
196            }
197        } else {
198            let local_var_entity: Option<DeleteItemFromPersistenceServiceError> =
199                serde_json::from_str(&local_var_content).ok();
200            let local_var_error = ResponseContent {
201                status: local_var_status,
202                content: local_var_content,
203                entity: local_var_entity,
204            };
205            Err(Error::ResponseError(local_var_error))
206        }
207    }
208
209    async fn delete_persistence_service_configuration<'service_id>(
210        &self,
211        service_id: &'service_id str,
212    ) -> Result<(), Error<DeletePersistenceServiceConfigurationError>> {
213        let local_var_configuration = &self.configuration;
214
215        let local_var_client = &local_var_configuration.client;
216
217        let local_var_uri_str = format!(
218            "{}/persistence/{serviceId}",
219            local_var_configuration.base_path,
220            serviceId = crate::apis::urlencode(service_id)
221        );
222        let mut local_var_req_builder =
223            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
224
225        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
226            local_var_req_builder = local_var_req_builder
227                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
228        }
229        if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
230            local_var_req_builder = local_var_req_builder.basic_auth(
231                local_var_auth_conf.0.to_owned(),
232                local_var_auth_conf.1.to_owned(),
233            );
234        };
235        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
236            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
237        };
238
239        let local_var_req = local_var_req_builder.build()?;
240        let local_var_resp = local_var_client.execute(local_var_req).await?;
241
242        let local_var_status = local_var_resp.status();
243        let local_var_content = local_var_resp.text().await?;
244
245        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
246            Ok(())
247        } else {
248            let local_var_entity: Option<DeletePersistenceServiceConfigurationError> =
249                serde_json::from_str(&local_var_content).ok();
250            let local_var_error = ResponseContent {
251                status: local_var_status,
252                content: local_var_content,
253                entity: local_var_entity,
254            };
255            Err(Error::ResponseError(local_var_error))
256        }
257    }
258
259    async fn get_item_data_from_persistence_service<
260        'itemname,
261        'service_id,
262        'starttime,
263        'endtime,
264        'page,
265        'pagelength,
266        'boundary,
267        'item_state,
268    >(
269        &self,
270        itemname: &'itemname str,
271        service_id: Option<&'service_id str>,
272        starttime: Option<&'starttime str>,
273        endtime: Option<&'endtime str>,
274        page: Option<i32>,
275        pagelength: Option<i32>,
276        boundary: Option<bool>,
277        item_state: Option<bool>,
278    ) -> Result<models::ItemHistoryDto, Error<GetItemDataFromPersistenceServiceError>> {
279        let local_var_configuration = &self.configuration;
280
281        let local_var_client = &local_var_configuration.client;
282
283        let local_var_uri_str = format!(
284            "{}/persistence/items/{itemname}",
285            local_var_configuration.base_path,
286            itemname = crate::apis::urlencode(itemname)
287        );
288        let mut local_var_req_builder =
289            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
290
291        if let Some(ref local_var_str) = service_id {
292            local_var_req_builder =
293                local_var_req_builder.query(&[("serviceId", &local_var_str.to_string())]);
294        }
295        if let Some(ref local_var_str) = starttime {
296            local_var_req_builder =
297                local_var_req_builder.query(&[("starttime", &local_var_str.to_string())]);
298        }
299        if let Some(ref local_var_str) = endtime {
300            local_var_req_builder =
301                local_var_req_builder.query(&[("endtime", &local_var_str.to_string())]);
302        }
303        if let Some(ref local_var_str) = page {
304            local_var_req_builder =
305                local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
306        }
307        if let Some(ref local_var_str) = pagelength {
308            local_var_req_builder =
309                local_var_req_builder.query(&[("pagelength", &local_var_str.to_string())]);
310        }
311        if let Some(ref local_var_str) = boundary {
312            local_var_req_builder =
313                local_var_req_builder.query(&[("boundary", &local_var_str.to_string())]);
314        }
315        if let Some(ref local_var_str) = item_state {
316            local_var_req_builder =
317                local_var_req_builder.query(&[("itemState", &local_var_str.to_string())]);
318        }
319        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
320            local_var_req_builder = local_var_req_builder
321                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
322        }
323
324        let local_var_req = local_var_req_builder.build()?;
325        let local_var_resp = local_var_client.execute(local_var_req).await?;
326
327        let local_var_status = local_var_resp.status();
328        let local_var_content_type = local_var_resp
329            .headers()
330            .get("content-type")
331            .and_then(|v| v.to_str().ok())
332            .unwrap_or("application/octet-stream");
333        let local_var_content_type = super::ContentType::from(local_var_content_type);
334        let local_var_content = local_var_resp.text().await?;
335
336        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
337            match local_var_content_type {
338                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
339                ContentType::Text => {
340                    return Err(Error::from(serde_json::Error::custom(
341                        "Received `text/plain` content type response that cannot be converted to `models::ItemHistoryDto`",
342                    )));
343                }
344                ContentType::Unsupported(local_var_unknown_type) => {
345                    return Err(Error::from(serde_json::Error::custom(format!(
346                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ItemHistoryDto`"
347                    ))));
348                }
349            }
350        } else {
351            let local_var_entity: Option<GetItemDataFromPersistenceServiceError> =
352                serde_json::from_str(&local_var_content).ok();
353            let local_var_error = ResponseContent {
354                status: local_var_status,
355                content: local_var_content,
356                entity: local_var_entity,
357            };
358            Err(Error::ResponseError(local_var_error))
359        }
360    }
361
362    async fn get_items_for_persistence_service<'service_id>(
363        &self,
364        service_id: Option<&'service_id str>,
365    ) -> Result<Vec<models::PersistenceItemInfo>, Error<GetItemsForPersistenceServiceError>> {
366        let local_var_configuration = &self.configuration;
367
368        let local_var_client = &local_var_configuration.client;
369
370        let local_var_uri_str = format!("{}/persistence/items", local_var_configuration.base_path);
371        let mut local_var_req_builder =
372            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
373
374        if let Some(ref local_var_str) = service_id {
375            local_var_req_builder =
376                local_var_req_builder.query(&[("serviceId", &local_var_str.to_string())]);
377        }
378        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
379            local_var_req_builder = local_var_req_builder
380                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
381        }
382        if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
383            local_var_req_builder = local_var_req_builder.basic_auth(
384                local_var_auth_conf.0.to_owned(),
385                local_var_auth_conf.1.to_owned(),
386            );
387        };
388        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
389            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
390        };
391
392        let local_var_req = local_var_req_builder.build()?;
393        let local_var_resp = local_var_client.execute(local_var_req).await?;
394
395        let local_var_status = local_var_resp.status();
396        let local_var_content_type = local_var_resp
397            .headers()
398            .get("content-type")
399            .and_then(|v| v.to_str().ok())
400            .unwrap_or("application/octet-stream");
401        let local_var_content_type = super::ContentType::from(local_var_content_type);
402        let local_var_content = local_var_resp.text().await?;
403
404        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
405            match local_var_content_type {
406                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
407                ContentType::Text => {
408                    return Err(Error::from(serde_json::Error::custom(
409                        "Received `text/plain` content type response that cannot be converted to `Vec&lt;models::PersistenceItemInfo&gt;`",
410                    )));
411                }
412                ContentType::Unsupported(local_var_unknown_type) => {
413                    return Err(Error::from(serde_json::Error::custom(format!(
414                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec&lt;models::PersistenceItemInfo&gt;`"
415                    ))));
416                }
417            }
418        } else {
419            let local_var_entity: Option<GetItemsForPersistenceServiceError> =
420                serde_json::from_str(&local_var_content).ok();
421            let local_var_error = ResponseContent {
422                status: local_var_status,
423                content: local_var_content,
424                entity: local_var_entity,
425            };
426            Err(Error::ResponseError(local_var_error))
427        }
428    }
429
430    async fn get_persistence_service_configuration<'service_id>(
431        &self,
432        service_id: &'service_id str,
433    ) -> Result<
434        models::PersistenceServiceConfigurationDto,
435        Error<GetPersistenceServiceConfigurationError>,
436    > {
437        let local_var_configuration = &self.configuration;
438
439        let local_var_client = &local_var_configuration.client;
440
441        let local_var_uri_str = format!(
442            "{}/persistence/{serviceId}",
443            local_var_configuration.base_path,
444            serviceId = crate::apis::urlencode(service_id)
445        );
446        let mut local_var_req_builder =
447            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
448
449        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
450            local_var_req_builder = local_var_req_builder
451                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
452        }
453        if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
454            local_var_req_builder = local_var_req_builder.basic_auth(
455                local_var_auth_conf.0.to_owned(),
456                local_var_auth_conf.1.to_owned(),
457            );
458        };
459        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
460            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
461        };
462
463        let local_var_req = local_var_req_builder.build()?;
464        let local_var_resp = local_var_client.execute(local_var_req).await?;
465
466        let local_var_status = local_var_resp.status();
467        let local_var_content_type = local_var_resp
468            .headers()
469            .get("content-type")
470            .and_then(|v| v.to_str().ok())
471            .unwrap_or("application/octet-stream");
472        let local_var_content_type = super::ContentType::from(local_var_content_type);
473        let local_var_content = local_var_resp.text().await?;
474
475        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
476            match local_var_content_type {
477                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
478                ContentType::Text => {
479                    return Err(Error::from(serde_json::Error::custom(
480                        "Received `text/plain` content type response that cannot be converted to `models::PersistenceServiceConfigurationDto`",
481                    )));
482                }
483                ContentType::Unsupported(local_var_unknown_type) => {
484                    return Err(Error::from(serde_json::Error::custom(format!(
485                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PersistenceServiceConfigurationDto`"
486                    ))));
487                }
488            }
489        } else {
490            let local_var_entity: Option<GetPersistenceServiceConfigurationError> =
491                serde_json::from_str(&local_var_content).ok();
492            let local_var_error = ResponseContent {
493                status: local_var_status,
494                content: local_var_content,
495                entity: local_var_entity,
496            };
497            Err(Error::ResponseError(local_var_error))
498        }
499    }
500
501    async fn get_persistence_services<'accept_language>(
502        &self,
503        accept_language: Option<&'accept_language str>,
504    ) -> Result<Vec<models::PersistenceServiceDto>, Error<GetPersistenceServicesError>> {
505        let local_var_configuration = &self.configuration;
506
507        let local_var_client = &local_var_configuration.client;
508
509        let local_var_uri_str = format!("{}/persistence", local_var_configuration.base_path);
510        let mut local_var_req_builder =
511            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
512
513        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
514            local_var_req_builder = local_var_req_builder
515                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
516        }
517        if let Some(local_var_param_value) = accept_language {
518            local_var_req_builder =
519                local_var_req_builder.header("Accept-Language", local_var_param_value.to_string());
520        }
521        if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
522            local_var_req_builder = local_var_req_builder.basic_auth(
523                local_var_auth_conf.0.to_owned(),
524                local_var_auth_conf.1.to_owned(),
525            );
526        };
527        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
528            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
529        };
530
531        let local_var_req = local_var_req_builder.build()?;
532        let local_var_resp = local_var_client.execute(local_var_req).await?;
533
534        let local_var_status = local_var_resp.status();
535        let local_var_content_type = local_var_resp
536            .headers()
537            .get("content-type")
538            .and_then(|v| v.to_str().ok())
539            .unwrap_or("application/octet-stream");
540        let local_var_content_type = super::ContentType::from(local_var_content_type);
541        let local_var_content = local_var_resp.text().await?;
542
543        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
544            match local_var_content_type {
545                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
546                ContentType::Text => {
547                    return Err(Error::from(serde_json::Error::custom(
548                        "Received `text/plain` content type response that cannot be converted to `Vec&lt;models::PersistenceServiceDto&gt;`",
549                    )));
550                }
551                ContentType::Unsupported(local_var_unknown_type) => {
552                    return Err(Error::from(serde_json::Error::custom(format!(
553                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec&lt;models::PersistenceServiceDto&gt;`"
554                    ))));
555                }
556            }
557        } else {
558            let local_var_entity: Option<GetPersistenceServicesError> =
559                serde_json::from_str(&local_var_content).ok();
560            let local_var_error = ResponseContent {
561                status: local_var_status,
562                content: local_var_content,
563                entity: local_var_entity,
564            };
565            Err(Error::ResponseError(local_var_error))
566        }
567    }
568
569    async fn put_persistence_service_configuration<
570        'service_id,
571        'persistence_service_configuration_dto,
572    >(
573        &self,
574        service_id: &'service_id str,
575        persistence_service_configuration_dto: models::PersistenceServiceConfigurationDto,
576    ) -> Result<
577        models::PersistenceServiceConfigurationDto,
578        Error<PutPersistenceServiceConfigurationError>,
579    > {
580        let local_var_configuration = &self.configuration;
581
582        let local_var_client = &local_var_configuration.client;
583
584        let local_var_uri_str = format!(
585            "{}/persistence/{serviceId}",
586            local_var_configuration.base_path,
587            serviceId = crate::apis::urlencode(service_id)
588        );
589        let mut local_var_req_builder =
590            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
591
592        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
593            local_var_req_builder = local_var_req_builder
594                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
595        }
596        if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
597            local_var_req_builder = local_var_req_builder.basic_auth(
598                local_var_auth_conf.0.to_owned(),
599                local_var_auth_conf.1.to_owned(),
600            );
601        };
602        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
603            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
604        };
605        local_var_req_builder = local_var_req_builder.json(&persistence_service_configuration_dto);
606
607        let local_var_req = local_var_req_builder.build()?;
608        let local_var_resp = local_var_client.execute(local_var_req).await?;
609
610        let local_var_status = local_var_resp.status();
611        let local_var_content_type = local_var_resp
612            .headers()
613            .get("content-type")
614            .and_then(|v| v.to_str().ok())
615            .unwrap_or("application/octet-stream");
616        let local_var_content_type = super::ContentType::from(local_var_content_type);
617        let local_var_content = local_var_resp.text().await?;
618
619        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
620            match local_var_content_type {
621                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
622                ContentType::Text => {
623                    return Err(Error::from(serde_json::Error::custom(
624                        "Received `text/plain` content type response that cannot be converted to `models::PersistenceServiceConfigurationDto`",
625                    )));
626                }
627                ContentType::Unsupported(local_var_unknown_type) => {
628                    return Err(Error::from(serde_json::Error::custom(format!(
629                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PersistenceServiceConfigurationDto`"
630                    ))));
631                }
632            }
633        } else {
634            let local_var_entity: Option<PutPersistenceServiceConfigurationError> =
635                serde_json::from_str(&local_var_content).ok();
636            let local_var_error = ResponseContent {
637                status: local_var_status,
638                content: local_var_content,
639                entity: local_var_entity,
640            };
641            Err(Error::ResponseError(local_var_error))
642        }
643    }
644
645    async fn store_item_data_in_persistence_service<'itemname, 'time, 'state, 'service_id>(
646        &self,
647        itemname: &'itemname str,
648        time: &'time str,
649        state: &'state str,
650        service_id: Option<&'service_id str>,
651    ) -> Result<(), Error<StoreItemDataInPersistenceServiceError>> {
652        let local_var_configuration = &self.configuration;
653
654        let local_var_client = &local_var_configuration.client;
655
656        let local_var_uri_str = format!(
657            "{}/persistence/items/{itemname}",
658            local_var_configuration.base_path,
659            itemname = crate::apis::urlencode(itemname)
660        );
661        let mut local_var_req_builder =
662            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
663
664        if let Some(ref local_var_str) = service_id {
665            local_var_req_builder =
666                local_var_req_builder.query(&[("serviceId", &local_var_str.to_string())]);
667        }
668        local_var_req_builder = local_var_req_builder.query(&[("time", &time.to_string())]);
669        local_var_req_builder = local_var_req_builder.query(&[("state", &state.to_string())]);
670        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
671            local_var_req_builder = local_var_req_builder
672                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
673        }
674        if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
675            local_var_req_builder = local_var_req_builder.basic_auth(
676                local_var_auth_conf.0.to_owned(),
677                local_var_auth_conf.1.to_owned(),
678            );
679        };
680        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
681            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
682        };
683
684        let local_var_req = local_var_req_builder.build()?;
685        let local_var_resp = local_var_client.execute(local_var_req).await?;
686
687        let local_var_status = local_var_resp.status();
688        let local_var_content = local_var_resp.text().await?;
689
690        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
691            Ok(())
692        } else {
693            let local_var_entity: Option<StoreItemDataInPersistenceServiceError> =
694                serde_json::from_str(&local_var_content).ok();
695            let local_var_error = ResponseContent {
696                status: local_var_status,
697                content: local_var_content,
698                entity: local_var_entity,
699            };
700            Err(Error::ResponseError(local_var_error))
701        }
702    }
703}
704
705/// struct for typed errors of method [PersistenceApi::delete_item_from_persistence_service]
706#[derive(Debug, Clone, Serialize, Deserialize)]
707#[serde(untagged)]
708pub enum DeleteItemFromPersistenceServiceError {
709    Status400(),
710    Status404(),
711    UnknownValue(serde_json::Value),
712}
713
714/// struct for typed errors of method [PersistenceApi::delete_persistence_service_configuration]
715#[derive(Debug, Clone, Serialize, Deserialize)]
716#[serde(untagged)]
717pub enum DeletePersistenceServiceConfigurationError {
718    Status404(),
719    Status405(),
720    UnknownValue(serde_json::Value),
721}
722
723/// struct for typed errors of method [PersistenceApi::get_item_data_from_persistence_service]
724#[derive(Debug, Clone, Serialize, Deserialize)]
725#[serde(untagged)]
726pub enum GetItemDataFromPersistenceServiceError {
727    Status404(),
728    UnknownValue(serde_json::Value),
729}
730
731/// struct for typed errors of method [PersistenceApi::get_items_for_persistence_service]
732#[derive(Debug, Clone, Serialize, Deserialize)]
733#[serde(untagged)]
734pub enum GetItemsForPersistenceServiceError {
735    UnknownValue(serde_json::Value),
736}
737
738/// struct for typed errors of method [PersistenceApi::get_persistence_service_configuration]
739#[derive(Debug, Clone, Serialize, Deserialize)]
740#[serde(untagged)]
741pub enum GetPersistenceServiceConfigurationError {
742    Status404(),
743    UnknownValue(serde_json::Value),
744}
745
746/// struct for typed errors of method [PersistenceApi::get_persistence_services]
747#[derive(Debug, Clone, Serialize, Deserialize)]
748#[serde(untagged)]
749pub enum GetPersistenceServicesError {
750    UnknownValue(serde_json::Value),
751}
752
753/// struct for typed errors of method [PersistenceApi::put_persistence_service_configuration]
754#[derive(Debug, Clone, Serialize, Deserialize)]
755#[serde(untagged)]
756pub enum PutPersistenceServiceConfigurationError {
757    Status400(),
758    Status405(),
759    UnknownValue(serde_json::Value),
760}
761
762/// struct for typed errors of method [PersistenceApi::store_item_data_in_persistence_service]
763#[derive(Debug, Clone, Serialize, Deserialize)]
764#[serde(untagged)]
765pub enum StoreItemDataInPersistenceServiceError {
766    Status404(),
767    UnknownValue(serde_json::Value),
768}