podman_rest_client/v4/apis/
secrets.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 Secrets: HasConfig + Send + Sync {
8 fn secret_delete_libpod<'a>(
12 &'a self,
13 name: &'a str,
14 params: Option<crate::v4::params::SecretDeleteLibpod>,
15 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
16 Box::pin(request::execute_request_unit(
17 self.get_config(),
18 move |mut req_builder: Builder| {
19 req_builder = req_builder.method("DELETE");
20 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
21 let mut request_path = request_url.path().to_owned();
22 if request_path.ends_with('/') {
23 request_path.pop();
24 }
25 request_path.push_str("/libpod/secrets/{name}");
26 request_path = request_path.replace("{name}", name);
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(all) = params.all {
31 query_pairs.append_pair("all", &all.to_string());
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_exists_libpod<'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("GET");
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("/libpod/secrets/{name}/exists");
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_libpod<'a>(
69 &'a self,
70 name: &'a str,
71 params: Option<crate::v4::params::SecretInspectLibpod>,
72 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
73 Box::pin(request::execute_request_unit(
74 self.get_config(),
75 move |mut req_builder: Builder| {
76 req_builder = req_builder.method("GET");
77 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
78 let mut request_path = request_url.path().to_owned();
79 if request_path.ends_with('/') {
80 request_path.pop();
81 }
82 request_path.push_str("/libpod/secrets/{name}/json");
83 request_path = request_path.replace("{name}", name);
84 request_url.set_path(&request_path);
85 if let Some(params) = ¶ms {
86 let mut query_pairs = request_url.query_pairs_mut();
87 if let Some(showsecret) = params.showsecret {
88 query_pairs.append_pair("showsecret", &showsecret.to_string());
89 }
90 }
91 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
92 req_builder = req_builder.uri(hyper_uri);
93 Ok(req_builder.body(String::new())?)
94 },
95 ))
96 }
97 fn secret_create_libpod<'a>(
101 &'a self,
102 params: Option<crate::v4::params::SecretCreateLibpod<'a>>,
103 request: String,
104 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
105 Box::pin(request::execute_request_unit(
106 self.get_config(),
107 move |mut req_builder: Builder| {
108 req_builder = req_builder.method("POST");
109 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
110 let mut request_path = request_url.path().to_owned();
111 if request_path.ends_with('/') {
112 request_path.pop();
113 }
114 request_path.push_str("/libpod/secrets/create");
115 request_url.set_path(&request_path);
116 if let Some(params) = ¶ms {
117 let mut query_pairs = request_url.query_pairs_mut();
118 query_pairs.append_pair("name", params.name);
119 if let Some(driver) = params.driver {
120 query_pairs.append_pair("driver", driver);
121 }
122 if let Some(driveropts) = params.driveropts {
123 query_pairs.append_pair("driveropts", driveropts);
124 }
125 if let Some(labels) = params.labels {
126 query_pairs.append_pair("labels", labels);
127 }
128 }
129 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
130 req_builder = req_builder.uri(hyper_uri);
131 let body = serde_json::to_string(&request)?;
132 req_builder = req_builder.header(hyper::header::CONTENT_TYPE, "application/json");
133 req_builder = req_builder.header(hyper::header::CONTENT_LENGTH, body.len());
134 Ok(req_builder.body(body)?)
135 },
136 ))
137 }
138 fn secret_list_libpod<'a>(
144 &'a self,
145 params: Option<crate::v4::params::SecretListLibpod<'a>>,
146 ) -> Pin<Box<dyn Future<Output = Result<Vec<()>, Error>> + Send + 'a>> {
147 Box::pin(request::execute_request_json(
148 self.get_config(),
149 move |mut req_builder: Builder| {
150 req_builder = req_builder.method("GET");
151 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
152 let mut request_path = request_url.path().to_owned();
153 if request_path.ends_with('/') {
154 request_path.pop();
155 }
156 request_path.push_str("/libpod/secrets/json");
157 request_url.set_path(&request_path);
158 if let Some(params) = ¶ms {
159 let mut query_pairs = request_url.query_pairs_mut();
160 if let Some(filters) = params.filters {
161 query_pairs.append_pair("filters", filters);
162 }
163 }
164 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
165 req_builder = req_builder.uri(hyper_uri);
166 Ok(req_builder.body(String::new())?)
167 },
168 ))
169 }
170}