podman_client/models/podman/pods/
inspect.rs

1use core::fmt;
2use std::{collections::HashMap, net::Ipv4Addr};
3
4use chrono::{DateTime, Utc};
5use serde::{Deserialize, Serialize};
6
7use crate::models::podman::common::{
8    blkio_weight_device::BlkioWeightDevice, inspect_device::InspectDevice,
9    inspect_host_port::InspectHostPort, inspect_mount::InspectMount,
10};
11
12pub struct PodInspectOptions<'a> {
13    pub name: &'a str,
14}
15
16#[derive(Deserialize, Serialize)]
17pub struct PodInspect {
18    pub blkio_weight: u64,
19    pub blkio_weight_device: Vec<BlkioWeightDevice>,
20    #[serde(rename = "CgroupParent")]
21    pub cgroup_parent: String,
22    #[serde(rename = "CgroupPath")]
23    pub cgroup_path: String,
24    #[serde(rename = "Containers")]
25    pub containers: Vec<PodInspectContainer>,
26    pub cpu_period: u64,
27    pub cpu_quota: i64,
28    pub cpu_shares: u64,
29    pub cpuset_cpus: String,
30    pub cpuset_mems: String,
31    #[serde(rename = "CreateCgroup")]
32    pub create_cgroup: bool,
33    #[serde(rename = "CreateCommand")]
34    pub create_command: Vec<String>,
35    #[serde(rename = "Created")]
36    pub created: DateTime<Utc>,
37    #[serde(rename = "CreateInfra")]
38    pub create_infra: bool,
39    pub device_read_bps: Vec<PodCreateBlkioThrottleDevice>,
40    pub device_write_bps: Vec<PodCreateBlkioThrottleDevice>,
41    #[serde(rename = "Devices")]
42    pub devices: Vec<InspectDevice>,
43    #[serde(rename = "ExitPolicy")]
44    pub exit_policy: String,
45    #[serde(rename = "Hostname")]
46    pub hostname: String,
47    #[serde(rename = "Id")]
48    pub id: String,
49    #[serde(rename = "InfraConfig")]
50    pub infra_config: PodCreateInfraConfig,
51    #[serde(rename = "InfraContainerID")]
52    pub infra_container_id: String,
53    pub labels: HashMap<String, String>,
54    #[serde(rename = "LockNumber")]
55    pub lock_number: u32,
56    pub memory_limit: u64,
57    pub memory_swap: u64,
58    pub mounts: Vec<InspectMount>,
59    #[serde(rename = "Name")]
60    pub name: String,
61    #[serde(rename = "Namespace")]
62    pub namespace: String,
63    #[serde(rename = "NumContainers")]
64    pub num_containers: u64,
65    #[serde(rename = "RestartPolicy")]
66    pub restart_policy: String,
67    pub security_opt: Vec<String>,
68    #[serde(rename = "SharedNamespaces")]
69    pub shared_namespaces: Vec<String>,
70    #[serde(rename = "State")]
71    pub state: String,
72    pub volumes_from: Vec<String>,
73}
74
75impl fmt::Debug for PodInspect {
76    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
77        let json = serde_json::to_string_pretty(self).map_err(|_| fmt::Error)?;
78        f.write_str(&json)
79    }
80}
81
82#[derive(Deserialize, Serialize)]
83pub struct PodInspectContainer {
84    pub id: String,
85    pub name: String,
86    pub state: String,
87}
88
89#[derive(Deserialize, Serialize)]
90pub struct PodCreateBlkioThrottleDevice {
91    pub path: String,
92    pub rate: u64,
93}
94
95#[derive(Deserialize, Serialize)]
96pub struct PodCreateInfraConfig {
97    pub cpu_period: u64,
98    pub cpu_quota: i64,
99    pub cpuset_cpus: String,
100    #[serde(rename = "DNSOption")]
101    pub dns_option: Vec<String>,
102    #[serde(rename = "DNSSearch")]
103    pub dns_search: Vec<String>,
104    #[serde(rename = "DNSServer")]
105    pub dns_server: Vec<String>,
106    #[serde(rename = "HostNetwork")]
107    pub host_network: bool,
108    #[serde(rename = "HostsFile")]
109    pub hosts_file: String,
110    #[serde(rename = "NetworkOptions")]
111    pub network_options: HashMap<String, Vec<String>>,
112    #[serde(rename = "Networks")]
113    pub networks: Vec<String>,
114    #[serde(rename = "NoManageHostname")]
115    pub no_manage_hostname: bool,
116    #[serde(rename = "NoManageHosts")]
117    pub no_manage_hosts: bool,
118    #[serde(rename = "NoManageResolvConf")]
119    pub no_manage_resolv_conf: bool,
120    pub pid_ns: String,
121    #[serde(rename = "PortBindings")]
122    pub port_bindings: HashMap<String, Vec<InspectHostPort>>,
123    #[serde(rename = "StaticIP")]
124    pub static_ip: Ipv4Addr,
125    #[serde(rename = "StaticMAC")]
126    pub static_mac: String,
127    pub userns: String,
128    pub uts_ns: String,
129}