Skip to main content

clientapi_pbs/apis/
config_metrics_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_metrics_create_influxdb_http`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ConfigMetricsCreateInfluxdbHttpError {
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_metrics_create_influxdb_udp`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ConfigMetricsCreateInfluxdbUdpError {
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_metrics_delete_influxdb_http`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ConfigMetricsDeleteInfluxdbHttpError {
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_metrics_delete_influxdb_udp`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum ConfigMetricsDeleteInfluxdbUdpError {
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_metrics_get_config_metrics_influxdb_http_by_name`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum ConfigMetricsGetConfigMetricsInfluxdbHttpByNameError {
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_metrics_get_config_metrics_influxdb_udp_by_name`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum ConfigMetricsGetConfigMetricsInfluxdbUdpByNameError {
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_metrics_get_influxdb_http`]
103#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum ConfigMetricsGetInfluxdbHttpError {
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_metrics_get_influxdb_udp`]
117#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum ConfigMetricsGetInfluxdbUdpError {
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_metrics_get_metrics`]
131#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum ConfigMetricsGetMetricsError {
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/// struct for typed errors of method [`config_metrics_update_influxdb_http`]
145#[derive(Debug, Clone, Serialize, Deserialize)]
146#[serde(untagged)]
147pub enum ConfigMetricsUpdateInfluxdbHttpError {
148    Status400(models::PbsError),
149    Status401(models::PbsError),
150    Status403(models::PbsError),
151    Status404(models::PbsError),
152    Status500(models::PbsError),
153    Status501(models::PbsError),
154    Status503(models::PbsError),
155    UnknownValue(serde_json::Value),
156}
157
158/// struct for typed errors of method [`config_metrics_update_influxdb_udp`]
159#[derive(Debug, Clone, Serialize, Deserialize)]
160#[serde(untagged)]
161pub enum ConfigMetricsUpdateInfluxdbUdpError {
162    Status400(models::PbsError),
163    Status401(models::PbsError),
164    Status403(models::PbsError),
165    Status404(models::PbsError),
166    Status500(models::PbsError),
167    Status501(models::PbsError),
168    Status503(models::PbsError),
169    UnknownValue(serde_json::Value),
170}
171
172
173/// Create a new InfluxDB http server configuration
174pub async fn config_metrics_create_influxdb_http(configuration: &configuration::Configuration, config_metrics_create_influxdb_http_request: models::ConfigMetricsCreateInfluxdbHttpRequest) -> Result<models::ConfigMetricsCreateInfluxdbHttpResponse, Error<ConfigMetricsCreateInfluxdbHttpError>> {
175    // add a prefix to parameters to efficiently prevent name collisions
176    let p_body_config_metrics_create_influxdb_http_request = config_metrics_create_influxdb_http_request;
177
178    let uri_str = format!("{}/config/metrics/influxdb-http", configuration.base_path);
179    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
180
181    if let Some(ref user_agent) = configuration.user_agent {
182        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
183    }
184    if let Some(ref apikey) = configuration.api_key {
185        let key = apikey.key.clone();
186        let value = match apikey.prefix {
187            Some(ref prefix) => format!("{} {}", prefix, key),
188            None => key,
189        };
190        req_builder = req_builder.header("Authorization", value);
191    };
192    if let Some(ref apikey) = configuration.api_key {
193        let key = apikey.key.clone();
194        let value = match apikey.prefix {
195            Some(ref prefix) => format!("{} {}", prefix, key),
196            None => key,
197        };
198        req_builder = req_builder.header("CSRFPreventionToken", value);
199    };
200    req_builder = req_builder.json(&p_body_config_metrics_create_influxdb_http_request);
201
202    let req = req_builder.build()?;
203    let resp = configuration.client.execute(req).await?;
204
205    let status = resp.status();
206    let content_type = resp
207        .headers()
208        .get("content-type")
209        .and_then(|v| v.to_str().ok())
210        .unwrap_or("application/octet-stream");
211    let content_type = super::ContentType::from(content_type);
212
213    if !status.is_client_error() && !status.is_server_error() {
214        let content = resp.text().await?;
215        match content_type {
216            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
217            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigMetricsCreateInfluxdbHttpResponse`"))),
218            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::ConfigMetricsCreateInfluxdbHttpResponse`")))),
219        }
220    } else {
221        let content = resp.text().await?;
222        let entity: Option<ConfigMetricsCreateInfluxdbHttpError> = serde_json::from_str(&content).ok();
223        Err(Error::ResponseError(ResponseContent { status, content, entity }))
224    }
225}
226
227/// Create a new InfluxDB udp server configuration
228pub async fn config_metrics_create_influxdb_udp(configuration: &configuration::Configuration, config_metrics_create_influxdb_udp_request: models::ConfigMetricsCreateInfluxdbUdpRequest) -> Result<models::ConfigMetricsCreateInfluxdbUdpResponse, Error<ConfigMetricsCreateInfluxdbUdpError>> {
229    // add a prefix to parameters to efficiently prevent name collisions
230    let p_body_config_metrics_create_influxdb_udp_request = config_metrics_create_influxdb_udp_request;
231
232    let uri_str = format!("{}/config/metrics/influxdb-udp", configuration.base_path);
233    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
234
235    if let Some(ref user_agent) = configuration.user_agent {
236        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
237    }
238    if let Some(ref apikey) = configuration.api_key {
239        let key = apikey.key.clone();
240        let value = match apikey.prefix {
241            Some(ref prefix) => format!("{} {}", prefix, key),
242            None => key,
243        };
244        req_builder = req_builder.header("Authorization", value);
245    };
246    if let Some(ref apikey) = configuration.api_key {
247        let key = apikey.key.clone();
248        let value = match apikey.prefix {
249            Some(ref prefix) => format!("{} {}", prefix, key),
250            None => key,
251        };
252        req_builder = req_builder.header("CSRFPreventionToken", value);
253    };
254    req_builder = req_builder.json(&p_body_config_metrics_create_influxdb_udp_request);
255
256    let req = req_builder.build()?;
257    let resp = configuration.client.execute(req).await?;
258
259    let status = resp.status();
260    let content_type = resp
261        .headers()
262        .get("content-type")
263        .and_then(|v| v.to_str().ok())
264        .unwrap_or("application/octet-stream");
265    let content_type = super::ContentType::from(content_type);
266
267    if !status.is_client_error() && !status.is_server_error() {
268        let content = resp.text().await?;
269        match content_type {
270            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
271            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigMetricsCreateInfluxdbUdpResponse`"))),
272            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::ConfigMetricsCreateInfluxdbUdpResponse`")))),
273        }
274    } else {
275        let content = resp.text().await?;
276        let entity: Option<ConfigMetricsCreateInfluxdbUdpError> = serde_json::from_str(&content).ok();
277        Err(Error::ResponseError(ResponseContent { status, content, entity }))
278    }
279}
280
281/// Remove a InfluxDB http server configuration
282pub async fn config_metrics_delete_influxdb_http(configuration: &configuration::Configuration, name: &str, digest: Option<&str>) -> Result<models::ConfigMetricsDeleteInfluxdbHttpResponse, Error<ConfigMetricsDeleteInfluxdbHttpError>> {
283    // add a prefix to parameters to efficiently prevent name collisions
284    let p_path_name = name;
285    let p_query_digest = digest;
286
287    let uri_str = format!("{}/config/metrics/influxdb-http/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
288    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
289
290    if let Some(ref param_value) = p_query_digest {
291        req_builder = req_builder.query(&[("digest", &param_value.to_string())]);
292    }
293    if let Some(ref user_agent) = configuration.user_agent {
294        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
295    }
296    if let Some(ref apikey) = configuration.api_key {
297        let key = apikey.key.clone();
298        let value = match apikey.prefix {
299            Some(ref prefix) => format!("{} {}", prefix, key),
300            None => key,
301        };
302        req_builder = req_builder.header("Authorization", value);
303    };
304    if let Some(ref apikey) = configuration.api_key {
305        let key = apikey.key.clone();
306        let value = match apikey.prefix {
307            Some(ref prefix) => format!("{} {}", prefix, key),
308            None => key,
309        };
310        req_builder = req_builder.header("CSRFPreventionToken", value);
311    };
312
313    let req = req_builder.build()?;
314    let resp = configuration.client.execute(req).await?;
315
316    let status = resp.status();
317    let content_type = resp
318        .headers()
319        .get("content-type")
320        .and_then(|v| v.to_str().ok())
321        .unwrap_or("application/octet-stream");
322    let content_type = super::ContentType::from(content_type);
323
324    if !status.is_client_error() && !status.is_server_error() {
325        let content = resp.text().await?;
326        match content_type {
327            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
328            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigMetricsDeleteInfluxdbHttpResponse`"))),
329            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::ConfigMetricsDeleteInfluxdbHttpResponse`")))),
330        }
331    } else {
332        let content = resp.text().await?;
333        let entity: Option<ConfigMetricsDeleteInfluxdbHttpError> = serde_json::from_str(&content).ok();
334        Err(Error::ResponseError(ResponseContent { status, content, entity }))
335    }
336}
337
338/// Remove a InfluxDB udp server configuration
339pub async fn config_metrics_delete_influxdb_udp(configuration: &configuration::Configuration, name: &str, digest: Option<&str>) -> Result<models::ConfigMetricsDeleteInfluxdbUdpResponse, Error<ConfigMetricsDeleteInfluxdbUdpError>> {
340    // add a prefix to parameters to efficiently prevent name collisions
341    let p_path_name = name;
342    let p_query_digest = digest;
343
344    let uri_str = format!("{}/config/metrics/influxdb-udp/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
345    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
346
347    if let Some(ref param_value) = p_query_digest {
348        req_builder = req_builder.query(&[("digest", &param_value.to_string())]);
349    }
350    if let Some(ref user_agent) = configuration.user_agent {
351        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
352    }
353    if let Some(ref apikey) = configuration.api_key {
354        let key = apikey.key.clone();
355        let value = match apikey.prefix {
356            Some(ref prefix) => format!("{} {}", prefix, key),
357            None => key,
358        };
359        req_builder = req_builder.header("Authorization", value);
360    };
361    if let Some(ref apikey) = configuration.api_key {
362        let key = apikey.key.clone();
363        let value = match apikey.prefix {
364            Some(ref prefix) => format!("{} {}", prefix, key),
365            None => key,
366        };
367        req_builder = req_builder.header("CSRFPreventionToken", value);
368    };
369
370    let req = req_builder.build()?;
371    let resp = configuration.client.execute(req).await?;
372
373    let status = resp.status();
374    let content_type = resp
375        .headers()
376        .get("content-type")
377        .and_then(|v| v.to_str().ok())
378        .unwrap_or("application/octet-stream");
379    let content_type = super::ContentType::from(content_type);
380
381    if !status.is_client_error() && !status.is_server_error() {
382        let content = resp.text().await?;
383        match content_type {
384            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
385            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigMetricsDeleteInfluxdbUdpResponse`"))),
386            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::ConfigMetricsDeleteInfluxdbUdpResponse`")))),
387        }
388    } else {
389        let content = resp.text().await?;
390        let entity: Option<ConfigMetricsDeleteInfluxdbUdpError> = serde_json::from_str(&content).ok();
391        Err(Error::ResponseError(ResponseContent { status, content, entity }))
392    }
393}
394
395/// Read the InfluxDB http server configuration
396pub async fn config_metrics_get_config_metrics_influxdb_http_by_name(configuration: &configuration::Configuration, name: &str) -> Result<models::ConfigMetricsGetConfigMetricsInfluxdbHttpByNameResponse, Error<ConfigMetricsGetConfigMetricsInfluxdbHttpByNameError>> {
397    // add a prefix to parameters to efficiently prevent name collisions
398    let p_path_name = name;
399
400    let uri_str = format!("{}/config/metrics/influxdb-http/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
401    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
402
403    if let Some(ref user_agent) = configuration.user_agent {
404        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
405    }
406    if let Some(ref apikey) = configuration.api_key {
407        let key = apikey.key.clone();
408        let value = match apikey.prefix {
409            Some(ref prefix) => format!("{} {}", prefix, key),
410            None => key,
411        };
412        req_builder = req_builder.header("Authorization", value);
413    };
414    if let Some(ref apikey) = configuration.api_key {
415        let key = apikey.key.clone();
416        let value = match apikey.prefix {
417            Some(ref prefix) => format!("{} {}", prefix, key),
418            None => key,
419        };
420        req_builder = req_builder.header("CSRFPreventionToken", value);
421    };
422
423    let req = req_builder.build()?;
424    let resp = configuration.client.execute(req).await?;
425
426    let status = resp.status();
427    let content_type = resp
428        .headers()
429        .get("content-type")
430        .and_then(|v| v.to_str().ok())
431        .unwrap_or("application/octet-stream");
432    let content_type = super::ContentType::from(content_type);
433
434    if !status.is_client_error() && !status.is_server_error() {
435        let content = resp.text().await?;
436        match content_type {
437            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
438            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigMetricsGetConfigMetricsInfluxdbHttpByNameResponse`"))),
439            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::ConfigMetricsGetConfigMetricsInfluxdbHttpByNameResponse`")))),
440        }
441    } else {
442        let content = resp.text().await?;
443        let entity: Option<ConfigMetricsGetConfigMetricsInfluxdbHttpByNameError> = serde_json::from_str(&content).ok();
444        Err(Error::ResponseError(ResponseContent { status, content, entity }))
445    }
446}
447
448/// Read the InfluxDB udp server configuration
449pub async fn config_metrics_get_config_metrics_influxdb_udp_by_name(configuration: &configuration::Configuration, name: &str) -> Result<models::ConfigMetricsGetConfigMetricsInfluxdbUdpByNameResponse, Error<ConfigMetricsGetConfigMetricsInfluxdbUdpByNameError>> {
450    // add a prefix to parameters to efficiently prevent name collisions
451    let p_path_name = name;
452
453    let uri_str = format!("{}/config/metrics/influxdb-udp/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
454    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
455
456    if let Some(ref user_agent) = configuration.user_agent {
457        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
458    }
459    if let Some(ref apikey) = configuration.api_key {
460        let key = apikey.key.clone();
461        let value = match apikey.prefix {
462            Some(ref prefix) => format!("{} {}", prefix, key),
463            None => key,
464        };
465        req_builder = req_builder.header("Authorization", value);
466    };
467    if let Some(ref apikey) = configuration.api_key {
468        let key = apikey.key.clone();
469        let value = match apikey.prefix {
470            Some(ref prefix) => format!("{} {}", prefix, key),
471            None => key,
472        };
473        req_builder = req_builder.header("CSRFPreventionToken", value);
474    };
475
476    let req = req_builder.build()?;
477    let resp = configuration.client.execute(req).await?;
478
479    let status = resp.status();
480    let content_type = resp
481        .headers()
482        .get("content-type")
483        .and_then(|v| v.to_str().ok())
484        .unwrap_or("application/octet-stream");
485    let content_type = super::ContentType::from(content_type);
486
487    if !status.is_client_error() && !status.is_server_error() {
488        let content = resp.text().await?;
489        match content_type {
490            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
491            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigMetricsGetConfigMetricsInfluxdbUdpByNameResponse`"))),
492            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::ConfigMetricsGetConfigMetricsInfluxdbUdpByNameResponse`")))),
493        }
494    } else {
495        let content = resp.text().await?;
496        let entity: Option<ConfigMetricsGetConfigMetricsInfluxdbUdpByNameError> = serde_json::from_str(&content).ok();
497        Err(Error::ResponseError(ResponseContent { status, content, entity }))
498    }
499}
500
501/// List configured InfluxDB http metric servers.
502pub async fn config_metrics_get_influxdb_http(configuration: &configuration::Configuration, ) -> Result<models::ConfigMetricsGetInfluxdbHttpResponse, Error<ConfigMetricsGetInfluxdbHttpError>> {
503
504    let uri_str = format!("{}/config/metrics/influxdb-http", configuration.base_path);
505    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
506
507    if let Some(ref user_agent) = configuration.user_agent {
508        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
509    }
510    if let Some(ref apikey) = configuration.api_key {
511        let key = apikey.key.clone();
512        let value = match apikey.prefix {
513            Some(ref prefix) => format!("{} {}", prefix, key),
514            None => key,
515        };
516        req_builder = req_builder.header("Authorization", value);
517    };
518    if let Some(ref apikey) = configuration.api_key {
519        let key = apikey.key.clone();
520        let value = match apikey.prefix {
521            Some(ref prefix) => format!("{} {}", prefix, key),
522            None => key,
523        };
524        req_builder = req_builder.header("CSRFPreventionToken", value);
525    };
526
527    let req = req_builder.build()?;
528    let resp = configuration.client.execute(req).await?;
529
530    let status = resp.status();
531    let content_type = resp
532        .headers()
533        .get("content-type")
534        .and_then(|v| v.to_str().ok())
535        .unwrap_or("application/octet-stream");
536    let content_type = super::ContentType::from(content_type);
537
538    if !status.is_client_error() && !status.is_server_error() {
539        let content = resp.text().await?;
540        match content_type {
541            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
542            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigMetricsGetInfluxdbHttpResponse`"))),
543            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::ConfigMetricsGetInfluxdbHttpResponse`")))),
544        }
545    } else {
546        let content = resp.text().await?;
547        let entity: Option<ConfigMetricsGetInfluxdbHttpError> = serde_json::from_str(&content).ok();
548        Err(Error::ResponseError(ResponseContent { status, content, entity }))
549    }
550}
551
552/// List configured InfluxDB udp metric servers.
553pub async fn config_metrics_get_influxdb_udp(configuration: &configuration::Configuration, ) -> Result<models::ConfigMetricsGetInfluxdbUdpResponse, Error<ConfigMetricsGetInfluxdbUdpError>> {
554
555    let uri_str = format!("{}/config/metrics/influxdb-udp", configuration.base_path);
556    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
557
558    if let Some(ref user_agent) = configuration.user_agent {
559        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
560    }
561    if let Some(ref apikey) = configuration.api_key {
562        let key = apikey.key.clone();
563        let value = match apikey.prefix {
564            Some(ref prefix) => format!("{} {}", prefix, key),
565            None => key,
566        };
567        req_builder = req_builder.header("Authorization", value);
568    };
569    if let Some(ref apikey) = configuration.api_key {
570        let key = apikey.key.clone();
571        let value = match apikey.prefix {
572            Some(ref prefix) => format!("{} {}", prefix, key),
573            None => key,
574        };
575        req_builder = req_builder.header("CSRFPreventionToken", value);
576    };
577
578    let req = req_builder.build()?;
579    let resp = configuration.client.execute(req).await?;
580
581    let status = resp.status();
582    let content_type = resp
583        .headers()
584        .get("content-type")
585        .and_then(|v| v.to_str().ok())
586        .unwrap_or("application/octet-stream");
587    let content_type = super::ContentType::from(content_type);
588
589    if !status.is_client_error() && !status.is_server_error() {
590        let content = resp.text().await?;
591        match content_type {
592            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
593            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigMetricsGetInfluxdbUdpResponse`"))),
594            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::ConfigMetricsGetInfluxdbUdpResponse`")))),
595        }
596    } else {
597        let content = resp.text().await?;
598        let entity: Option<ConfigMetricsGetInfluxdbUdpError> = serde_json::from_str(&content).ok();
599        Err(Error::ResponseError(ResponseContent { status, content, entity }))
600    }
601}
602
603/// Directory index.
604pub async fn config_metrics_get_metrics(configuration: &configuration::Configuration, ) -> Result<models::ConfigMetricsGetMetricsResponse, Error<ConfigMetricsGetMetricsError>> {
605
606    let uri_str = format!("{}/config/metrics", configuration.base_path);
607    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
608
609    if let Some(ref user_agent) = configuration.user_agent {
610        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
611    }
612    if let Some(ref apikey) = configuration.api_key {
613        let key = apikey.key.clone();
614        let value = match apikey.prefix {
615            Some(ref prefix) => format!("{} {}", prefix, key),
616            None => key,
617        };
618        req_builder = req_builder.header("Authorization", value);
619    };
620    if let Some(ref apikey) = configuration.api_key {
621        let key = apikey.key.clone();
622        let value = match apikey.prefix {
623            Some(ref prefix) => format!("{} {}", prefix, key),
624            None => key,
625        };
626        req_builder = req_builder.header("CSRFPreventionToken", value);
627    };
628
629    let req = req_builder.build()?;
630    let resp = configuration.client.execute(req).await?;
631
632    let status = resp.status();
633    let content_type = resp
634        .headers()
635        .get("content-type")
636        .and_then(|v| v.to_str().ok())
637        .unwrap_or("application/octet-stream");
638    let content_type = super::ContentType::from(content_type);
639
640    if !status.is_client_error() && !status.is_server_error() {
641        let content = resp.text().await?;
642        match content_type {
643            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
644            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigMetricsGetMetricsResponse`"))),
645            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::ConfigMetricsGetMetricsResponse`")))),
646        }
647    } else {
648        let content = resp.text().await?;
649        let entity: Option<ConfigMetricsGetMetricsError> = serde_json::from_str(&content).ok();
650        Err(Error::ResponseError(ResponseContent { status, content, entity }))
651    }
652}
653
654/// Update an InfluxDB http server configuration
655pub async fn config_metrics_update_influxdb_http(configuration: &configuration::Configuration, name: &str, config_metrics_update_influxdb_http_request: Option<models::ConfigMetricsUpdateInfluxdbHttpRequest>) -> Result<models::ConfigMetricsUpdateInfluxdbHttpResponse, Error<ConfigMetricsUpdateInfluxdbHttpError>> {
656    // add a prefix to parameters to efficiently prevent name collisions
657    let p_path_name = name;
658    let p_body_config_metrics_update_influxdb_http_request = config_metrics_update_influxdb_http_request;
659
660    let uri_str = format!("{}/config/metrics/influxdb-http/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
661    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
662
663    if let Some(ref user_agent) = configuration.user_agent {
664        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
665    }
666    if let Some(ref apikey) = configuration.api_key {
667        let key = apikey.key.clone();
668        let value = match apikey.prefix {
669            Some(ref prefix) => format!("{} {}", prefix, key),
670            None => key,
671        };
672        req_builder = req_builder.header("Authorization", value);
673    };
674    if let Some(ref apikey) = configuration.api_key {
675        let key = apikey.key.clone();
676        let value = match apikey.prefix {
677            Some(ref prefix) => format!("{} {}", prefix, key),
678            None => key,
679        };
680        req_builder = req_builder.header("CSRFPreventionToken", value);
681    };
682    req_builder = req_builder.json(&p_body_config_metrics_update_influxdb_http_request);
683
684    let req = req_builder.build()?;
685    let resp = configuration.client.execute(req).await?;
686
687    let status = resp.status();
688    let content_type = resp
689        .headers()
690        .get("content-type")
691        .and_then(|v| v.to_str().ok())
692        .unwrap_or("application/octet-stream");
693    let content_type = super::ContentType::from(content_type);
694
695    if !status.is_client_error() && !status.is_server_error() {
696        let content = resp.text().await?;
697        match content_type {
698            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
699            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigMetricsUpdateInfluxdbHttpResponse`"))),
700            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::ConfigMetricsUpdateInfluxdbHttpResponse`")))),
701        }
702    } else {
703        let content = resp.text().await?;
704        let entity: Option<ConfigMetricsUpdateInfluxdbHttpError> = serde_json::from_str(&content).ok();
705        Err(Error::ResponseError(ResponseContent { status, content, entity }))
706    }
707}
708
709/// Update an InfluxDB udp server configuration
710pub async fn config_metrics_update_influxdb_udp(configuration: &configuration::Configuration, name: &str, config_metrics_update_influxdb_udp_request: Option<models::ConfigMetricsUpdateInfluxdbUdpRequest>) -> Result<models::ConfigMetricsUpdateInfluxdbUdpResponse, Error<ConfigMetricsUpdateInfluxdbUdpError>> {
711    // add a prefix to parameters to efficiently prevent name collisions
712    let p_path_name = name;
713    let p_body_config_metrics_update_influxdb_udp_request = config_metrics_update_influxdb_udp_request;
714
715    let uri_str = format!("{}/config/metrics/influxdb-udp/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
716    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
717
718    if let Some(ref user_agent) = configuration.user_agent {
719        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
720    }
721    if let Some(ref apikey) = configuration.api_key {
722        let key = apikey.key.clone();
723        let value = match apikey.prefix {
724            Some(ref prefix) => format!("{} {}", prefix, key),
725            None => key,
726        };
727        req_builder = req_builder.header("Authorization", value);
728    };
729    if let Some(ref apikey) = configuration.api_key {
730        let key = apikey.key.clone();
731        let value = match apikey.prefix {
732            Some(ref prefix) => format!("{} {}", prefix, key),
733            None => key,
734        };
735        req_builder = req_builder.header("CSRFPreventionToken", value);
736    };
737    req_builder = req_builder.json(&p_body_config_metrics_update_influxdb_udp_request);
738
739    let req = req_builder.build()?;
740    let resp = configuration.client.execute(req).await?;
741
742    let status = resp.status();
743    let content_type = resp
744        .headers()
745        .get("content-type")
746        .and_then(|v| v.to_str().ok())
747        .unwrap_or("application/octet-stream");
748    let content_type = super::ContentType::from(content_type);
749
750    if !status.is_client_error() && !status.is_server_error() {
751        let content = resp.text().await?;
752        match content_type {
753            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
754            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigMetricsUpdateInfluxdbUdpResponse`"))),
755            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::ConfigMetricsUpdateInfluxdbUdpResponse`")))),
756        }
757    } else {
758        let content = resp.text().await?;
759        let entity: Option<ConfigMetricsUpdateInfluxdbUdpError> = serde_json::from_str(&content).ok();
760        Err(Error::ResponseError(ResponseContent { status, content, entity }))
761    }
762}
763