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
mod containers;
mod exec;
mod images;
mod pods;
mod volumes;
pub use containers::*;
pub use exec::*;
pub use images::*;
pub use pods::*;
pub use volumes::*;
pub type EventsConstraint = (String, Vec<String>);
impl_opts_builder!(
url =>
Events
);
impl EventsOptsBuilder {
impl_url_str_field!(
since => "since"
);
impl_url_str_field!(
until => "until"
);
impl_url_bool_field!(
stream => "stream"
);
pub fn filters<F>(mut self, filters: F) -> Self
where
F: IntoIterator<Item = EventsConstraint>,
{
let filters: std::collections::HashMap<_, _> = filters.into_iter().collect();
self.params.insert(
"filters",
serde_json::to_string(&filters).unwrap_or_default(),
);
self
}
}
#[derive(serde::Serialize, Debug, Clone)]
pub struct SecretCreateOpts {
name: String,
driver: Option<String>,
}
impl SecretCreateOpts {
pub fn builder(name: impl Into<String>) -> SecretCreateOptsBuilder {
SecretCreateOptsBuilder {
name: name.into(),
driver: None,
}
}
pub fn serialize(&self) -> Option<String> {
if self.name.is_empty() {
return None;
}
let mut params = vec![("name", self.name.clone())];
if let Some(driver) = &self.driver {
params.push(("driver", driver.clone()));
}
Some(crate::util::url::encoded_pairs(params))
}
}
#[derive(Debug, Clone)]
pub struct SecretCreateOptsBuilder {
name: String,
driver: Option<String>,
}
impl SecretCreateOptsBuilder {
pub fn driver(mut self, driver: impl Into<String>) -> Self {
self.driver = Some(driver.into());
self
}
pub fn build(self) -> SecretCreateOpts {
SecretCreateOpts {
name: self.name,
driver: self.driver,
}
}
}