docker-client-async 0.1.0

A modern async/await Docker client written in Rust.
Documentation
/*
 * Copyright 2020 Damian Peckett <damian@pecke.tt>.
 * Copyright 2013-2018 Docker, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

use crate::container::StatsStream;
use crate::types::filters::Args;
use crate::types::network::EndpointSettings;
use crate::types::volume::Volume;
use derive_builder::Builder;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::time::SystemTime;

/// ContainerListOptions holds parameters to list containers with.
#[derive(Clone, Debug, Default, Builder)]
#[builder(default, setter(into))]
pub struct ContainerListOptions {
    /// Return the size of container as fields SizeRw and SizeRootFs.
    pub size: bool,
    /// Return all containers. By default, only running containers are shown.
    pub all: bool,
    /// Return this number of most recently created containers, including non-running ones.
    pub limit: Option<usize>,
    /// Filters to process on the container list.
    pub filters: Option<super::filters::Args>,
}

/// ContainerLogsOptions holds parameters to filter logs with.
#[derive(Clone, Debug, Default, Builder)]
#[builder(default, setter(into))]
pub struct ContainerLogsOptions {
    pub show_stdout: bool,
    pub show_stderr: bool,
    pub since: Option<SystemTime>,
    pub until: Option<SystemTime>,
    pub timestamps: bool,
    pub follow: bool,
    pub tail: Option<String>,
    pub details: bool,
}

/// ResizeOptions holds parameters to resize a tty.
/// It can be used to resize container ttys and
/// exec process ttys too.
#[derive(Clone, Debug, Default, Builder)]
#[builder(default, setter(into))]
pub struct ResizeOptions {
    pub height: Option<u32>,
    pub width: Option<u32>,
}

/// ContainerStartOptions holds parameters to start containers.
#[derive(Clone, Debug, Default, Builder)]
#[builder(default, setter(into))]
pub struct ContainerStartOptions {
    pub checkpoint_id: Option<String>,
    pub checkpoint_dir: Option<String>,
}

/// ContainerAttachOptions holds parameters to attach to a container.
#[derive(Clone, Debug, Default, Builder)]
#[builder(default, setter(into))]
pub struct ContainerAttachOptions {
    pub stream: bool,
    pub stdin: bool,
    pub stdout: bool,
    pub stderr: bool,
    pub detach_keys: Option<String>,
    pub logs: bool,
}

/// CopyToContainerOptions holds information
/// about files to copy into a container.
#[derive(Clone, Debug, Default, Builder)]
#[builder(default, setter(into))]
pub struct CopyToContainerOptions {
    pub allow_overwrite_dir_with_file: bool,
    pub copy_uid_gid: bool,
}

/// ContainerRemoveOptions holds parameters to remove containers.
#[derive(Clone, Debug, Default, Builder)]
#[builder(default, setter(into))]
pub struct ContainerRemoveOptions {
    pub remove_volumes: bool,
    pub remove_links: bool,
    pub force: bool,
}

// NetworkListOptions holds parameters to filter the list of networks with.
#[derive(Clone, Debug, Default, Builder)]
#[builder(default, setter(into))]
pub struct NetworkListOptions {
    pub filters: Option<Args>,
}

/// NetworkInspectOptions holds parameters to inspect network.
#[derive(Clone, Debug, Default, Builder)]
#[builder(default, setter(into))]
pub struct NetworkInspectOptions {
    pub scope: Option<String>,
    pub verbose: bool,
}

/// ContainerCreateCreatedBody OK response to ContainerCreate operation.
#[derive(Clone, Debug, Deserialize)]
pub struct ContainerCreateCreatedBody {
    /// The ID of the created container.
    #[serde(rename = "Id")]
    pub id: String,
    /// Warnings encountered when creating the container.
    #[serde(rename = "Warnings")]
    pub warnings: Option<Vec<String>>,
}

/// ContainerTopOKBody OK response to ContainerTop operation.
#[derive(Clone, Debug, Deserialize)]
pub struct ContainerTopOKBody {
    /// Each process running in the container, where each is process is an array of values \
    /// corresponding to the titles.
    #[serde(rename = "Processes")]
    pub processes: Vec<Vec<String>>,
    /// The ps column titles.
    #[serde(rename = "Titles")]
    pub titles: Vec<String>,
}

/// ContainerChangeResponseItem change item in response to ContainerChanges operation.
#[derive(Clone, Debug, Deserialize)]
pub struct ContainerChangeResponseItem {
    /// Kind of change.
    #[serde(rename = "Kind")]
    pub kind: u8,
    /// Path to file that has changed.
    #[serde(rename = "Path")]
    pub path: String,
}

/// ContainerUpdateOKBody OK response to ContainerUpdate operation.
#[derive(Clone, Debug, Deserialize)]
pub struct ContainerUpdateOKBody {
    /// Warnings.
    #[serde(rename = "Warnings")]
    pub warnings: Option<Vec<String>>,
}

/// ContainerWaitOKBody OK response to ContainerWait operation.
#[derive(Clone, Debug, Deserialize)]
pub struct ContainerWaitOKBody {
    /// Error.
    #[serde(rename = "Error")]
    pub error: Option<Vec<String>>,
    /// Exit code of the container.
    #[serde(rename = "StatusCode")]
    pub status_code: i64,
}

/// ContainerPathStat is used to encode the header from
/// GET "/containers/{name:.*}/archive"
/// "Name" is the file or directory name.
#[derive(Clone, Debug, Deserialize)]
pub struct ContainerPathStat {
    pub name: String,
    pub size: i64,
    pub mode: u32,
    pub mtime: String,
    #[serde(rename = "linkTarget")]
    pub link_target: Option<String>,
}

/// ContainersPruneReport contains the response for Engine API:
/// POST "/containers/prune".
#[derive(Clone, Debug, Deserialize)]
pub struct ContainersPruneReport {
    #[serde(rename = "ContainersDeleted")]
    pub containers_deleted: Option<Vec<String>>,
    #[serde(rename = "SpaceReclaimed")]
    pub space_reclaimed: Option<u64>,
}

/// ContainerStats contains response of Engine API.
pub struct ContainerStats {
    pub body: StatsStream,
    pub os_type: String,
}

/// VolumeCreateBody Volume configuration.
#[derive(Clone, Debug, Serialize, Default, Builder)]
#[builder(default, setter(into))]
pub struct VolumeCreateBody {
    /// Name of the volume driver to use.
    #[serde(rename = "Driver")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub driver: Option<String>,
    /// A mapping of driver options and values. These options are passed directly to the driver
    /// and are driver specific.
    #[serde(rename = "DriverOpts")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub driver_opts: Option<HashMap<String, String>>,
    /// User-defined key/value metadata.
    #[serde(rename = "Labels")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub labels: Option<HashMap<String, String>>,
    /// The new volume's name. If not specified, Docker generates a name.
    #[serde(rename = "Name")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
}

/// VolumeListOKBody Volume list response.
#[derive(Clone, Debug, Deserialize)]
pub struct VolumeListOKBody {
    /// List of volumes.
    #[serde(rename = "Volumes")]
    pub volumes: Option<Vec<Volume>>,
    /// Warnings that occurred when fetching the list of volumes.
    #[serde(rename = "Warnings")]
    pub warnings: Option<Vec<String>>,
}

/// VolumesPruneReport contains the response for Engine API:
/// POST "/volumes/prune"
#[derive(Clone, Debug, Deserialize)]
pub struct VolumesPruneReport {
    #[serde(rename = "VolumesDeleted")]
    pub volumes_deleted: Option<Vec<String>>,
    #[serde(rename = "SpaceReclaimed")]
    pub space_reclaimed: Option<u64>,
}

/// NetworkCreateResponse is the response message sent by the server for network create call.
#[derive(Clone, Debug, Deserialize)]
pub struct NetworkCreateResponse {
    #[serde(rename = "Id")]
    pub id: String,
    #[serde(rename = "Warning")]
    pub warning: Option<String>,
}

/// NetworksPruneReport contains the response for Engine API.
#[derive(Clone, Debug, Deserialize)]
pub struct NetworksPruneReport {
    #[serde(rename = "NetworksDeleted")]
    pub networks_deleted: Option<Vec<String>>,
}

/// NetworkConnect represents the data to be used to connect a container to the network.
#[derive(Clone, Debug, Serialize)]
pub struct NetworkConnect {
    #[serde(rename = "Container")]
    pub container: String,
    #[serde(rename = "EndpointConfig")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub endpoint_config: Option<EndpointSettings>,
}

/// NetworkDisconnect represents the data to be used to disconnect a container from the network.
#[derive(Clone, Debug, Serialize)]
pub struct NetworkDisconnect {
    #[serde(rename = "Container")]
    pub container: String,
    #[serde(rename = "Force")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub force: Option<bool>,
}