podman_rest_client/v4/apis/
secrets_compat.rs1use crate::api_common::config::HasConfig;
2use crate::api_common::request;
3use crate::api_common::Error;
4use http::request::Builder;
5use std::future::Future;
6use std::pin::Pin;
7pub trait SecretsCompat: HasConfig + Send + Sync {
8 fn secret_list<'a>(
14 &'a self,
15 params: Option<crate::v4::params::SecretList<'a>>,
16 ) -> Pin<Box<dyn Future<Output = Result<Vec<()>, Error>> + Send + 'a>> {
17 Box::pin(request::execute_request_json(
18 self.get_config(),
19 move |mut req_builder: Builder| {
20 req_builder = req_builder.method("GET");
21 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
22 let mut request_path = request_url.path().to_owned();
23 if request_path.ends_with('/') {
24 request_path.pop();
25 }
26 request_path.push_str("/secrets");
27 request_url.set_path(&request_path);
28 if let Some(params) = ¶ms {
29 let mut query_pairs = request_url.query_pairs_mut();
30 if let Some(filters) = params.filters {
31 query_pairs.append_pair("filters", filters);
32 }
33 }
34 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
35 req_builder = req_builder.uri(hyper_uri);
36 Ok(req_builder.body(String::new())?)
37 },
38 ))
39 }
40 fn secret_delete<'a>(
44 &'a self,
45 name: &'a str,
46 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
47 Box::pin(request::execute_request_unit(
48 self.get_config(),
49 move |mut req_builder: Builder| {
50 req_builder = req_builder.method("DELETE");
51 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
52 let mut request_path = request_url.path().to_owned();
53 if request_path.ends_with('/') {
54 request_path.pop();
55 }
56 request_path.push_str("/secrets/{name}");
57 request_path = request_path.replace("{name}", name);
58 request_url.set_path(&request_path);
59 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
60 req_builder = req_builder.uri(hyper_uri);
61 Ok(req_builder.body(String::new())?)
62 },
63 ))
64 }
65 fn secret_inspect<'a>(
69 &'a self,
70 name: &'a str,
71 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
72 Box::pin(request::execute_request_unit(
73 self.get_config(),
74 move |mut req_builder: Builder| {
75 req_builder = req_builder.method("GET");
76 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
77 let mut request_path = request_url.path().to_owned();
78 if request_path.ends_with('/') {
79 request_path.pop();
80 }
81 request_path.push_str("/secrets/{name}");
82 request_path = request_path.replace("{name}", name);
83 request_url.set_path(&request_path);
84 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
85 req_builder = req_builder.uri(hyper_uri);
86 Ok(req_builder.body(String::new())?)
87 },
88 ))
89 }
90 fn secret_create<'a>(
94 &'a self,
95 create: (),
96 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
97 Box::pin(request::execute_request_unit(
98 self.get_config(),
99 move |mut req_builder: Builder| {
100 req_builder = req_builder.method("POST");
101 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
102 let mut request_path = request_url.path().to_owned();
103 if request_path.ends_with('/') {
104 request_path.pop();
105 }
106 request_path.push_str("/secrets/create");
107 request_url.set_path(&request_path);
108 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
109 req_builder = req_builder.uri(hyper_uri);
110 let body = serde_json::to_string(&create)?;
111 req_builder = req_builder.header(hyper::header::CONTENT_TYPE, "application/json");
112 req_builder = req_builder.header(hyper::header::CONTENT_LENGTH, body.len());
113 Ok(req_builder.body(body)?)
114 },
115 ))
116 }
117}