podman_client/images/
untag.rs

1use http_body_util::Empty;
2use hyper::body::Bytes;
3use url::form_urlencoded;
4
5use crate::{
6    client::Client,
7    models::{
8        connection::SendRequestOptions, lib::Error, podman::images::untag::ImageUntagOptions,
9    },
10};
11
12impl Client {
13    pub async fn image_untag(&self, options: ImageUntagOptions<'_>) -> Result<(), Error> {
14        let mut path = ["/libpod/images/", options.name, "/untag"].concat();
15
16        let mut query = form_urlencoded::Serializer::new(String::new());
17        if let Some(repo) = options.repo {
18            query.append_pair("repo", repo);
19        }
20        if let Some(tag) = options.tag {
21            query.append_pair("tag", tag);
22        }
23        let query_string = query.finish();
24        if !query_string.is_empty() {
25            path += &["?", &query_string].concat();
26        }
27
28        let (_, data) = self
29            .send_request::<_, (), _>(SendRequestOptions {
30                method: "POST",
31                path: &path,
32                header: None,
33                body: Empty::<Bytes>::new(),
34            })
35            .await?;
36
37        Ok(data)
38    }
39}