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
use crate::{models, opts, util::url, Result};
impl_api_ty!(
Secret => id
);
impl<'podman> Secret<'podman> {
api_doc! {
Secret => InspectLibpod
/// Inspect this secret returning detailed information about it.
///
/// Examples:
///
/// ```no_run
/// 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
/// let podman = Podman::unix("/run/user/1000/podman/podman.sock");
///
/// if let Err(e) = podman.secrets().delete().await {
/// eprintln!("{}", e);
/// }
/// ```
|
pub async fn delete(&self) -> Result<()> {
self.podman
.delete(&format!("/libpod/secrets/{}/", &self.id))
.await
.map(|_| ())
}}
}
impl<'podman> Secrets<'podman> {
api_doc! {
Secret => ListLibpod
/// List available secrets.
///
/// Examples:
///
/// ```no_run
/// 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
/// let podman = Podman::unix("/run/user/1000/podman/podman.sock");
///
/// match podman.secrets().create().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())?),
)
.await
.map(|resp: models::LibpodSecretCreateResponse| {
Secret::new(self.podman, resp.ID.unwrap_or_default())
})
}}
}