1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
use crate::{models, opts, Result};
use containers_api::url;
impl_api_ty!(
Secret => id
);
impl Secret {
api_doc! {
Secret => InspectLibpod
|
/// Inspect this secret returning detailed information about it.
///
/// Examples:
///
/// ```no_run
/// async {
/// use podman_api::Podman;
/// let podman = Podman::unix("/run/user/1000/podman/podman.sock");
///
/// match podman.secrets().get("79c93f220e3e").inspect().await {
/// Ok(info) => println!("{:?}", info),
/// Err(e) => eprintln!("{}", e),
/// }
/// };
/// ```
pub async fn inspect(&self) -> Result<models::SecretInfoReport> {
self.podman
.get_json(&format!("/libpod/secrets/{}/json", &self.id))
.await
}}
api_doc! {
Secret => DeleteLibpod
|
/// Remove this secret
///
/// Examples:
///
/// ```no_run
/// async {
/// use podman_api::Podman;
/// let podman = Podman::unix("/run/user/1000/podman/podman.sock");
///
/// if let Err(e) = podman.secrets().get("79c93f220e3e").delete().await {
/// eprintln!("{}", e);
/// }
/// };
/// ```
pub async fn delete(&self) -> Result<()> {
self.podman
.delete(&format!("/libpod/secrets/{}", &self.id))
.await
.map(|_| ())
}}
}
impl Secrets {
api_doc! {
Secret => ListLibpod
|
/// List available secrets.
///
/// Examples:
///
/// ```no_run
/// async {
/// use podman_api::Podman;
/// let podman = Podman::unix("/run/user/1000/podman/podman.sock");
///
/// match podman.secrets().list().await {
/// Ok(info) => println!("{:?}", info),
/// Err(e) => eprintln!("{}", e),
/// }
/// };
/// ```
pub async fn list(&self) -> Result<Vec<models::SecretInfoReport>> {
self.podman.get_json("/libpod/secrets/json").await
}}
api_doc! {
Secret => CreateLibpod
|
/// Create a new secret.
///
/// Examples:
///
/// ```no_run
/// async {
/// use podman_api::Podman;
/// use podman_api::opts::SecretCreateOpts;
/// let podman = Podman::unix("/run/user/1000/podman/podman.sock");
///
/// match podman.secrets().create(
/// &SecretCreateOpts::builder("my-secret").build(),
/// "secret-value"
/// ).await {
/// Ok(info) => println!("{:?}", info),
/// Err(e) => eprintln!("{}", e),
/// }
/// };
/// ```
pub async fn create(
&self,
opts: &opts::SecretCreateOpts,
secret: impl Into<String>,
) -> Result<Secret> {
let ep = url::construct_ep("/libpod/secrets/create", opts.serialize());
self.podman
.post_json(
&ep,
crate::conn::Payload::Json(serde_json::to_string(&secret.into())?),
crate::conn::Headers::none(),
)
.await
.map(|resp: models::SecretCreateResponse| {
Secret::new(self.podman.clone(), resp.id.unwrap_or_default())
})
}}
}