Skip to main content

clientapi_pbs/apis/
config_remote_api.rs

1/*
2 * Proxmox Backup Server API
3 *
4 * Generated from apidoc.js. NOT an official Proxmox specification. See https://pbs.proxmox.com/docs/api-viewer/ for the upstream documentation.
5 *
6 * The version of the OpenAPI document: 9.x
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 [`config_remote_create_remote`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ConfigRemoteCreateRemoteError {
22    Status400(models::PbsError),
23    Status401(models::PbsError),
24    Status403(models::PbsError),
25    Status404(models::PbsError),
26    Status500(models::PbsError),
27    Status501(models::PbsError),
28    Status503(models::PbsError),
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`config_remote_delete_remote`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ConfigRemoteDeleteRemoteError {
36    Status400(models::PbsError),
37    Status401(models::PbsError),
38    Status403(models::PbsError),
39    Status404(models::PbsError),
40    Status500(models::PbsError),
41    Status501(models::PbsError),
42    Status503(models::PbsError),
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`config_remote_get_config_remote_by_name`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ConfigRemoteGetConfigRemoteByNameError {
50    Status400(models::PbsError),
51    Status401(models::PbsError),
52    Status403(models::PbsError),
53    Status404(models::PbsError),
54    Status500(models::PbsError),
55    Status501(models::PbsError),
56    Status503(models::PbsError),
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`config_remote_get_config_remote_by_name_scan_by_store`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum ConfigRemoteGetConfigRemoteByNameScanByStoreError {
64    Status400(models::PbsError),
65    Status401(models::PbsError),
66    Status403(models::PbsError),
67    Status404(models::PbsError),
68    Status500(models::PbsError),
69    Status501(models::PbsError),
70    Status503(models::PbsError),
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`config_remote_get_groups`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum ConfigRemoteGetGroupsError {
78    Status400(models::PbsError),
79    Status401(models::PbsError),
80    Status403(models::PbsError),
81    Status404(models::PbsError),
82    Status500(models::PbsError),
83    Status501(models::PbsError),
84    Status503(models::PbsError),
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`config_remote_get_namespaces`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum ConfigRemoteGetNamespacesError {
92    Status400(models::PbsError),
93    Status401(models::PbsError),
94    Status403(models::PbsError),
95    Status404(models::PbsError),
96    Status500(models::PbsError),
97    Status501(models::PbsError),
98    Status503(models::PbsError),
99    UnknownValue(serde_json::Value),
100}
101
102/// struct for typed errors of method [`config_remote_get_remote`]
103#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum ConfigRemoteGetRemoteError {
106    Status400(models::PbsError),
107    Status401(models::PbsError),
108    Status403(models::PbsError),
109    Status404(models::PbsError),
110    Status500(models::PbsError),
111    Status501(models::PbsError),
112    Status503(models::PbsError),
113    UnknownValue(serde_json::Value),
114}
115
116/// struct for typed errors of method [`config_remote_get_scan`]
117#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum ConfigRemoteGetScanError {
120    Status400(models::PbsError),
121    Status401(models::PbsError),
122    Status403(models::PbsError),
123    Status404(models::PbsError),
124    Status500(models::PbsError),
125    Status501(models::PbsError),
126    Status503(models::PbsError),
127    UnknownValue(serde_json::Value),
128}
129
130/// struct for typed errors of method [`config_remote_update_remote`]
131#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum ConfigRemoteUpdateRemoteError {
134    Status400(models::PbsError),
135    Status401(models::PbsError),
136    Status403(models::PbsError),
137    Status404(models::PbsError),
138    Status500(models::PbsError),
139    Status501(models::PbsError),
140    Status503(models::PbsError),
141    UnknownValue(serde_json::Value),
142}
143
144
145/// Create new remote.
146pub async fn config_remote_create_remote(configuration: &configuration::Configuration, config_remote_create_remote_request: models::ConfigRemoteCreateRemoteRequest) -> Result<models::ConfigRemoteCreateRemoteResponse, Error<ConfigRemoteCreateRemoteError>> {
147    // add a prefix to parameters to efficiently prevent name collisions
148    let p_body_config_remote_create_remote_request = config_remote_create_remote_request;
149
150    let uri_str = format!("{}/config/remote", configuration.base_path);
151    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
152
153    if let Some(ref user_agent) = configuration.user_agent {
154        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
155    }
156    if let Some(ref apikey) = configuration.api_key {
157        let key = apikey.key.clone();
158        let value = match apikey.prefix {
159            Some(ref prefix) => format!("{} {}", prefix, key),
160            None => key,
161        };
162        req_builder = req_builder.header("Authorization", value);
163    };
164    if let Some(ref apikey) = configuration.api_key {
165        let key = apikey.key.clone();
166        let value = match apikey.prefix {
167            Some(ref prefix) => format!("{} {}", prefix, key),
168            None => key,
169        };
170        req_builder = req_builder.header("CSRFPreventionToken", value);
171    };
172    req_builder = req_builder.json(&p_body_config_remote_create_remote_request);
173
174    let req = req_builder.build()?;
175    let resp = configuration.client.execute(req).await?;
176
177    let status = resp.status();
178    let content_type = resp
179        .headers()
180        .get("content-type")
181        .and_then(|v| v.to_str().ok())
182        .unwrap_or("application/octet-stream");
183    let content_type = super::ContentType::from(content_type);
184
185    if !status.is_client_error() && !status.is_server_error() {
186        let content = resp.text().await?;
187        match content_type {
188            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
189            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigRemoteCreateRemoteResponse`"))),
190            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::ConfigRemoteCreateRemoteResponse`")))),
191        }
192    } else {
193        let content = resp.text().await?;
194        let entity: Option<ConfigRemoteCreateRemoteError> = serde_json::from_str(&content).ok();
195        Err(Error::ResponseError(ResponseContent { status, content, entity }))
196    }
197}
198
199/// Remove a remote from the configuration file.
200pub async fn config_remote_delete_remote(configuration: &configuration::Configuration, name: &str, digest: Option<&str>) -> Result<models::ConfigRemoteDeleteRemoteResponse, Error<ConfigRemoteDeleteRemoteError>> {
201    // add a prefix to parameters to efficiently prevent name collisions
202    let p_path_name = name;
203    let p_query_digest = digest;
204
205    let uri_str = format!("{}/config/remote/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
206    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
207
208    if let Some(ref param_value) = p_query_digest {
209        req_builder = req_builder.query(&[("digest", &param_value.to_string())]);
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("Authorization", value);
221    };
222    if let Some(ref apikey) = configuration.api_key {
223        let key = apikey.key.clone();
224        let value = match apikey.prefix {
225            Some(ref prefix) => format!("{} {}", prefix, key),
226            None => key,
227        };
228        req_builder = req_builder.header("CSRFPreventionToken", value);
229    };
230
231    let req = req_builder.build()?;
232    let resp = configuration.client.execute(req).await?;
233
234    let status = resp.status();
235    let content_type = resp
236        .headers()
237        .get("content-type")
238        .and_then(|v| v.to_str().ok())
239        .unwrap_or("application/octet-stream");
240    let content_type = super::ContentType::from(content_type);
241
242    if !status.is_client_error() && !status.is_server_error() {
243        let content = resp.text().await?;
244        match content_type {
245            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
246            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigRemoteDeleteRemoteResponse`"))),
247            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::ConfigRemoteDeleteRemoteResponse`")))),
248        }
249    } else {
250        let content = resp.text().await?;
251        let entity: Option<ConfigRemoteDeleteRemoteError> = serde_json::from_str(&content).ok();
252        Err(Error::ResponseError(ResponseContent { status, content, entity }))
253    }
254}
255
256/// Read remote configuration data.
257pub async fn config_remote_get_config_remote_by_name(configuration: &configuration::Configuration, name: &str) -> Result<models::ConfigRemoteGetConfigRemoteByNameResponse, Error<ConfigRemoteGetConfigRemoteByNameError>> {
258    // add a prefix to parameters to efficiently prevent name collisions
259    let p_path_name = name;
260
261    let uri_str = format!("{}/config/remote/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
262    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
263
264    if let Some(ref user_agent) = configuration.user_agent {
265        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
266    }
267    if let Some(ref apikey) = configuration.api_key {
268        let key = apikey.key.clone();
269        let value = match apikey.prefix {
270            Some(ref prefix) => format!("{} {}", prefix, key),
271            None => key,
272        };
273        req_builder = req_builder.header("Authorization", value);
274    };
275    if let Some(ref apikey) = configuration.api_key {
276        let key = apikey.key.clone();
277        let value = match apikey.prefix {
278            Some(ref prefix) => format!("{} {}", prefix, key),
279            None => key,
280        };
281        req_builder = req_builder.header("CSRFPreventionToken", value);
282    };
283
284    let req = req_builder.build()?;
285    let resp = configuration.client.execute(req).await?;
286
287    let status = resp.status();
288    let content_type = resp
289        .headers()
290        .get("content-type")
291        .and_then(|v| v.to_str().ok())
292        .unwrap_or("application/octet-stream");
293    let content_type = super::ContentType::from(content_type);
294
295    if !status.is_client_error() && !status.is_server_error() {
296        let content = resp.text().await?;
297        match content_type {
298            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
299            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigRemoteGetConfigRemoteByNameResponse`"))),
300            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::ConfigRemoteGetConfigRemoteByNameResponse`")))),
301        }
302    } else {
303        let content = resp.text().await?;
304        let entity: Option<ConfigRemoteGetConfigRemoteByNameError> = serde_json::from_str(&content).ok();
305        Err(Error::ResponseError(ResponseContent { status, content, entity }))
306    }
307}
308
309/// Directory index.
310pub async fn config_remote_get_config_remote_by_name_scan_by_store(configuration: &configuration::Configuration, name: &str, store: &str) -> Result<models::ConfigRemoteGetConfigRemoteByNameScanByStoreResponse, Error<ConfigRemoteGetConfigRemoteByNameScanByStoreError>> {
311    // add a prefix to parameters to efficiently prevent name collisions
312    let p_path_name = name;
313    let p_path_store = store;
314
315    let uri_str = format!("{}/config/remote/{name}/scan/{store}", configuration.base_path, name=crate::apis::urlencode(p_path_name), store=crate::apis::urlencode(p_path_store));
316    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
317
318    if let Some(ref user_agent) = configuration.user_agent {
319        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
320    }
321    if let Some(ref apikey) = configuration.api_key {
322        let key = apikey.key.clone();
323        let value = match apikey.prefix {
324            Some(ref prefix) => format!("{} {}", prefix, key),
325            None => key,
326        };
327        req_builder = req_builder.header("Authorization", value);
328    };
329    if let Some(ref apikey) = configuration.api_key {
330        let key = apikey.key.clone();
331        let value = match apikey.prefix {
332            Some(ref prefix) => format!("{} {}", prefix, key),
333            None => key,
334        };
335        req_builder = req_builder.header("CSRFPreventionToken", value);
336    };
337
338    let req = req_builder.build()?;
339    let resp = configuration.client.execute(req).await?;
340
341    let status = resp.status();
342    let content_type = resp
343        .headers()
344        .get("content-type")
345        .and_then(|v| v.to_str().ok())
346        .unwrap_or("application/octet-stream");
347    let content_type = super::ContentType::from(content_type);
348
349    if !status.is_client_error() && !status.is_server_error() {
350        let content = resp.text().await?;
351        match content_type {
352            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
353            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigRemoteGetConfigRemoteByNameScanByStoreResponse`"))),
354            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::ConfigRemoteGetConfigRemoteByNameScanByStoreResponse`")))),
355        }
356    } else {
357        let content = resp.text().await?;
358        let entity: Option<ConfigRemoteGetConfigRemoteByNameScanByStoreError> = serde_json::from_str(&content).ok();
359        Err(Error::ResponseError(ResponseContent { status, content, entity }))
360    }
361}
362
363/// List groups of a remote.cfg entry's datastore
364pub async fn config_remote_get_groups(configuration: &configuration::Configuration, name: &str, store: &str, namespace: Option<&str>) -> Result<models::ConfigRemoteGetGroupsResponse, Error<ConfigRemoteGetGroupsError>> {
365    // add a prefix to parameters to efficiently prevent name collisions
366    let p_path_name = name;
367    let p_path_store = store;
368    let p_query_namespace = namespace;
369
370    let uri_str = format!("{}/config/remote/{name}/scan/{store}/groups", configuration.base_path, name=crate::apis::urlencode(p_path_name), store=crate::apis::urlencode(p_path_store));
371    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
372
373    if let Some(ref param_value) = p_query_namespace {
374        req_builder = req_builder.query(&[("namespace", &param_value.to_string())]);
375    }
376    if let Some(ref user_agent) = configuration.user_agent {
377        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
378    }
379    if let Some(ref apikey) = configuration.api_key {
380        let key = apikey.key.clone();
381        let value = match apikey.prefix {
382            Some(ref prefix) => format!("{} {}", prefix, key),
383            None => key,
384        };
385        req_builder = req_builder.header("Authorization", value);
386    };
387    if let Some(ref apikey) = configuration.api_key {
388        let key = apikey.key.clone();
389        let value = match apikey.prefix {
390            Some(ref prefix) => format!("{} {}", prefix, key),
391            None => key,
392        };
393        req_builder = req_builder.header("CSRFPreventionToken", value);
394    };
395
396    let req = req_builder.build()?;
397    let resp = configuration.client.execute(req).await?;
398
399    let status = resp.status();
400    let content_type = resp
401        .headers()
402        .get("content-type")
403        .and_then(|v| v.to_str().ok())
404        .unwrap_or("application/octet-stream");
405    let content_type = super::ContentType::from(content_type);
406
407    if !status.is_client_error() && !status.is_server_error() {
408        let content = resp.text().await?;
409        match content_type {
410            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
411            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigRemoteGetGroupsResponse`"))),
412            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::ConfigRemoteGetGroupsResponse`")))),
413        }
414    } else {
415        let content = resp.text().await?;
416        let entity: Option<ConfigRemoteGetGroupsError> = serde_json::from_str(&content).ok();
417        Err(Error::ResponseError(ResponseContent { status, content, entity }))
418    }
419}
420
421/// List namespaces of a datastore of a remote.cfg entry
422pub async fn config_remote_get_namespaces(configuration: &configuration::Configuration, name: &str, store: &str) -> Result<models::ConfigRemoteGetNamespacesResponse, Error<ConfigRemoteGetNamespacesError>> {
423    // add a prefix to parameters to efficiently prevent name collisions
424    let p_path_name = name;
425    let p_path_store = store;
426
427    let uri_str = format!("{}/config/remote/{name}/scan/{store}/namespaces", configuration.base_path, name=crate::apis::urlencode(p_path_name), store=crate::apis::urlencode(p_path_store));
428    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
429
430    if let Some(ref user_agent) = configuration.user_agent {
431        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
432    }
433    if let Some(ref apikey) = configuration.api_key {
434        let key = apikey.key.clone();
435        let value = match apikey.prefix {
436            Some(ref prefix) => format!("{} {}", prefix, key),
437            None => key,
438        };
439        req_builder = req_builder.header("Authorization", value);
440    };
441    if let Some(ref apikey) = configuration.api_key {
442        let key = apikey.key.clone();
443        let value = match apikey.prefix {
444            Some(ref prefix) => format!("{} {}", prefix, key),
445            None => key,
446        };
447        req_builder = req_builder.header("CSRFPreventionToken", value);
448    };
449
450    let req = req_builder.build()?;
451    let resp = configuration.client.execute(req).await?;
452
453    let status = resp.status();
454    let content_type = resp
455        .headers()
456        .get("content-type")
457        .and_then(|v| v.to_str().ok())
458        .unwrap_or("application/octet-stream");
459    let content_type = super::ContentType::from(content_type);
460
461    if !status.is_client_error() && !status.is_server_error() {
462        let content = resp.text().await?;
463        match content_type {
464            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
465            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigRemoteGetNamespacesResponse`"))),
466            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::ConfigRemoteGetNamespacesResponse`")))),
467        }
468    } else {
469        let content = resp.text().await?;
470        let entity: Option<ConfigRemoteGetNamespacesError> = serde_json::from_str(&content).ok();
471        Err(Error::ResponseError(ResponseContent { status, content, entity }))
472    }
473}
474
475/// List all remotes  Permissions: List configured remotes filtered by Remote.Audit privileges
476pub async fn config_remote_get_remote(configuration: &configuration::Configuration, ) -> Result<models::ConfigRemoteGetRemoteResponse, Error<ConfigRemoteGetRemoteError>> {
477
478    let uri_str = format!("{}/config/remote", configuration.base_path);
479    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
480
481    if let Some(ref user_agent) = configuration.user_agent {
482        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
483    }
484    if let Some(ref apikey) = configuration.api_key {
485        let key = apikey.key.clone();
486        let value = match apikey.prefix {
487            Some(ref prefix) => format!("{} {}", prefix, key),
488            None => key,
489        };
490        req_builder = req_builder.header("Authorization", value);
491    };
492    if let Some(ref apikey) = configuration.api_key {
493        let key = apikey.key.clone();
494        let value = match apikey.prefix {
495            Some(ref prefix) => format!("{} {}", prefix, key),
496            None => key,
497        };
498        req_builder = req_builder.header("CSRFPreventionToken", value);
499    };
500
501    let req = req_builder.build()?;
502    let resp = configuration.client.execute(req).await?;
503
504    let status = resp.status();
505    let content_type = resp
506        .headers()
507        .get("content-type")
508        .and_then(|v| v.to_str().ok())
509        .unwrap_or("application/octet-stream");
510    let content_type = super::ContentType::from(content_type);
511
512    if !status.is_client_error() && !status.is_server_error() {
513        let content = resp.text().await?;
514        match content_type {
515            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
516            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigRemoteGetRemoteResponse`"))),
517            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::ConfigRemoteGetRemoteResponse`")))),
518        }
519    } else {
520        let content = resp.text().await?;
521        let entity: Option<ConfigRemoteGetRemoteError> = serde_json::from_str(&content).ok();
522        Err(Error::ResponseError(ResponseContent { status, content, entity }))
523    }
524}
525
526/// List datastores of a remote.cfg entry
527pub async fn config_remote_get_scan(configuration: &configuration::Configuration, name: &str) -> Result<models::ConfigRemoteGetScanResponse, Error<ConfigRemoteGetScanError>> {
528    // add a prefix to parameters to efficiently prevent name collisions
529    let p_path_name = name;
530
531    let uri_str = format!("{}/config/remote/{name}/scan", configuration.base_path, name=crate::apis::urlencode(p_path_name));
532    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
533
534    if let Some(ref user_agent) = configuration.user_agent {
535        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
536    }
537    if let Some(ref apikey) = configuration.api_key {
538        let key = apikey.key.clone();
539        let value = match apikey.prefix {
540            Some(ref prefix) => format!("{} {}", prefix, key),
541            None => key,
542        };
543        req_builder = req_builder.header("Authorization", value);
544    };
545    if let Some(ref apikey) = configuration.api_key {
546        let key = apikey.key.clone();
547        let value = match apikey.prefix {
548            Some(ref prefix) => format!("{} {}", prefix, key),
549            None => key,
550        };
551        req_builder = req_builder.header("CSRFPreventionToken", value);
552    };
553
554    let req = req_builder.build()?;
555    let resp = configuration.client.execute(req).await?;
556
557    let status = resp.status();
558    let content_type = resp
559        .headers()
560        .get("content-type")
561        .and_then(|v| v.to_str().ok())
562        .unwrap_or("application/octet-stream");
563    let content_type = super::ContentType::from(content_type);
564
565    if !status.is_client_error() && !status.is_server_error() {
566        let content = resp.text().await?;
567        match content_type {
568            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
569            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigRemoteGetScanResponse`"))),
570            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::ConfigRemoteGetScanResponse`")))),
571        }
572    } else {
573        let content = resp.text().await?;
574        let entity: Option<ConfigRemoteGetScanError> = serde_json::from_str(&content).ok();
575        Err(Error::ResponseError(ResponseContent { status, content, entity }))
576    }
577}
578
579/// Update remote configuration.
580pub async fn config_remote_update_remote(configuration: &configuration::Configuration, name: &str, config_remote_update_remote_request: Option<models::ConfigRemoteUpdateRemoteRequest>) -> Result<models::ConfigRemoteUpdateRemoteResponse, Error<ConfigRemoteUpdateRemoteError>> {
581    // add a prefix to parameters to efficiently prevent name collisions
582    let p_path_name = name;
583    let p_body_config_remote_update_remote_request = config_remote_update_remote_request;
584
585    let uri_str = format!("{}/config/remote/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
586    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
587
588    if let Some(ref user_agent) = configuration.user_agent {
589        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
590    }
591    if let Some(ref apikey) = configuration.api_key {
592        let key = apikey.key.clone();
593        let value = match apikey.prefix {
594            Some(ref prefix) => format!("{} {}", prefix, key),
595            None => key,
596        };
597        req_builder = req_builder.header("Authorization", value);
598    };
599    if let Some(ref apikey) = configuration.api_key {
600        let key = apikey.key.clone();
601        let value = match apikey.prefix {
602            Some(ref prefix) => format!("{} {}", prefix, key),
603            None => key,
604        };
605        req_builder = req_builder.header("CSRFPreventionToken", value);
606    };
607    req_builder = req_builder.json(&p_body_config_remote_update_remote_request);
608
609    let req = req_builder.build()?;
610    let resp = configuration.client.execute(req).await?;
611
612    let status = resp.status();
613    let content_type = resp
614        .headers()
615        .get("content-type")
616        .and_then(|v| v.to_str().ok())
617        .unwrap_or("application/octet-stream");
618    let content_type = super::ContentType::from(content_type);
619
620    if !status.is_client_error() && !status.is_server_error() {
621        let content = resp.text().await?;
622        match content_type {
623            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
624            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigRemoteUpdateRemoteResponse`"))),
625            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::ConfigRemoteUpdateRemoteResponse`")))),
626        }
627    } else {
628        let content = resp.text().await?;
629        let entity: Option<ConfigRemoteUpdateRemoteError> = serde_json::from_str(&content).ok();
630        Err(Error::ResponseError(ResponseContent { status, content, entity }))
631    }
632}
633