docker_client_async/types/
client.rs

1/*
2 * Copyright 2020 Damian Peckett <damian@pecke.tt>.
3 * Copyright 2013-2018 Docker, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *     https://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18use crate::container::StatsStream;
19use crate::types::filters::Args;
20use crate::types::network::EndpointSettings;
21use crate::types::volume::Volume;
22use derive_builder::Builder;
23use serde::{Deserialize, Serialize};
24use std::collections::HashMap;
25use std::time::SystemTime;
26
27/// ContainerListOptions holds parameters to list containers with.
28#[derive(Clone, Debug, Default, Builder)]
29#[builder(default, setter(into))]
30pub struct ContainerListOptions {
31    /// Return the size of container as fields SizeRw and SizeRootFs.
32    pub size: bool,
33    /// Return all containers. By default, only running containers are shown.
34    pub all: bool,
35    /// Return this number of most recently created containers, including non-running ones.
36    pub limit: Option<usize>,
37    /// Filters to process on the container list.
38    pub filters: Option<super::filters::Args>,
39}
40
41/// ContainerLogsOptions holds parameters to filter logs with.
42#[derive(Clone, Debug, Default, Builder)]
43#[builder(default, setter(into))]
44pub struct ContainerLogsOptions {
45    pub show_stdout: bool,
46    pub show_stderr: bool,
47    pub since: Option<SystemTime>,
48    pub until: Option<SystemTime>,
49    pub timestamps: bool,
50    pub follow: bool,
51    pub tail: Option<String>,
52    pub details: bool,
53}
54
55/// ResizeOptions holds parameters to resize a tty.
56/// It can be used to resize container ttys and
57/// exec process ttys too.
58#[derive(Clone, Debug, Default, Builder)]
59#[builder(default, setter(into))]
60pub struct ResizeOptions {
61    pub height: Option<u32>,
62    pub width: Option<u32>,
63}
64
65/// ContainerStartOptions holds parameters to start containers.
66#[derive(Clone, Debug, Default, Builder)]
67#[builder(default, setter(into))]
68pub struct ContainerStartOptions {
69    pub checkpoint_id: Option<String>,
70    pub checkpoint_dir: Option<String>,
71}
72
73/// ContainerAttachOptions holds parameters to attach to a container.
74#[derive(Clone, Debug, Default, Builder)]
75#[builder(default, setter(into))]
76pub struct ContainerAttachOptions {
77    pub stream: bool,
78    pub stdin: bool,
79    pub stdout: bool,
80    pub stderr: bool,
81    pub detach_keys: Option<String>,
82    pub logs: bool,
83}
84
85/// CopyToContainerOptions holds information
86/// about files to copy into a container.
87#[derive(Clone, Debug, Default, Builder)]
88#[builder(default, setter(into))]
89pub struct CopyToContainerOptions {
90    pub allow_overwrite_dir_with_file: bool,
91    pub copy_uid_gid: bool,
92}
93
94/// ContainerRemoveOptions holds parameters to remove containers.
95#[derive(Clone, Debug, Default, Builder)]
96#[builder(default, setter(into))]
97pub struct ContainerRemoveOptions {
98    pub remove_volumes: bool,
99    pub remove_links: bool,
100    pub force: bool,
101}
102
103// NetworkListOptions holds parameters to filter the list of networks with.
104#[derive(Clone, Debug, Default, Builder)]
105#[builder(default, setter(into))]
106pub struct NetworkListOptions {
107    pub filters: Option<Args>,
108}
109
110/// NetworkInspectOptions holds parameters to inspect network.
111#[derive(Clone, Debug, Default, Builder)]
112#[builder(default, setter(into))]
113pub struct NetworkInspectOptions {
114    pub scope: Option<String>,
115    pub verbose: bool,
116}
117
118/// ContainerCreateCreatedBody OK response to ContainerCreate operation.
119#[derive(Clone, Debug, Deserialize)]
120pub struct ContainerCreateCreatedBody {
121    /// The ID of the created container.
122    #[serde(rename = "Id")]
123    pub id: String,
124    /// Warnings encountered when creating the container.
125    #[serde(rename = "Warnings")]
126    pub warnings: Option<Vec<String>>,
127}
128
129/// ContainerTopOKBody OK response to ContainerTop operation.
130#[derive(Clone, Debug, Deserialize)]
131pub struct ContainerTopOKBody {
132    /// Each process running in the container, where each is process is an array of values \
133    /// corresponding to the titles.
134    #[serde(rename = "Processes")]
135    pub processes: Vec<Vec<String>>,
136    /// The ps column titles.
137    #[serde(rename = "Titles")]
138    pub titles: Vec<String>,
139}
140
141/// ContainerChangeResponseItem change item in response to ContainerChanges operation.
142#[derive(Clone, Debug, Deserialize)]
143pub struct ContainerChangeResponseItem {
144    /// Kind of change.
145    #[serde(rename = "Kind")]
146    pub kind: u8,
147    /// Path to file that has changed.
148    #[serde(rename = "Path")]
149    pub path: String,
150}
151
152/// ContainerUpdateOKBody OK response to ContainerUpdate operation.
153#[derive(Clone, Debug, Deserialize)]
154pub struct ContainerUpdateOKBody {
155    /// Warnings.
156    #[serde(rename = "Warnings")]
157    pub warnings: Option<Vec<String>>,
158}
159
160/// ContainerWaitOKBody OK response to ContainerWait operation.
161#[derive(Clone, Debug, Deserialize)]
162pub struct ContainerWaitOKBody {
163    /// Error.
164    #[serde(rename = "Error")]
165    pub error: Option<Vec<String>>,
166    /// Exit code of the container.
167    #[serde(rename = "StatusCode")]
168    pub status_code: i64,
169}
170
171/// ContainerPathStat is used to encode the header from
172/// GET "/containers/{name:.*}/archive"
173/// "Name" is the file or directory name.
174#[derive(Clone, Debug, Deserialize)]
175pub struct ContainerPathStat {
176    pub name: String,
177    pub size: i64,
178    pub mode: u32,
179    pub mtime: String,
180    #[serde(rename = "linkTarget")]
181    pub link_target: Option<String>,
182}
183
184/// ContainersPruneReport contains the response for Engine API:
185/// POST "/containers/prune".
186#[derive(Clone, Debug, Deserialize)]
187pub struct ContainersPruneReport {
188    #[serde(rename = "ContainersDeleted")]
189    pub containers_deleted: Option<Vec<String>>,
190    #[serde(rename = "SpaceReclaimed")]
191    pub space_reclaimed: Option<u64>,
192}
193
194/// ContainerStats contains response of Engine API.
195pub struct ContainerStats {
196    pub body: StatsStream,
197    pub os_type: String,
198}
199
200/// VolumeCreateBody Volume configuration.
201#[derive(Clone, Debug, Serialize, Default, Builder)]
202#[builder(default, setter(into))]
203pub struct VolumeCreateBody {
204    /// Name of the volume driver to use.
205    #[serde(rename = "Driver")]
206    #[serde(skip_serializing_if = "Option::is_none")]
207    pub driver: Option<String>,
208    /// A mapping of driver options and values. These options are passed directly to the driver
209    /// and are driver specific.
210    #[serde(rename = "DriverOpts")]
211    #[serde(skip_serializing_if = "Option::is_none")]
212    pub driver_opts: Option<HashMap<String, String>>,
213    /// User-defined key/value metadata.
214    #[serde(rename = "Labels")]
215    #[serde(skip_serializing_if = "Option::is_none")]
216    pub labels: Option<HashMap<String, String>>,
217    /// The new volume's name. If not specified, Docker generates a name.
218    #[serde(rename = "Name")]
219    #[serde(skip_serializing_if = "Option::is_none")]
220    pub name: Option<String>,
221}
222
223/// VolumeListOKBody Volume list response.
224#[derive(Clone, Debug, Deserialize)]
225pub struct VolumeListOKBody {
226    /// List of volumes.
227    #[serde(rename = "Volumes")]
228    pub volumes: Option<Vec<Volume>>,
229    /// Warnings that occurred when fetching the list of volumes.
230    #[serde(rename = "Warnings")]
231    pub warnings: Option<Vec<String>>,
232}
233
234/// VolumesPruneReport contains the response for Engine API:
235/// POST "/volumes/prune"
236#[derive(Clone, Debug, Deserialize)]
237pub struct VolumesPruneReport {
238    #[serde(rename = "VolumesDeleted")]
239    pub volumes_deleted: Option<Vec<String>>,
240    #[serde(rename = "SpaceReclaimed")]
241    pub space_reclaimed: Option<u64>,
242}
243
244/// NetworkCreateResponse is the response message sent by the server for network create call.
245#[derive(Clone, Debug, Deserialize)]
246pub struct NetworkCreateResponse {
247    #[serde(rename = "Id")]
248    pub id: String,
249    #[serde(rename = "Warning")]
250    pub warning: Option<String>,
251}
252
253/// NetworksPruneReport contains the response for Engine API.
254#[derive(Clone, Debug, Deserialize)]
255pub struct NetworksPruneReport {
256    #[serde(rename = "NetworksDeleted")]
257    pub networks_deleted: Option<Vec<String>>,
258}
259
260/// NetworkConnect represents the data to be used to connect a container to the network.
261#[derive(Clone, Debug, Serialize)]
262pub struct NetworkConnect {
263    #[serde(rename = "Container")]
264    pub container: String,
265    #[serde(rename = "EndpointConfig")]
266    #[serde(skip_serializing_if = "Option::is_none")]
267    pub endpoint_config: Option<EndpointSettings>,
268}
269
270/// NetworkDisconnect represents the data to be used to disconnect a container from the network.
271#[derive(Clone, Debug, Serialize)]
272pub struct NetworkDisconnect {
273    #[serde(rename = "Container")]
274    pub container: String,
275    #[serde(rename = "Force")]
276    #[serde(skip_serializing_if = "Option::is_none")]
277    pub force: Option<bool>,
278}