docker_client_async/types/
volume.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 derive_builder::Builder;
19use serde::{Deserialize, Serialize};
20use serde_json::Value;
21use std::collections::HashMap;
22
23/// Volume volume.
24#[derive(Clone, Debug, Default, Deserialize, Serialize, Builder)]
25#[builder(default, setter(into))]
26pub struct Volume {
27    /// Date/Time the volume was created.
28    #[serde(rename = "CreatedAt")]
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub created_at: Option<String>,
31    /// Name of the volume driver used by the volume.
32    #[serde(rename = "Driver")]
33    #[serde(skip_serializing_if = "Option::is_none")]
34    pub driver: Option<String>,
35    /// User-defined key/value metadata.
36    #[serde(rename = "Labels")]
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub labels: Option<HashMap<String, String>>,
39    /// Mount path of the volume on the host.
40    #[serde(rename = "Mountpoint")]
41    #[serde(skip_serializing_if = "Option::is_none")]
42    pub mountpoint: Option<String>,
43    /// Name of the volume.
44    #[serde(rename = "Name")]
45    #[serde(skip_serializing_if = "Option::is_none")]
46    pub name: Option<String>,
47    /// The driver specific options used when creating the volume.
48    #[serde(rename = "Options")]
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub options: Option<HashMap<String, String>>,
51    /// The level at which the volume exists. Either `global` for cluster-wide, or `local`
52    /// for machine level.
53    #[serde(rename = "Scope")]
54    #[serde(skip_serializing_if = "Option::is_none")]
55    pub scope: Option<String>,
56    /// Low-level details about the volume, provided by the volume driver.
57    /// Details are returned as a map with key/value pairs:
58    /// `{"key":"value","key2":"value2"}`.
59    /// The `Status` field is optional, and is omitted if the volume driver
60    /// does not support this feature.
61    #[serde(rename = "Status")]
62    #[serde(skip_serializing_if = "Option::is_none")]
63    pub status: Option<HashMap<String, Value>>,
64    /// usage data.
65    #[serde(rename = "UsageData")]
66    #[serde(skip_serializing_if = "Option::is_none")]
67    pub usage_data: Option<VolumeUsageData>,
68}
69
70/// VolumeUsageData Usage details about the volume. This information is used by the
71/// `GET /system/df` endpoint, and omitted in other endpoints.
72#[derive(Clone, Debug, Default, Deserialize, Serialize, Builder)]
73#[builder(default, setter(into))]
74pub struct VolumeUsageData {
75    /// The number of containers referencing this volume. This field
76    /// is set to `-1` if the reference-count is not available.
77    #[serde(rename = "RefCount")]
78    #[serde(skip_serializing_if = "Option::is_none")]
79    pub ref_count: Option<i64>,
80    /// Amount of disk space used by the volume (in bytes). This information
81    /// is only available for volumes created with the `"local"` volume
82    /// driver. For volumes created with other volume drivers, this field
83    /// is set to `-1` ("not available").
84    #[serde(rename = "Size")]
85    #[serde(skip_serializing_if = "Option::is_none")]
86    pub size: Option<i64>,
87}