1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
//! System API: interface for interacting with the Docker server and/or Registry.
use bytes::Bytes;
use futures_core::Stream;
use http::request::Builder;
use http_body_util::Full;
use hyper::Method;
use super::Docker;
use crate::docker::BodyType;
use crate::errors::Error;
use crate::models::*;
impl Docker {
/// ---
///
/// # Version
///
/// Returns the version of Docker that is running and various information about the system that
/// Docker is running on.
///
/// # Returns
///
/// - [SystemVersion](crate::models::SystemVersion), wrapped in a Future.
///
/// # Examples
///
/// ```rust
/// # use bollard::Docker;
/// # let docker = Docker::connect_with_http_defaults().unwrap();
/// docker.version();
/// ```
pub async fn version(&self) -> Result<SystemVersion, Error> {
let req = self.build_request(
"/version",
Builder::new().method(Method::GET),
None::<String>,
Ok(BodyType::Left(Full::new(Bytes::new()))),
);
self.process_into_value(req).await
}
/// ---
///
/// # Info
///
/// Returns Docker client and server information that is running.
///
/// # Returns
///
/// - [Info](SystemInfo), wrapped in a Future.
///
/// # Examples
///
/// ```rust
/// # use bollard::Docker;
/// # let docker = Docker::connect_with_http_defaults().unwrap();
/// docker.info();
/// ```
pub async fn info(&self) -> Result<SystemInfo, Error> {
let req = self.build_request(
"/info",
Builder::new().method(Method::GET),
None::<String>,
Ok(BodyType::Left(Full::new(Bytes::new()))),
);
self.process_into_value(req).await
}
/// ---
///
/// # Ping
///
/// This is a dummy endpoint you can use to test if the server is accessible.
/// # Returns - A [String](std::string::String), wrapped in a Future. # Examples
///
/// ```rust
/// # use bollard::Docker;
/// # let docker = Docker::connect_with_http_defaults().unwrap();
///
/// docker.ping();
/// ```
pub async fn ping(&self) -> Result<String, Error> {
let url = "/_ping";
let req = self.build_request(
url,
Builder::new().method(Method::GET),
None::<String>,
Ok(BodyType::Left(Full::new(Bytes::new()))),
);
self.process_into_string(req).await
}
/// ---
///
/// # Events
///
/// Stream real-time events from the server.
///
/// # Returns
///
/// - [EventMessage](crate::models::EventMessage),
/// wrapped in a Stream.
///
/// # Examples
///
/// ```rust
/// use bollard::query_parameters::EventsOptionsBuilder;
/// use std::collections::HashMap;
///
/// # use bollard::Docker;
/// # let docker = Docker::connect_with_http_defaults().unwrap();
///
/// let mut filters = HashMap::new();
/// filters.insert("type", vec!["container"]);
///
/// let options = EventsOptionsBuilder::default()
/// .since("1h")
/// .filters(&filters)
/// .build();
///
/// docker.events(Some(options));
/// ```
pub fn events(
&self,
options: Option<crate::query_parameters::EventsOptions>,
) -> impl Stream<Item = Result<EventMessage, Error>> {
let url = "/events";
let req = self.build_request(
url,
Builder::new().method(Method::GET),
options,
Ok(BodyType::Left(Full::new(Bytes::new()))),
);
self.process_into_stream(req)
}
/// ---
///
/// # Get data usage information
///
/// Show docker disk usage
///
/// # Returns
///
/// - [System Data Usage
/// Response](SystemDataUsageResponse), wrapped in a
/// Future.
///
/// # Examples
///
/// ```rust
/// # use bollard::Docker;
/// # use bollard::query_parameters::DataUsageOptions;
/// # let docker = Docker::connect_with_http_defaults().unwrap();
/// docker.df(None::<DataUsageOptions>);
/// ```
pub async fn df(
&self,
options: Option<crate::query_parameters::DataUsageOptions>,
) -> Result<SystemDataUsageResponse, Error> {
let url = "/system/df";
let req = self.build_request(
url,
Builder::new().method(Method::GET),
options,
Ok(BodyType::Left(Full::new(Bytes::new()))),
);
self.process_into_value(req).await
}
}