hab_rs_api_client/apis/
things_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 ThingsApi: Send + Sync {
24    /// POST /things
25    ///
26    ///
27    async fn create_thing_in_registry<'thing_dto, 'accept_language>(
28        &self,
29        thing_dto: models::ThingDto,
30        accept_language: Option<&'accept_language str>,
31    ) -> Result<models::EnrichedThingDto, Error<CreateThingInRegistryError>>;
32
33    /// PUT /things/{thingUID}/enable
34    ///
35    ///
36    async fn enable_thing<'thing_uid, 'accept_language, 'body>(
37        &self,
38        thing_uid: &'thing_uid str,
39        accept_language: Option<&'accept_language str>,
40        body: Option<&'body str>,
41    ) -> Result<models::EnrichedThingDto, Error<EnableThingError>>;
42
43    /// GET /things/{thingUID}/firmwares
44    ///
45    ///
46    async fn get_available_firmwares_for_thing<'thing_uid, 'accept_language>(
47        &self,
48        thing_uid: &'thing_uid str,
49        accept_language: Option<&'accept_language str>,
50    ) -> Result<Vec<models::FirmwareDto>, Error<GetAvailableFirmwaresForThingError>>;
51
52    /// GET /things/{thingUID}
53    ///
54    ///
55    async fn get_thing_by_id<'thing_uid, 'accept_language>(
56        &self,
57        thing_uid: &'thing_uid str,
58        accept_language: Option<&'accept_language str>,
59    ) -> Result<models::EnrichedThingDto, Error<GetThingByIdError>>;
60
61    /// GET /things/{thingUID}/config/status
62    ///
63    ///
64    async fn get_thing_config_status<'thing_uid, 'accept_language>(
65        &self,
66        thing_uid: &'thing_uid str,
67        accept_language: Option<&'accept_language str>,
68    ) -> Result<Vec<models::ConfigStatusMessage>, Error<GetThingConfigStatusError>>;
69
70    /// GET /things/{thingUID}/firmware/status
71    ///
72    ///
73    async fn get_thing_firmware_status<'thing_uid, 'accept_language>(
74        &self,
75        thing_uid: &'thing_uid str,
76        accept_language: Option<&'accept_language str>,
77    ) -> Result<models::FirmwareStatusDto, Error<GetThingFirmwareStatusError>>;
78
79    /// GET /things/{thingUID}/status
80    ///
81    ///
82    async fn get_thing_status<'thing_uid, 'accept_language>(
83        &self,
84        thing_uid: &'thing_uid str,
85        accept_language: Option<&'accept_language str>,
86    ) -> Result<models::ThingStatusInfo, Error<GetThingStatusError>>;
87
88    /// GET /things
89    ///
90    ///
91    async fn get_things<'accept_language, 'summary, 'static_data_only>(
92        &self,
93        accept_language: Option<&'accept_language str>,
94        summary: Option<bool>,
95        static_data_only: Option<bool>,
96    ) -> Result<Vec<models::EnrichedThingDto>, Error<GetThingsError>>;
97
98    /// DELETE /things/{thingUID}
99    ///
100    ///
101    async fn remove_thing_by_id<'thing_uid, 'accept_language, 'force>(
102        &self,
103        thing_uid: &'thing_uid str,
104        accept_language: Option<&'accept_language str>,
105        force: Option<bool>,
106    ) -> Result<(), Error<RemoveThingByIdError>>;
107
108    /// PUT /things/{thingUID}
109    ///
110    ///
111    async fn update_thing<'thing_uid, 'thing_dto, 'accept_language>(
112        &self,
113        thing_uid: &'thing_uid str,
114        thing_dto: models::ThingDto,
115        accept_language: Option<&'accept_language str>,
116    ) -> Result<models::EnrichedThingDto, Error<UpdateThingError>>;
117
118    /// PUT /things/{thingUID}/config
119    ///
120    ///
121    async fn update_thing_config<'thing_uid, 'accept_language, 'request_body>(
122        &self,
123        thing_uid: &'thing_uid str,
124        accept_language: Option<&'accept_language str>,
125        request_body: Option<std::collections::HashMap<String, serde_json::Value>>,
126    ) -> Result<models::EnrichedThingDto, Error<UpdateThingConfigError>>;
127
128    /// PUT /things/{thingUID}/firmware/{firmwareVersion}
129    ///
130    ///
131    async fn update_thing_firmware<'thing_uid, 'firmware_version, 'accept_language>(
132        &self,
133        thing_uid: &'thing_uid str,
134        firmware_version: &'firmware_version str,
135        accept_language: Option<&'accept_language str>,
136    ) -> Result<(), Error<UpdateThingFirmwareError>>;
137}
138
139pub struct ThingsApiClient {
140    configuration: Arc<configuration::Configuration>,
141}
142
143impl ThingsApiClient {
144    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
145        Self { configuration }
146    }
147}
148
149#[async_trait]
150impl ThingsApi for ThingsApiClient {
151    async fn create_thing_in_registry<'thing_dto, 'accept_language>(
152        &self,
153        thing_dto: models::ThingDto,
154        accept_language: Option<&'accept_language str>,
155    ) -> Result<models::EnrichedThingDto, Error<CreateThingInRegistryError>> {
156        let local_var_configuration = &self.configuration;
157
158        let local_var_client = &local_var_configuration.client;
159
160        let local_var_uri_str = format!("{}/things", local_var_configuration.base_path);
161        let mut local_var_req_builder =
162            local_var_client.request(reqwest::Method::POST, 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
166                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
167        }
168        if let Some(local_var_param_value) = accept_language {
169            local_var_req_builder =
170                local_var_req_builder.header("Accept-Language", local_var_param_value.to_string());
171        }
172        if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
173            local_var_req_builder = local_var_req_builder.basic_auth(
174                local_var_auth_conf.0.to_owned(),
175                local_var_auth_conf.1.to_owned(),
176            );
177        };
178        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
179            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
180        };
181        local_var_req_builder = local_var_req_builder.json(&thing_dto);
182
183        let local_var_req = local_var_req_builder.build()?;
184        let local_var_resp = local_var_client.execute(local_var_req).await?;
185
186        let local_var_status = local_var_resp.status();
187        let local_var_content_type = local_var_resp
188            .headers()
189            .get("content-type")
190            .and_then(|v| v.to_str().ok())
191            .unwrap_or("application/octet-stream");
192        let local_var_content_type = super::ContentType::from(local_var_content_type);
193        let local_var_content = local_var_resp.text().await?;
194
195        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
196            match local_var_content_type {
197                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
198                ContentType::Text => {
199                    return Err(Error::from(serde_json::Error::custom(
200                        "Received `text/plain` content type response that cannot be converted to `models::EnrichedThingDto`",
201                    )));
202                }
203                ContentType::Unsupported(local_var_unknown_type) => {
204                    return Err(Error::from(serde_json::Error::custom(format!(
205                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EnrichedThingDto`"
206                    ))));
207                }
208            }
209        } else {
210            let local_var_entity: Option<CreateThingInRegistryError> =
211                serde_json::from_str(&local_var_content).ok();
212            let local_var_error = ResponseContent {
213                status: local_var_status,
214                content: local_var_content,
215                entity: local_var_entity,
216            };
217            Err(Error::ResponseError(local_var_error))
218        }
219    }
220
221    async fn enable_thing<'thing_uid, 'accept_language, 'body>(
222        &self,
223        thing_uid: &'thing_uid str,
224        accept_language: Option<&'accept_language str>,
225        body: Option<&'body str>,
226    ) -> Result<models::EnrichedThingDto, Error<EnableThingError>> {
227        let local_var_configuration = &self.configuration;
228
229        let local_var_client = &local_var_configuration.client;
230
231        let local_var_uri_str = format!(
232            "{}/things/{thingUID}/enable",
233            local_var_configuration.base_path,
234            thingUID = crate::apis::urlencode(thing_uid)
235        );
236        let mut local_var_req_builder =
237            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
238
239        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
240            local_var_req_builder = local_var_req_builder
241                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
242        }
243        if let Some(local_var_param_value) = accept_language {
244            local_var_req_builder =
245                local_var_req_builder.header("Accept-Language", local_var_param_value.to_string());
246        }
247        if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
248            local_var_req_builder = local_var_req_builder.basic_auth(
249                local_var_auth_conf.0.to_owned(),
250                local_var_auth_conf.1.to_owned(),
251            );
252        };
253        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
254            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
255        };
256        if let Some(body) = body {
257            local_var_req_builder = local_var_req_builder.body(body.to_string());
258            local_var_req_builder = local_var_req_builder.header(
259                reqwest::header::CONTENT_TYPE,
260                reqwest::header::HeaderValue::from_static("text/plain"),
261            );
262        }
263
264        let local_var_req = local_var_req_builder.build()?;
265        let local_var_resp = local_var_client.execute(local_var_req).await?;
266
267        let local_var_status = local_var_resp.status();
268        let local_var_content_type = local_var_resp
269            .headers()
270            .get("content-type")
271            .and_then(|v| v.to_str().ok())
272            .unwrap_or("application/octet-stream");
273        let local_var_content_type = super::ContentType::from(local_var_content_type);
274        let local_var_content = local_var_resp.text().await?;
275
276        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
277            match local_var_content_type {
278                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
279                ContentType::Text => {
280                    return Err(Error::from(serde_json::Error::custom(
281                        "Received `text/plain` content type response that cannot be converted to `models::EnrichedThingDto`",
282                    )));
283                }
284                ContentType::Unsupported(local_var_unknown_type) => {
285                    return Err(Error::from(serde_json::Error::custom(format!(
286                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EnrichedThingDto`"
287                    ))));
288                }
289            }
290        } else {
291            let local_var_entity: Option<EnableThingError> =
292                serde_json::from_str(&local_var_content).ok();
293            let local_var_error = ResponseContent {
294                status: local_var_status,
295                content: local_var_content,
296                entity: local_var_entity,
297            };
298            Err(Error::ResponseError(local_var_error))
299        }
300    }
301
302    async fn get_available_firmwares_for_thing<'thing_uid, 'accept_language>(
303        &self,
304        thing_uid: &'thing_uid str,
305        accept_language: Option<&'accept_language str>,
306    ) -> Result<Vec<models::FirmwareDto>, Error<GetAvailableFirmwaresForThingError>> {
307        let local_var_configuration = &self.configuration;
308
309        let local_var_client = &local_var_configuration.client;
310
311        let local_var_uri_str = format!(
312            "{}/things/{thingUID}/firmwares",
313            local_var_configuration.base_path,
314            thingUID = crate::apis::urlencode(thing_uid)
315        );
316        let mut local_var_req_builder =
317            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
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        if let Some(local_var_param_value) = accept_language {
324            local_var_req_builder =
325                local_var_req_builder.header("Accept-Language", local_var_param_value.to_string());
326        }
327        if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
328            local_var_req_builder = local_var_req_builder.basic_auth(
329                local_var_auth_conf.0.to_owned(),
330                local_var_auth_conf.1.to_owned(),
331            );
332        };
333        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
334            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
335        };
336
337        let local_var_req = local_var_req_builder.build()?;
338        let local_var_resp = local_var_client.execute(local_var_req).await?;
339
340        let local_var_status = local_var_resp.status();
341        let local_var_content_type = local_var_resp
342            .headers()
343            .get("content-type")
344            .and_then(|v| v.to_str().ok())
345            .unwrap_or("application/octet-stream");
346        let local_var_content_type = super::ContentType::from(local_var_content_type);
347        let local_var_content = local_var_resp.text().await?;
348
349        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
350            match local_var_content_type {
351                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
352                ContentType::Text => {
353                    return Err(Error::from(serde_json::Error::custom(
354                        "Received `text/plain` content type response that cannot be converted to `Vec&lt;models::FirmwareDto&gt;`",
355                    )));
356                }
357                ContentType::Unsupported(local_var_unknown_type) => {
358                    return Err(Error::from(serde_json::Error::custom(format!(
359                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec&lt;models::FirmwareDto&gt;`"
360                    ))));
361                }
362            }
363        } else {
364            let local_var_entity: Option<GetAvailableFirmwaresForThingError> =
365                serde_json::from_str(&local_var_content).ok();
366            let local_var_error = ResponseContent {
367                status: local_var_status,
368                content: local_var_content,
369                entity: local_var_entity,
370            };
371            Err(Error::ResponseError(local_var_error))
372        }
373    }
374
375    async fn get_thing_by_id<'thing_uid, 'accept_language>(
376        &self,
377        thing_uid: &'thing_uid str,
378        accept_language: Option<&'accept_language str>,
379    ) -> Result<models::EnrichedThingDto, Error<GetThingByIdError>> {
380        let local_var_configuration = &self.configuration;
381
382        let local_var_client = &local_var_configuration.client;
383
384        let local_var_uri_str = format!(
385            "{}/things/{thingUID}",
386            local_var_configuration.base_path,
387            thingUID = crate::apis::urlencode(thing_uid)
388        );
389        let mut local_var_req_builder =
390            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
391
392        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
393            local_var_req_builder = local_var_req_builder
394                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
395        }
396        if let Some(local_var_param_value) = accept_language {
397            local_var_req_builder =
398                local_var_req_builder.header("Accept-Language", local_var_param_value.to_string());
399        }
400        if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
401            local_var_req_builder = local_var_req_builder.basic_auth(
402                local_var_auth_conf.0.to_owned(),
403                local_var_auth_conf.1.to_owned(),
404            );
405        };
406        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
407            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
408        };
409
410        let local_var_req = local_var_req_builder.build()?;
411        let local_var_resp = local_var_client.execute(local_var_req).await?;
412
413        let local_var_status = local_var_resp.status();
414        let local_var_content_type = local_var_resp
415            .headers()
416            .get("content-type")
417            .and_then(|v| v.to_str().ok())
418            .unwrap_or("application/octet-stream");
419        let local_var_content_type = super::ContentType::from(local_var_content_type);
420        let local_var_content = local_var_resp.text().await?;
421
422        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
423            match local_var_content_type {
424                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
425                ContentType::Text => {
426                    return Err(Error::from(serde_json::Error::custom(
427                        "Received `text/plain` content type response that cannot be converted to `models::EnrichedThingDto`",
428                    )));
429                }
430                ContentType::Unsupported(local_var_unknown_type) => {
431                    return Err(Error::from(serde_json::Error::custom(format!(
432                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EnrichedThingDto`"
433                    ))));
434                }
435            }
436        } else {
437            let local_var_entity: Option<GetThingByIdError> =
438                serde_json::from_str(&local_var_content).ok();
439            let local_var_error = ResponseContent {
440                status: local_var_status,
441                content: local_var_content,
442                entity: local_var_entity,
443            };
444            Err(Error::ResponseError(local_var_error))
445        }
446    }
447
448    async fn get_thing_config_status<'thing_uid, 'accept_language>(
449        &self,
450        thing_uid: &'thing_uid str,
451        accept_language: Option<&'accept_language str>,
452    ) -> Result<Vec<models::ConfigStatusMessage>, Error<GetThingConfigStatusError>> {
453        let local_var_configuration = &self.configuration;
454
455        let local_var_client = &local_var_configuration.client;
456
457        let local_var_uri_str = format!(
458            "{}/things/{thingUID}/config/status",
459            local_var_configuration.base_path,
460            thingUID = crate::apis::urlencode(thing_uid)
461        );
462        let mut local_var_req_builder =
463            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
464
465        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
466            local_var_req_builder = local_var_req_builder
467                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
468        }
469        if let Some(local_var_param_value) = accept_language {
470            local_var_req_builder =
471                local_var_req_builder.header("Accept-Language", local_var_param_value.to_string());
472        }
473        if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
474            local_var_req_builder = local_var_req_builder.basic_auth(
475                local_var_auth_conf.0.to_owned(),
476                local_var_auth_conf.1.to_owned(),
477            );
478        };
479        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
480            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
481        };
482
483        let local_var_req = local_var_req_builder.build()?;
484        let local_var_resp = local_var_client.execute(local_var_req).await?;
485
486        let local_var_status = local_var_resp.status();
487        let local_var_content_type = local_var_resp
488            .headers()
489            .get("content-type")
490            .and_then(|v| v.to_str().ok())
491            .unwrap_or("application/octet-stream");
492        let local_var_content_type = super::ContentType::from(local_var_content_type);
493        let local_var_content = local_var_resp.text().await?;
494
495        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
496            match local_var_content_type {
497                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
498                ContentType::Text => {
499                    return Err(Error::from(serde_json::Error::custom(
500                        "Received `text/plain` content type response that cannot be converted to `Vec&lt;models::ConfigStatusMessage&gt;`",
501                    )));
502                }
503                ContentType::Unsupported(local_var_unknown_type) => {
504                    return Err(Error::from(serde_json::Error::custom(format!(
505                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec&lt;models::ConfigStatusMessage&gt;`"
506                    ))));
507                }
508            }
509        } else {
510            let local_var_entity: Option<GetThingConfigStatusError> =
511                serde_json::from_str(&local_var_content).ok();
512            let local_var_error = ResponseContent {
513                status: local_var_status,
514                content: local_var_content,
515                entity: local_var_entity,
516            };
517            Err(Error::ResponseError(local_var_error))
518        }
519    }
520
521    async fn get_thing_firmware_status<'thing_uid, 'accept_language>(
522        &self,
523        thing_uid: &'thing_uid str,
524        accept_language: Option<&'accept_language str>,
525    ) -> Result<models::FirmwareStatusDto, Error<GetThingFirmwareStatusError>> {
526        let local_var_configuration = &self.configuration;
527
528        let local_var_client = &local_var_configuration.client;
529
530        let local_var_uri_str = format!(
531            "{}/things/{thingUID}/firmware/status",
532            local_var_configuration.base_path,
533            thingUID = crate::apis::urlencode(thing_uid)
534        );
535        let mut local_var_req_builder =
536            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
537
538        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
539            local_var_req_builder = local_var_req_builder
540                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
541        }
542        if let Some(local_var_param_value) = accept_language {
543            local_var_req_builder =
544                local_var_req_builder.header("Accept-Language", local_var_param_value.to_string());
545        }
546        if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
547            local_var_req_builder = local_var_req_builder.basic_auth(
548                local_var_auth_conf.0.to_owned(),
549                local_var_auth_conf.1.to_owned(),
550            );
551        };
552        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
553            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
554        };
555
556        let local_var_req = local_var_req_builder.build()?;
557        let local_var_resp = local_var_client.execute(local_var_req).await?;
558
559        let local_var_status = local_var_resp.status();
560        let local_var_content_type = local_var_resp
561            .headers()
562            .get("content-type")
563            .and_then(|v| v.to_str().ok())
564            .unwrap_or("application/octet-stream");
565        let local_var_content_type = super::ContentType::from(local_var_content_type);
566        let local_var_content = local_var_resp.text().await?;
567
568        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
569            match local_var_content_type {
570                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
571                ContentType::Text => {
572                    return Err(Error::from(serde_json::Error::custom(
573                        "Received `text/plain` content type response that cannot be converted to `models::FirmwareStatusDto`",
574                    )));
575                }
576                ContentType::Unsupported(local_var_unknown_type) => {
577                    return Err(Error::from(serde_json::Error::custom(format!(
578                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::FirmwareStatusDto`"
579                    ))));
580                }
581            }
582        } else {
583            let local_var_entity: Option<GetThingFirmwareStatusError> =
584                serde_json::from_str(&local_var_content).ok();
585            let local_var_error = ResponseContent {
586                status: local_var_status,
587                content: local_var_content,
588                entity: local_var_entity,
589            };
590            Err(Error::ResponseError(local_var_error))
591        }
592    }
593
594    async fn get_thing_status<'thing_uid, 'accept_language>(
595        &self,
596        thing_uid: &'thing_uid str,
597        accept_language: Option<&'accept_language str>,
598    ) -> Result<models::ThingStatusInfo, Error<GetThingStatusError>> {
599        let local_var_configuration = &self.configuration;
600
601        let local_var_client = &local_var_configuration.client;
602
603        let local_var_uri_str = format!(
604            "{}/things/{thingUID}/status",
605            local_var_configuration.base_path,
606            thingUID = crate::apis::urlencode(thing_uid)
607        );
608        let mut local_var_req_builder =
609            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
610
611        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
612            local_var_req_builder = local_var_req_builder
613                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
614        }
615        if let Some(local_var_param_value) = accept_language {
616            local_var_req_builder =
617                local_var_req_builder.header("Accept-Language", local_var_param_value.to_string());
618        }
619        if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
620            local_var_req_builder = local_var_req_builder.basic_auth(
621                local_var_auth_conf.0.to_owned(),
622                local_var_auth_conf.1.to_owned(),
623            );
624        };
625        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
626            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
627        };
628
629        let local_var_req = local_var_req_builder.build()?;
630        let local_var_resp = local_var_client.execute(local_var_req).await?;
631
632        let local_var_status = local_var_resp.status();
633        let local_var_content_type = local_var_resp
634            .headers()
635            .get("content-type")
636            .and_then(|v| v.to_str().ok())
637            .unwrap_or("application/octet-stream");
638        let local_var_content_type = super::ContentType::from(local_var_content_type);
639        let local_var_content = local_var_resp.text().await?;
640
641        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
642            match local_var_content_type {
643                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
644                ContentType::Text => {
645                    return Err(Error::from(serde_json::Error::custom(
646                        "Received `text/plain` content type response that cannot be converted to `models::ThingStatusInfo`",
647                    )));
648                }
649                ContentType::Unsupported(local_var_unknown_type) => {
650                    return Err(Error::from(serde_json::Error::custom(format!(
651                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ThingStatusInfo`"
652                    ))));
653                }
654            }
655        } else {
656            let local_var_entity: Option<GetThingStatusError> =
657                serde_json::from_str(&local_var_content).ok();
658            let local_var_error = ResponseContent {
659                status: local_var_status,
660                content: local_var_content,
661                entity: local_var_entity,
662            };
663            Err(Error::ResponseError(local_var_error))
664        }
665    }
666
667    async fn get_things<'accept_language, 'summary, 'static_data_only>(
668        &self,
669        accept_language: Option<&'accept_language str>,
670        summary: Option<bool>,
671        static_data_only: Option<bool>,
672    ) -> Result<Vec<models::EnrichedThingDto>, Error<GetThingsError>> {
673        let local_var_configuration = &self.configuration;
674
675        let local_var_client = &local_var_configuration.client;
676
677        let local_var_uri_str = format!("{}/things", local_var_configuration.base_path);
678        let mut local_var_req_builder =
679            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
680
681        if let Some(ref local_var_str) = summary {
682            local_var_req_builder =
683                local_var_req_builder.query(&[("summary", &local_var_str.to_string())]);
684        }
685        if let Some(ref local_var_str) = static_data_only {
686            local_var_req_builder =
687                local_var_req_builder.query(&[("staticDataOnly", &local_var_str.to_string())]);
688        }
689        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
690            local_var_req_builder = local_var_req_builder
691                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
692        }
693        if let Some(local_var_param_value) = accept_language {
694            local_var_req_builder =
695                local_var_req_builder.header("Accept-Language", local_var_param_value.to_string());
696        }
697        if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
698            local_var_req_builder = local_var_req_builder.basic_auth(
699                local_var_auth_conf.0.to_owned(),
700                local_var_auth_conf.1.to_owned(),
701            );
702        };
703        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
704            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
705        };
706
707        let local_var_req = local_var_req_builder.build()?;
708        let local_var_resp = local_var_client.execute(local_var_req).await?;
709
710        let local_var_status = local_var_resp.status();
711        let local_var_content_type = local_var_resp
712            .headers()
713            .get("content-type")
714            .and_then(|v| v.to_str().ok())
715            .unwrap_or("application/octet-stream");
716        let local_var_content_type = super::ContentType::from(local_var_content_type);
717        let local_var_content = local_var_resp.text().await?;
718
719        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
720            match local_var_content_type {
721                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
722                ContentType::Text => {
723                    return Err(Error::from(serde_json::Error::custom(
724                        "Received `text/plain` content type response that cannot be converted to `Vec&lt;models::EnrichedThingDto&gt;`",
725                    )));
726                }
727                ContentType::Unsupported(local_var_unknown_type) => {
728                    return Err(Error::from(serde_json::Error::custom(format!(
729                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec&lt;models::EnrichedThingDto&gt;`"
730                    ))));
731                }
732            }
733        } else {
734            let local_var_entity: Option<GetThingsError> =
735                serde_json::from_str(&local_var_content).ok();
736            let local_var_error = ResponseContent {
737                status: local_var_status,
738                content: local_var_content,
739                entity: local_var_entity,
740            };
741            Err(Error::ResponseError(local_var_error))
742        }
743    }
744
745    async fn remove_thing_by_id<'thing_uid, 'accept_language, 'force>(
746        &self,
747        thing_uid: &'thing_uid str,
748        accept_language: Option<&'accept_language str>,
749        force: Option<bool>,
750    ) -> Result<(), Error<RemoveThingByIdError>> {
751        let local_var_configuration = &self.configuration;
752
753        let local_var_client = &local_var_configuration.client;
754
755        let local_var_uri_str = format!(
756            "{}/things/{thingUID}",
757            local_var_configuration.base_path,
758            thingUID = crate::apis::urlencode(thing_uid)
759        );
760        let mut local_var_req_builder =
761            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
762
763        if let Some(ref local_var_str) = force {
764            local_var_req_builder =
765                local_var_req_builder.query(&[("force", &local_var_str.to_string())]);
766        }
767        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
768            local_var_req_builder = local_var_req_builder
769                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
770        }
771        if let Some(local_var_param_value) = accept_language {
772            local_var_req_builder =
773                local_var_req_builder.header("Accept-Language", local_var_param_value.to_string());
774        }
775        if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
776            local_var_req_builder = local_var_req_builder.basic_auth(
777                local_var_auth_conf.0.to_owned(),
778                local_var_auth_conf.1.to_owned(),
779            );
780        };
781        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
782            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
783        };
784
785        let local_var_req = local_var_req_builder.build()?;
786        let local_var_resp = local_var_client.execute(local_var_req).await?;
787
788        let local_var_status = local_var_resp.status();
789        let local_var_content = local_var_resp.text().await?;
790
791        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
792            Ok(())
793        } else {
794            let local_var_entity: Option<RemoveThingByIdError> =
795                serde_json::from_str(&local_var_content).ok();
796            let local_var_error = ResponseContent {
797                status: local_var_status,
798                content: local_var_content,
799                entity: local_var_entity,
800            };
801            Err(Error::ResponseError(local_var_error))
802        }
803    }
804
805    async fn update_thing<'thing_uid, 'thing_dto, 'accept_language>(
806        &self,
807        thing_uid: &'thing_uid str,
808        thing_dto: models::ThingDto,
809        accept_language: Option<&'accept_language str>,
810    ) -> Result<models::EnrichedThingDto, Error<UpdateThingError>> {
811        let local_var_configuration = &self.configuration;
812
813        let local_var_client = &local_var_configuration.client;
814
815        let local_var_uri_str = format!(
816            "{}/things/{thingUID}",
817            local_var_configuration.base_path,
818            thingUID = crate::apis::urlencode(thing_uid)
819        );
820        let mut local_var_req_builder =
821            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
822
823        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
824            local_var_req_builder = local_var_req_builder
825                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
826        }
827        if let Some(local_var_param_value) = accept_language {
828            local_var_req_builder =
829                local_var_req_builder.header("Accept-Language", local_var_param_value.to_string());
830        }
831        if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
832            local_var_req_builder = local_var_req_builder.basic_auth(
833                local_var_auth_conf.0.to_owned(),
834                local_var_auth_conf.1.to_owned(),
835            );
836        };
837        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
838            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
839        };
840        local_var_req_builder = local_var_req_builder.json(&thing_dto);
841
842        let local_var_req = local_var_req_builder.build()?;
843        let local_var_resp = local_var_client.execute(local_var_req).await?;
844
845        let local_var_status = local_var_resp.status();
846        let local_var_content_type = local_var_resp
847            .headers()
848            .get("content-type")
849            .and_then(|v| v.to_str().ok())
850            .unwrap_or("application/octet-stream");
851        let local_var_content_type = super::ContentType::from(local_var_content_type);
852        let local_var_content = local_var_resp.text().await?;
853
854        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
855            match local_var_content_type {
856                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
857                ContentType::Text => {
858                    return Err(Error::from(serde_json::Error::custom(
859                        "Received `text/plain` content type response that cannot be converted to `models::EnrichedThingDto`",
860                    )));
861                }
862                ContentType::Unsupported(local_var_unknown_type) => {
863                    return Err(Error::from(serde_json::Error::custom(format!(
864                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EnrichedThingDto`"
865                    ))));
866                }
867            }
868        } else {
869            let local_var_entity: Option<UpdateThingError> =
870                serde_json::from_str(&local_var_content).ok();
871            let local_var_error = ResponseContent {
872                status: local_var_status,
873                content: local_var_content,
874                entity: local_var_entity,
875            };
876            Err(Error::ResponseError(local_var_error))
877        }
878    }
879
880    async fn update_thing_config<'thing_uid, 'accept_language, 'request_body>(
881        &self,
882        thing_uid: &'thing_uid str,
883        accept_language: Option<&'accept_language str>,
884        request_body: Option<std::collections::HashMap<String, serde_json::Value>>,
885    ) -> Result<models::EnrichedThingDto, Error<UpdateThingConfigError>> {
886        let local_var_configuration = &self.configuration;
887
888        let local_var_client = &local_var_configuration.client;
889
890        let local_var_uri_str = format!(
891            "{}/things/{thingUID}/config",
892            local_var_configuration.base_path,
893            thingUID = crate::apis::urlencode(thing_uid)
894        );
895        let mut local_var_req_builder =
896            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
897
898        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
899            local_var_req_builder = local_var_req_builder
900                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
901        }
902        if let Some(local_var_param_value) = accept_language {
903            local_var_req_builder =
904                local_var_req_builder.header("Accept-Language", local_var_param_value.to_string());
905        }
906        if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
907            local_var_req_builder = local_var_req_builder.basic_auth(
908                local_var_auth_conf.0.to_owned(),
909                local_var_auth_conf.1.to_owned(),
910            );
911        };
912        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
913            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
914        };
915        local_var_req_builder = local_var_req_builder.json(&request_body);
916
917        let local_var_req = local_var_req_builder.build()?;
918        let local_var_resp = local_var_client.execute(local_var_req).await?;
919
920        let local_var_status = local_var_resp.status();
921        let local_var_content_type = local_var_resp
922            .headers()
923            .get("content-type")
924            .and_then(|v| v.to_str().ok())
925            .unwrap_or("application/octet-stream");
926        let local_var_content_type = super::ContentType::from(local_var_content_type);
927        let local_var_content = local_var_resp.text().await?;
928
929        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
930            match local_var_content_type {
931                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
932                ContentType::Text => {
933                    return Err(Error::from(serde_json::Error::custom(
934                        "Received `text/plain` content type response that cannot be converted to `models::EnrichedThingDto`",
935                    )));
936                }
937                ContentType::Unsupported(local_var_unknown_type) => {
938                    return Err(Error::from(serde_json::Error::custom(format!(
939                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EnrichedThingDto`"
940                    ))));
941                }
942            }
943        } else {
944            let local_var_entity: Option<UpdateThingConfigError> =
945                serde_json::from_str(&local_var_content).ok();
946            let local_var_error = ResponseContent {
947                status: local_var_status,
948                content: local_var_content,
949                entity: local_var_entity,
950            };
951            Err(Error::ResponseError(local_var_error))
952        }
953    }
954
955    async fn update_thing_firmware<'thing_uid, 'firmware_version, 'accept_language>(
956        &self,
957        thing_uid: &'thing_uid str,
958        firmware_version: &'firmware_version str,
959        accept_language: Option<&'accept_language str>,
960    ) -> Result<(), Error<UpdateThingFirmwareError>> {
961        let local_var_configuration = &self.configuration;
962
963        let local_var_client = &local_var_configuration.client;
964
965        let local_var_uri_str = format!(
966            "{}/things/{thingUID}/firmware/{firmwareVersion}",
967            local_var_configuration.base_path,
968            thingUID = crate::apis::urlencode(thing_uid),
969            firmwareVersion = crate::apis::urlencode(firmware_version)
970        );
971        let mut local_var_req_builder =
972            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
973
974        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
975            local_var_req_builder = local_var_req_builder
976                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
977        }
978        if let Some(local_var_param_value) = accept_language {
979            local_var_req_builder =
980                local_var_req_builder.header("Accept-Language", local_var_param_value.to_string());
981        }
982        if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
983            local_var_req_builder = local_var_req_builder.basic_auth(
984                local_var_auth_conf.0.to_owned(),
985                local_var_auth_conf.1.to_owned(),
986            );
987        };
988        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
989            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
990        };
991
992        let local_var_req = local_var_req_builder.build()?;
993        let local_var_resp = local_var_client.execute(local_var_req).await?;
994
995        let local_var_status = local_var_resp.status();
996        let local_var_content = local_var_resp.text().await?;
997
998        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
999            Ok(())
1000        } else {
1001            let local_var_entity: Option<UpdateThingFirmwareError> =
1002                serde_json::from_str(&local_var_content).ok();
1003            let local_var_error = ResponseContent {
1004                status: local_var_status,
1005                content: local_var_content,
1006                entity: local_var_entity,
1007            };
1008            Err(Error::ResponseError(local_var_error))
1009        }
1010    }
1011}
1012
1013/// struct for typed errors of method [ThingsApi::create_thing_in_registry]
1014#[derive(Debug, Clone, Serialize, Deserialize)]
1015#[serde(untagged)]
1016pub enum CreateThingInRegistryError {
1017    Status400(),
1018    Status409(),
1019    UnknownValue(serde_json::Value),
1020}
1021
1022/// struct for typed errors of method [ThingsApi::enable_thing]
1023#[derive(Debug, Clone, Serialize, Deserialize)]
1024#[serde(untagged)]
1025pub enum EnableThingError {
1026    Status404(),
1027    UnknownValue(serde_json::Value),
1028}
1029
1030/// struct for typed errors of method [ThingsApi::get_available_firmwares_for_thing]
1031#[derive(Debug, Clone, Serialize, Deserialize)]
1032#[serde(untagged)]
1033pub enum GetAvailableFirmwaresForThingError {
1034    UnknownValue(serde_json::Value),
1035}
1036
1037/// struct for typed errors of method [ThingsApi::get_thing_by_id]
1038#[derive(Debug, Clone, Serialize, Deserialize)]
1039#[serde(untagged)]
1040pub enum GetThingByIdError {
1041    Status404(),
1042    UnknownValue(serde_json::Value),
1043}
1044
1045/// struct for typed errors of method [ThingsApi::get_thing_config_status]
1046#[derive(Debug, Clone, Serialize, Deserialize)]
1047#[serde(untagged)]
1048pub enum GetThingConfigStatusError {
1049    Status404(),
1050    UnknownValue(serde_json::Value),
1051}
1052
1053/// struct for typed errors of method [ThingsApi::get_thing_firmware_status]
1054#[derive(Debug, Clone, Serialize, Deserialize)]
1055#[serde(untagged)]
1056pub enum GetThingFirmwareStatusError {
1057    UnknownValue(serde_json::Value),
1058}
1059
1060/// struct for typed errors of method [ThingsApi::get_thing_status]
1061#[derive(Debug, Clone, Serialize, Deserialize)]
1062#[serde(untagged)]
1063pub enum GetThingStatusError {
1064    Status404(),
1065    UnknownValue(serde_json::Value),
1066}
1067
1068/// struct for typed errors of method [ThingsApi::get_things]
1069#[derive(Debug, Clone, Serialize, Deserialize)]
1070#[serde(untagged)]
1071pub enum GetThingsError {
1072    UnknownValue(serde_json::Value),
1073}
1074
1075/// struct for typed errors of method [ThingsApi::remove_thing_by_id]
1076#[derive(Debug, Clone, Serialize, Deserialize)]
1077#[serde(untagged)]
1078pub enum RemoveThingByIdError {
1079    Status404(),
1080    Status409(),
1081    UnknownValue(serde_json::Value),
1082}
1083
1084/// struct for typed errors of method [ThingsApi::update_thing]
1085#[derive(Debug, Clone, Serialize, Deserialize)]
1086#[serde(untagged)]
1087pub enum UpdateThingError {
1088    Status404(),
1089    Status409(),
1090    UnknownValue(serde_json::Value),
1091}
1092
1093/// struct for typed errors of method [ThingsApi::update_thing_config]
1094#[derive(Debug, Clone, Serialize, Deserialize)]
1095#[serde(untagged)]
1096pub enum UpdateThingConfigError {
1097    Status400(),
1098    Status404(),
1099    Status409(),
1100    UnknownValue(serde_json::Value),
1101}
1102
1103/// struct for typed errors of method [ThingsApi::update_thing_firmware]
1104#[derive(Debug, Clone, Serialize, Deserialize)]
1105#[serde(untagged)]
1106pub enum UpdateThingFirmwareError {
1107    Status400(),
1108    Status404(),
1109    UnknownValue(serde_json::Value),
1110}