readarr/apis/
download_client_api.rs

1/*
2 * Readarr
3 *
4 * Readarr API docs
5 *
6 * The version of the OpenAPI document: v0.4.10.2734
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`create_download_client`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateDownloadClientError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`create_download_client_action_by_name`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum CreateDownloadClientActionByNameError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`delete_download_client`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum DeleteDownloadClientError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`delete_download_client_bulk`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum DeleteDownloadClientBulkError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`get_download_client_by_id`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetDownloadClientByIdError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`list_download_client`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum ListDownloadClientError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`list_download_client_schema`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum ListDownloadClientSchemaError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`put_download_client_bulk`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum PutDownloadClientBulkError {
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`test_download_client`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum TestDownloadClientError {
78    UnknownValue(serde_json::Value),
79}
80
81/// struct for typed errors of method [`testall_download_client`]
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum TestallDownloadClientError {
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`update_download_client`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum UpdateDownloadClientError {
92    UnknownValue(serde_json::Value),
93}
94
95
96pub async fn create_download_client(configuration: &configuration::Configuration, force_save: Option<bool>, download_client_resource: Option<models::DownloadClientResource>) -> Result<models::DownloadClientResource, Error<CreateDownloadClientError>> {
97    // add a prefix to parameters to efficiently prevent name collisions
98    let p_query_force_save = force_save;
99    let p_body_download_client_resource = download_client_resource;
100
101    let uri_str = format!("{}/api/v1/downloadclient", configuration.base_path);
102    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
103
104    if let Some(ref param_value) = p_query_force_save {
105        req_builder = req_builder.query(&[("forceSave", &param_value.to_string())]);
106    }
107    if let Some(ref apikey) = configuration.api_key {
108        let key = apikey.key.clone();
109        let value = match apikey.prefix {
110            Some(ref prefix) => format!("{} {}", prefix, key),
111            None => key,
112        };
113        req_builder = req_builder.query(&[("apikey", value)]);
114    }
115    if let Some(ref user_agent) = configuration.user_agent {
116        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
117    }
118    if let Some(ref apikey) = configuration.api_key {
119        let key = apikey.key.clone();
120        let value = match apikey.prefix {
121            Some(ref prefix) => format!("{} {}", prefix, key),
122            None => key,
123        };
124        req_builder = req_builder.header("X-Api-Key", value);
125    };
126    req_builder = req_builder.json(&p_body_download_client_resource);
127
128    let req = req_builder.build()?;
129    let resp = configuration.client.execute(req).await?;
130
131    let status = resp.status();
132    let content_type = resp
133        .headers()
134        .get("content-type")
135        .and_then(|v| v.to_str().ok())
136        .unwrap_or("application/octet-stream");
137    let content_type = super::ContentType::from(content_type);
138
139    if !status.is_client_error() && !status.is_server_error() {
140        let content = resp.text().await?;
141        match content_type {
142            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
143            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DownloadClientResource`"))),
144            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DownloadClientResource`")))),
145        }
146    } else {
147        let content = resp.text().await?;
148        let entity: Option<CreateDownloadClientError> = serde_json::from_str(&content).ok();
149        Err(Error::ResponseError(ResponseContent { status, content, entity }))
150    }
151}
152
153pub async fn create_download_client_action_by_name(configuration: &configuration::Configuration, name: &str, download_client_resource: Option<models::DownloadClientResource>) -> Result<(), Error<CreateDownloadClientActionByNameError>> {
154    // add a prefix to parameters to efficiently prevent name collisions
155    let p_path_name = name;
156    let p_body_download_client_resource = download_client_resource;
157
158    let uri_str = format!("{}/api/v1/downloadclient/action/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
159    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
160
161    if let Some(ref apikey) = configuration.api_key {
162        let key = apikey.key.clone();
163        let value = match apikey.prefix {
164            Some(ref prefix) => format!("{} {}", prefix, key),
165            None => key,
166        };
167        req_builder = req_builder.query(&[("apikey", value)]);
168    }
169    if let Some(ref user_agent) = configuration.user_agent {
170        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
171    }
172    if let Some(ref apikey) = configuration.api_key {
173        let key = apikey.key.clone();
174        let value = match apikey.prefix {
175            Some(ref prefix) => format!("{} {}", prefix, key),
176            None => key,
177        };
178        req_builder = req_builder.header("X-Api-Key", value);
179    };
180    req_builder = req_builder.json(&p_body_download_client_resource);
181
182    let req = req_builder.build()?;
183    let resp = configuration.client.execute(req).await?;
184
185    let status = resp.status();
186
187    if !status.is_client_error() && !status.is_server_error() {
188        Ok(())
189    } else {
190        let content = resp.text().await?;
191        let entity: Option<CreateDownloadClientActionByNameError> = serde_json::from_str(&content).ok();
192        Err(Error::ResponseError(ResponseContent { status, content, entity }))
193    }
194}
195
196pub async fn delete_download_client(configuration: &configuration::Configuration, id: i32) -> Result<(), Error<DeleteDownloadClientError>> {
197    // add a prefix to parameters to efficiently prevent name collisions
198    let p_path_id = id;
199
200    let uri_str = format!("{}/api/v1/downloadclient/{id}", configuration.base_path, id=p_path_id);
201    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
202
203    if let Some(ref apikey) = configuration.api_key {
204        let key = apikey.key.clone();
205        let value = match apikey.prefix {
206            Some(ref prefix) => format!("{} {}", prefix, key),
207            None => key,
208        };
209        req_builder = req_builder.query(&[("apikey", value)]);
210    }
211    if let Some(ref user_agent) = configuration.user_agent {
212        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
213    }
214    if let Some(ref apikey) = configuration.api_key {
215        let key = apikey.key.clone();
216        let value = match apikey.prefix {
217            Some(ref prefix) => format!("{} {}", prefix, key),
218            None => key,
219        };
220        req_builder = req_builder.header("X-Api-Key", value);
221    };
222
223    let req = req_builder.build()?;
224    let resp = configuration.client.execute(req).await?;
225
226    let status = resp.status();
227
228    if !status.is_client_error() && !status.is_server_error() {
229        Ok(())
230    } else {
231        let content = resp.text().await?;
232        let entity: Option<DeleteDownloadClientError> = serde_json::from_str(&content).ok();
233        Err(Error::ResponseError(ResponseContent { status, content, entity }))
234    }
235}
236
237pub async fn delete_download_client_bulk(configuration: &configuration::Configuration, download_client_bulk_resource: Option<models::DownloadClientBulkResource>) -> Result<(), Error<DeleteDownloadClientBulkError>> {
238    // add a prefix to parameters to efficiently prevent name collisions
239    let p_body_download_client_bulk_resource = download_client_bulk_resource;
240
241    let uri_str = format!("{}/api/v1/downloadclient/bulk", configuration.base_path);
242    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
243
244    if let Some(ref apikey) = configuration.api_key {
245        let key = apikey.key.clone();
246        let value = match apikey.prefix {
247            Some(ref prefix) => format!("{} {}", prefix, key),
248            None => key,
249        };
250        req_builder = req_builder.query(&[("apikey", value)]);
251    }
252    if let Some(ref user_agent) = configuration.user_agent {
253        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
254    }
255    if let Some(ref apikey) = configuration.api_key {
256        let key = apikey.key.clone();
257        let value = match apikey.prefix {
258            Some(ref prefix) => format!("{} {}", prefix, key),
259            None => key,
260        };
261        req_builder = req_builder.header("X-Api-Key", value);
262    };
263    req_builder = req_builder.json(&p_body_download_client_bulk_resource);
264
265    let req = req_builder.build()?;
266    let resp = configuration.client.execute(req).await?;
267
268    let status = resp.status();
269
270    if !status.is_client_error() && !status.is_server_error() {
271        Ok(())
272    } else {
273        let content = resp.text().await?;
274        let entity: Option<DeleteDownloadClientBulkError> = serde_json::from_str(&content).ok();
275        Err(Error::ResponseError(ResponseContent { status, content, entity }))
276    }
277}
278
279pub async fn get_download_client_by_id(configuration: &configuration::Configuration, id: i32) -> Result<models::DownloadClientResource, Error<GetDownloadClientByIdError>> {
280    // add a prefix to parameters to efficiently prevent name collisions
281    let p_path_id = id;
282
283    let uri_str = format!("{}/api/v1/downloadclient/{id}", configuration.base_path, id=p_path_id);
284    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
285
286    if let Some(ref apikey) = configuration.api_key {
287        let key = apikey.key.clone();
288        let value = match apikey.prefix {
289            Some(ref prefix) => format!("{} {}", prefix, key),
290            None => key,
291        };
292        req_builder = req_builder.query(&[("apikey", value)]);
293    }
294    if let Some(ref user_agent) = configuration.user_agent {
295        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
296    }
297    if let Some(ref apikey) = configuration.api_key {
298        let key = apikey.key.clone();
299        let value = match apikey.prefix {
300            Some(ref prefix) => format!("{} {}", prefix, key),
301            None => key,
302        };
303        req_builder = req_builder.header("X-Api-Key", value);
304    };
305
306    let req = req_builder.build()?;
307    let resp = configuration.client.execute(req).await?;
308
309    let status = resp.status();
310    let content_type = resp
311        .headers()
312        .get("content-type")
313        .and_then(|v| v.to_str().ok())
314        .unwrap_or("application/octet-stream");
315    let content_type = super::ContentType::from(content_type);
316
317    if !status.is_client_error() && !status.is_server_error() {
318        let content = resp.text().await?;
319        match content_type {
320            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
321            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DownloadClientResource`"))),
322            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DownloadClientResource`")))),
323        }
324    } else {
325        let content = resp.text().await?;
326        let entity: Option<GetDownloadClientByIdError> = serde_json::from_str(&content).ok();
327        Err(Error::ResponseError(ResponseContent { status, content, entity }))
328    }
329}
330
331pub async fn list_download_client(configuration: &configuration::Configuration, ) -> Result<Vec<models::DownloadClientResource>, Error<ListDownloadClientError>> {
332
333    let uri_str = format!("{}/api/v1/downloadclient", configuration.base_path);
334    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
335
336    if let Some(ref apikey) = configuration.api_key {
337        let key = apikey.key.clone();
338        let value = match apikey.prefix {
339            Some(ref prefix) => format!("{} {}", prefix, key),
340            None => key,
341        };
342        req_builder = req_builder.query(&[("apikey", value)]);
343    }
344    if let Some(ref user_agent) = configuration.user_agent {
345        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
346    }
347    if let Some(ref apikey) = configuration.api_key {
348        let key = apikey.key.clone();
349        let value = match apikey.prefix {
350            Some(ref prefix) => format!("{} {}", prefix, key),
351            None => key,
352        };
353        req_builder = req_builder.header("X-Api-Key", value);
354    };
355
356    let req = req_builder.build()?;
357    let resp = configuration.client.execute(req).await?;
358
359    let status = resp.status();
360    let content_type = resp
361        .headers()
362        .get("content-type")
363        .and_then(|v| v.to_str().ok())
364        .unwrap_or("application/octet-stream");
365    let content_type = super::ContentType::from(content_type);
366
367    if !status.is_client_error() && !status.is_server_error() {
368        let content = resp.text().await?;
369        match content_type {
370            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
371            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::DownloadClientResource&gt;`"))),
372            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::DownloadClientResource&gt;`")))),
373        }
374    } else {
375        let content = resp.text().await?;
376        let entity: Option<ListDownloadClientError> = serde_json::from_str(&content).ok();
377        Err(Error::ResponseError(ResponseContent { status, content, entity }))
378    }
379}
380
381pub async fn list_download_client_schema(configuration: &configuration::Configuration, ) -> Result<Vec<models::DownloadClientResource>, Error<ListDownloadClientSchemaError>> {
382
383    let uri_str = format!("{}/api/v1/downloadclient/schema", configuration.base_path);
384    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
385
386    if let Some(ref apikey) = configuration.api_key {
387        let key = apikey.key.clone();
388        let value = match apikey.prefix {
389            Some(ref prefix) => format!("{} {}", prefix, key),
390            None => key,
391        };
392        req_builder = req_builder.query(&[("apikey", value)]);
393    }
394    if let Some(ref user_agent) = configuration.user_agent {
395        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
396    }
397    if let Some(ref apikey) = configuration.api_key {
398        let key = apikey.key.clone();
399        let value = match apikey.prefix {
400            Some(ref prefix) => format!("{} {}", prefix, key),
401            None => key,
402        };
403        req_builder = req_builder.header("X-Api-Key", value);
404    };
405
406    let req = req_builder.build()?;
407    let resp = configuration.client.execute(req).await?;
408
409    let status = resp.status();
410    let content_type = resp
411        .headers()
412        .get("content-type")
413        .and_then(|v| v.to_str().ok())
414        .unwrap_or("application/octet-stream");
415    let content_type = super::ContentType::from(content_type);
416
417    if !status.is_client_error() && !status.is_server_error() {
418        let content = resp.text().await?;
419        match content_type {
420            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
421            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::DownloadClientResource&gt;`"))),
422            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::DownloadClientResource&gt;`")))),
423        }
424    } else {
425        let content = resp.text().await?;
426        let entity: Option<ListDownloadClientSchemaError> = serde_json::from_str(&content).ok();
427        Err(Error::ResponseError(ResponseContent { status, content, entity }))
428    }
429}
430
431pub async fn put_download_client_bulk(configuration: &configuration::Configuration, download_client_bulk_resource: Option<models::DownloadClientBulkResource>) -> Result<models::DownloadClientResource, Error<PutDownloadClientBulkError>> {
432    // add a prefix to parameters to efficiently prevent name collisions
433    let p_body_download_client_bulk_resource = download_client_bulk_resource;
434
435    let uri_str = format!("{}/api/v1/downloadclient/bulk", configuration.base_path);
436    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
437
438    if let Some(ref apikey) = configuration.api_key {
439        let key = apikey.key.clone();
440        let value = match apikey.prefix {
441            Some(ref prefix) => format!("{} {}", prefix, key),
442            None => key,
443        };
444        req_builder = req_builder.query(&[("apikey", value)]);
445    }
446    if let Some(ref user_agent) = configuration.user_agent {
447        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
448    }
449    if let Some(ref apikey) = configuration.api_key {
450        let key = apikey.key.clone();
451        let value = match apikey.prefix {
452            Some(ref prefix) => format!("{} {}", prefix, key),
453            None => key,
454        };
455        req_builder = req_builder.header("X-Api-Key", value);
456    };
457    req_builder = req_builder.json(&p_body_download_client_bulk_resource);
458
459    let req = req_builder.build()?;
460    let resp = configuration.client.execute(req).await?;
461
462    let status = resp.status();
463    let content_type = resp
464        .headers()
465        .get("content-type")
466        .and_then(|v| v.to_str().ok())
467        .unwrap_or("application/octet-stream");
468    let content_type = super::ContentType::from(content_type);
469
470    if !status.is_client_error() && !status.is_server_error() {
471        let content = resp.text().await?;
472        match content_type {
473            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
474            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DownloadClientResource`"))),
475            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DownloadClientResource`")))),
476        }
477    } else {
478        let content = resp.text().await?;
479        let entity: Option<PutDownloadClientBulkError> = serde_json::from_str(&content).ok();
480        Err(Error::ResponseError(ResponseContent { status, content, entity }))
481    }
482}
483
484pub async fn test_download_client(configuration: &configuration::Configuration, force_test: Option<bool>, download_client_resource: Option<models::DownloadClientResource>) -> Result<(), Error<TestDownloadClientError>> {
485    // add a prefix to parameters to efficiently prevent name collisions
486    let p_query_force_test = force_test;
487    let p_body_download_client_resource = download_client_resource;
488
489    let uri_str = format!("{}/api/v1/downloadclient/test", configuration.base_path);
490    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
491
492    if let Some(ref param_value) = p_query_force_test {
493        req_builder = req_builder.query(&[("forceTest", &param_value.to_string())]);
494    }
495    if let Some(ref apikey) = configuration.api_key {
496        let key = apikey.key.clone();
497        let value = match apikey.prefix {
498            Some(ref prefix) => format!("{} {}", prefix, key),
499            None => key,
500        };
501        req_builder = req_builder.query(&[("apikey", value)]);
502    }
503    if let Some(ref user_agent) = configuration.user_agent {
504        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
505    }
506    if let Some(ref apikey) = configuration.api_key {
507        let key = apikey.key.clone();
508        let value = match apikey.prefix {
509            Some(ref prefix) => format!("{} {}", prefix, key),
510            None => key,
511        };
512        req_builder = req_builder.header("X-Api-Key", value);
513    };
514    req_builder = req_builder.json(&p_body_download_client_resource);
515
516    let req = req_builder.build()?;
517    let resp = configuration.client.execute(req).await?;
518
519    let status = resp.status();
520
521    if !status.is_client_error() && !status.is_server_error() {
522        Ok(())
523    } else {
524        let content = resp.text().await?;
525        let entity: Option<TestDownloadClientError> = serde_json::from_str(&content).ok();
526        Err(Error::ResponseError(ResponseContent { status, content, entity }))
527    }
528}
529
530pub async fn testall_download_client(configuration: &configuration::Configuration, ) -> Result<(), Error<TestallDownloadClientError>> {
531
532    let uri_str = format!("{}/api/v1/downloadclient/testall", configuration.base_path);
533    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
534
535    if let Some(ref apikey) = configuration.api_key {
536        let key = apikey.key.clone();
537        let value = match apikey.prefix {
538            Some(ref prefix) => format!("{} {}", prefix, key),
539            None => key,
540        };
541        req_builder = req_builder.query(&[("apikey", value)]);
542    }
543    if let Some(ref user_agent) = configuration.user_agent {
544        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
545    }
546    if let Some(ref apikey) = configuration.api_key {
547        let key = apikey.key.clone();
548        let value = match apikey.prefix {
549            Some(ref prefix) => format!("{} {}", prefix, key),
550            None => key,
551        };
552        req_builder = req_builder.header("X-Api-Key", value);
553    };
554
555    let req = req_builder.build()?;
556    let resp = configuration.client.execute(req).await?;
557
558    let status = resp.status();
559
560    if !status.is_client_error() && !status.is_server_error() {
561        Ok(())
562    } else {
563        let content = resp.text().await?;
564        let entity: Option<TestallDownloadClientError> = serde_json::from_str(&content).ok();
565        Err(Error::ResponseError(ResponseContent { status, content, entity }))
566    }
567}
568
569pub async fn update_download_client(configuration: &configuration::Configuration, id: &str, force_save: Option<bool>, download_client_resource: Option<models::DownloadClientResource>) -> Result<models::DownloadClientResource, Error<UpdateDownloadClientError>> {
570    // add a prefix to parameters to efficiently prevent name collisions
571    let p_path_id = id;
572    let p_query_force_save = force_save;
573    let p_body_download_client_resource = download_client_resource;
574
575    let uri_str = format!("{}/api/v1/downloadclient/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
576    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
577
578    if let Some(ref param_value) = p_query_force_save {
579        req_builder = req_builder.query(&[("forceSave", &param_value.to_string())]);
580    }
581    if let Some(ref apikey) = configuration.api_key {
582        let key = apikey.key.clone();
583        let value = match apikey.prefix {
584            Some(ref prefix) => format!("{} {}", prefix, key),
585            None => key,
586        };
587        req_builder = req_builder.query(&[("apikey", value)]);
588    }
589    if let Some(ref user_agent) = configuration.user_agent {
590        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
591    }
592    if let Some(ref apikey) = configuration.api_key {
593        let key = apikey.key.clone();
594        let value = match apikey.prefix {
595            Some(ref prefix) => format!("{} {}", prefix, key),
596            None => key,
597        };
598        req_builder = req_builder.header("X-Api-Key", value);
599    };
600    req_builder = req_builder.json(&p_body_download_client_resource);
601
602    let req = req_builder.build()?;
603    let resp = configuration.client.execute(req).await?;
604
605    let status = resp.status();
606    let content_type = resp
607        .headers()
608        .get("content-type")
609        .and_then(|v| v.to_str().ok())
610        .unwrap_or("application/octet-stream");
611    let content_type = super::ContentType::from(content_type);
612
613    if !status.is_client_error() && !status.is_server_error() {
614        let content = resp.text().await?;
615        match content_type {
616            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
617            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DownloadClientResource`"))),
618            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DownloadClientResource`")))),
619        }
620    } else {
621        let content = resp.text().await?;
622        let entity: Option<UpdateDownloadClientError> = serde_json::from_str(&content).ok();
623        Err(Error::ResponseError(ResponseContent { status, content, entity }))
624    }
625}
626