diff options
Diffstat (limited to 'src/docker.rs')
-rw-r--r-- | src/docker.rs | 80 |
1 files changed, 79 insertions, 1 deletions
diff --git a/src/docker.rs b/src/docker.rs index c44356e..edb97e4 100644 --- a/src/docker.rs +++ b/src/docker.rs @@ -7,6 +7,7 @@ use std::{collections::HashMap, env, io, path::Path}; use futures_util::{stream::Stream, TryStreamExt}; use hyper::{client::HttpConnector, Body, Client, Method}; use mime::Mime; +use serde::{Deserialize, Serialize}; use serde_json::Value; use url::form_urlencoded; @@ -15,13 +16,17 @@ use crate::{ errors::{Error, Result}, image::Images, network::Networks, - rep::{Event, Info, Version}, service::Services, transport::{Headers, Payload, Transport}, volume::Volumes, Uri, }; +#[cfg(feature = "chrono")] +use crate::datetime::{datetime_from_nano_timestamp, datetime_from_unix_timestamp}; +#[cfg(feature = "chrono")] +use chrono::{DateTime, Utc}; + #[cfg(feature = "tls")] use hyper_openssl::HttpsConnector; #[cfg(feature = "tls")] @@ -542,6 +547,79 @@ impl EventsOptionsBuilder { } } +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct Version { + pub version: String, + pub api_version: String, + pub git_commit: String, + pub go_version: String, + pub os: String, + pub arch: String, + pub kernel_version: String, + #[cfg(feature = "chrono")] + pub build_time: DateTime<Utc>, + #[cfg(not(feature = "chrono"))] + pub build_time: String, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct Info { + pub containers: u64, + pub images: u64, + pub driver: String, + pub docker_root_dir: String, + pub driver_status: Vec<Vec<String>>, + #[serde(rename = "ID")] + pub id: String, + pub kernel_version: String, + // pub Labels: Option<???>, + pub mem_total: u64, + pub memory_limit: bool, + #[serde(rename = "NCPU")] + pub n_cpu: u64, + pub n_events_listener: u64, + pub n_goroutines: u64, + pub name: String, + pub operating_system: String, + // pub RegistryConfig:??? + pub swap_limit: bool, + pub system_time: Option<String>, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct Event { + #[serde(rename = "Type")] + pub typ: String, + #[serde(rename = "Action")] + pub action: String, + #[serde(rename = "Actor")] + pub actor: Actor, + pub status: Option<String>, + pub id: Option<String>, + pub from: Option<String>, + #[cfg(feature = "chrono")] + #[serde(deserialize_with = "datetime_from_unix_timestamp")] + pub time: DateTime<Utc>, + #[cfg(not(feature = "chrono"))] + pub time: u64, + #[cfg(feature = "chrono")] + #[serde(deserialize_with = "datetime_from_nano_timestamp", rename = "timeNano")] + pub time_nano: DateTime<Utc>, + #[cfg(not(feature = "chrono"))] + #[serde(rename = "timeNano")] + pub time_nano: u64, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct Actor { + #[serde(rename = "ID")] + pub id: String, + #[serde(rename = "Attributes")] + pub attributes: HashMap<String, String>, +} + #[cfg(test)] mod tests { #[cfg(feature = "unix-socket")] |