podman_client/models/podman/pods/
list.rs

1use core::fmt;
2use std::collections::HashMap;
3
4use chrono::{DateTime, Utc};
5use serde::{Deserialize, Serialize};
6
7#[derive(Default)]
8pub struct PodListOptions<'a> {
9    pub filters: Option<PodListFiltersOptions<'a>>,
10}
11
12#[derive(Default)]
13pub struct PodListFiltersOptions<'a> {
14    pub id: Option<Vec<&'a str>>,
15    pub label: Option<Vec<&'a str>>,
16    pub name: Option<Vec<&'a str>>,
17    pub until: Option<Vec<&'a str>>,
18    pub status: Option<Vec<PodListFiltersStatusOptions>>,
19    pub network: Option<Vec<&'a str>>,
20    pub ctr_names: Option<Vec<&'a str>>,
21    pub ctr_ids: Option<Vec<&'a str>>,
22    pub ctr_status: Option<Vec<&'a str>>,
23    pub ctr_number: Option<Vec<&'a str>>,
24}
25
26pub enum PodListFiltersStatusOptions {
27    Stopped,
28    Running,
29    Paused,
30    Exited,
31    Dead,
32    Created,
33    Degraded,
34}
35
36impl PodListFiltersStatusOptions {
37    pub fn as_str(&self) -> &'static str {
38        match self {
39            Self::Stopped => "stopped",
40            Self::Running => "running",
41            Self::Paused => "paused",
42            Self::Exited => "exited",
43            Self::Dead => "dead",
44            Self::Created => "created",
45            Self::Degraded => "degraded",
46        }
47    }
48}
49
50pub type PodList = Vec<PodListItem>;
51
52#[derive(Deserialize, Serialize)]
53#[serde(rename_all = "PascalCase")]
54pub struct PodListItem {
55    pub cgroup: String,
56    pub containers: Vec<PodListItemContainer>,
57    pub created: DateTime<Utc>,
58    pub id: String,
59    pub infra_id: String,
60    pub labels: HashMap<String, String>,
61    pub name: String,
62    pub namespace: String,
63    pub networks: Vec<String>,
64    pub status: String,
65}
66
67impl fmt::Debug for PodListItem {
68    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
69        let json = serde_json::to_string_pretty(self).map_err(|_| fmt::Error)?;
70        f.write_str(&json)
71    }
72}
73
74#[derive(Deserialize, Serialize)]
75#[serde(rename_all = "PascalCase")]
76pub struct PodListItemContainer {
77    pub id: String,
78    pub names: String,
79    pub restart_count: u64,
80    pub status: String,
81}