podman_client/models/podman/containers/
list.rs1use core::fmt;
2use std::collections::HashMap;
3
4use chrono::{DateTime, Utc};
5use serde::{Deserialize, Serialize};
6
7use crate::models::podman::common::port_mapping::PortMapping;
8
9#[derive(Default)]
10pub struct ContainerListOptions {
11 pub all: Option<bool>,
12 pub filters: Option<ContainerListFiltersOptions>,
13 pub limit: Option<i64>,
14 pub namespace: Option<bool>,
15 pub pod: Option<bool>,
16 pub size: Option<bool>,
17 pub sync: Option<bool>,
18}
19
20#[derive(Default)]
21pub struct ContainerListFiltersOptions {
22 pub ancestor: Option<Vec<String>>,
23 pub before: Option<Vec<String>>,
24 pub expose: Option<Vec<String>>,
25 pub exited: Option<Vec<i64>>,
26 pub health: Option<Vec<ContainerListFiltersHealthOptions>>,
27 pub id: Option<Vec<String>>,
28 pub is_task: Option<Vec<bool>>,
29 pub label: Option<Vec<String>>,
30 pub name: Option<Vec<String>>,
31 pub network: Option<Vec<String>>,
32 pub pod: Option<Vec<String>>,
33 pub publish: Option<Vec<String>>,
34 pub since: Option<Vec<String>>,
35 pub status: Option<Vec<ContainerListFiltersStatusOptions>>,
36 pub volume: Option<Vec<String>>,
37}
38
39pub enum ContainerListFiltersHealthOptions {
40 Starting,
41 Healthy,
42 Unhealthy,
43 None,
44}
45
46impl ContainerListFiltersHealthOptions {
47 pub fn as_str(&self) -> &'static str {
48 match self {
49 Self::Starting => "starting",
50 Self::Healthy => "healthy",
51 Self::Unhealthy => "unhealthy",
52 Self::None => "none",
53 }
54 }
55}
56
57pub enum ContainerListFiltersStatusOptions {
58 Created,
59 Restarting,
60 Running,
61 Removing,
62 Paused,
63 Exited,
64 Dead,
65}
66
67impl ContainerListFiltersStatusOptions {
68 pub fn as_str(&self) -> &'static str {
69 match self {
70 Self::Created => "created",
71 Self::Restarting => "restarting",
72 Self::Running => "running",
73 Self::Removing => "removing",
74 Self::Paused => "paused",
75 Self::Exited => "exited",
76 Self::Dead => "dead",
77 }
78 }
79}
80
81pub type ContainerList = Vec<ContainerListItem>;
82
83#[derive(Deserialize, Serialize)]
84#[serde(rename_all = "PascalCase")]
85pub struct ContainerListItem {
86 pub auto_remove: bool,
87 #[serde(rename = "CIDFile")]
88 pub cid_file: String,
89 pub command: Vec<String>,
90 pub created: DateTime<Utc>,
91 pub created_at: DateTime<Utc>,
92 pub exit_code: i32,
93 pub exited: bool,
94 pub exited_at: DateTime<Utc>,
95 pub exposed_ports: HashMap<u16, Vec<String>>,
96 pub id: String,
97 pub image: String,
98 #[serde(rename = "ImageID")]
99 pub image_id: String,
100 pub is_infra: bool,
101 pub labels: HashMap<String, String>,
102 pub mounts: Vec<String>,
103 pub names: Vec<String>,
104 pub namespaces: ContainerListItemNamespaces,
105 pub networks: Vec<String>,
106 pub pid: i64,
107 pub pod: String,
108 pub pod_name: String,
109 pub ports: Vec<PortMapping>,
110 pub restarts: u64,
111 pub size: ContainerListItemSize,
112 pub started_at: DateTime<Utc>,
113 pub state: String,
114 pub status: String,
115}
116
117impl fmt::Debug for ContainerListItem {
118 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
119 let json = serde_json::to_string_pretty(self).map_err(|_| fmt::Error)?;
120 f.write_str(&json)
121 }
122}
123
124#[derive(Deserialize, Serialize)]
125#[serde(rename_all = "PascalCase")]
126pub struct ContainerListItemNamespaces {
127 pub cgroup: String,
128 pub ipc: String,
129 pub mnt: String,
130 pub net: String,
131 pub pidns: String,
132 pub user: String,
133 pub uts: String,
134}
135
136#[derive(Deserialize, Serialize)]
137#[serde(rename_all = "camelCase")]
138pub struct ContainerListItemSize {
139 pub root_fs_size: i64,
140 pub rw_size: i64,
141}