artcoded_api/apis/
cache_controller_api.rs1use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum ClearError {
20 UnknownValue(serde_json::Value),
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum FindAll9Error {
27 UnknownValue(serde_json::Value),
28}
29
30pub async fn clear(
31 configuration: &configuration::Configuration,
32 name: &str,
33) -> Result<models::Restore200Response, Error<ClearError>> {
34 let p_query_name = name;
36
37 let uri_str = format!("{}/api/cache/clear", configuration.base_path);
38 let mut req_builder = configuration
39 .client
40 .request(reqwest::Method::DELETE, &uri_str);
41
42 req_builder = req_builder.query(&[("name", &p_query_name.to_string())]);
43 if let Some(ref user_agent) = configuration.user_agent {
44 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
45 }
46 if let Some(ref token) = configuration.bearer_access_token {
47 req_builder = req_builder.bearer_auth(token.to_owned());
48 };
49
50 let req = req_builder.build()?;
51 let resp = configuration.client.execute(req).await?;
52
53 let status = resp.status();
54 let content_type = resp
55 .headers()
56 .get("content-type")
57 .and_then(|v| v.to_str().ok())
58 .unwrap_or("application/octet-stream");
59 let content_type = super::ContentType::from(content_type);
60
61 if !status.is_client_error() && !status.is_server_error() {
62 let content = resp.text().await?;
63 match content_type {
64 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
65 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Restore200Response`"))),
66 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Restore200Response`")))),
67 }
68 } else {
69 let content = resp.text().await?;
70 let entity: Option<ClearError> = serde_json::from_str(&content).ok();
71 Err(Error::ResponseError(ResponseContent {
72 status,
73 content,
74 entity,
75 }))
76 }
77}
78
79pub async fn find_all9(
80 configuration: &configuration::Configuration,
81) -> Result<Vec<String>, Error<FindAll9Error>> {
82 let uri_str = format!("{}/api/cache/find-all", configuration.base_path);
83 let mut req_builder = configuration
84 .client
85 .request(reqwest::Method::POST, &uri_str);
86
87 if let Some(ref user_agent) = configuration.user_agent {
88 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
89 }
90 if let Some(ref token) = configuration.bearer_access_token {
91 req_builder = req_builder.bearer_auth(token.to_owned());
92 };
93
94 let req = req_builder.build()?;
95 let resp = configuration.client.execute(req).await?;
96
97 let status = resp.status();
98 let content_type = resp
99 .headers()
100 .get("content-type")
101 .and_then(|v| v.to_str().ok())
102 .unwrap_or("application/octet-stream");
103 let content_type = super::ContentType::from(content_type);
104
105 if !status.is_client_error() && !status.is_server_error() {
106 let content = resp.text().await?;
107 match content_type {
108 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
109 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<String>`"))),
110 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<String>`")))),
111 }
112 } else {
113 let content = resp.text().await?;
114 let entity: Option<FindAll9Error> = serde_json::from_str(&content).ok();
115 Err(Error::ResponseError(ResponseContent {
116 status,
117 content,
118 entity,
119 }))
120 }
121}