#[derive(Debug, Default)]
pub struct RemoverBuilder {
id: String,
v: Option<bool>,
force: Option<bool>,
link: Option<bool>
}
#[derive(Debug)]
pub struct Remover {
id: String,
v: Option<bool>,
force: Option<bool>,
link: Option<bool>
}
impl Remover {
pub fn new() -> RemoverBuilder {
RemoverBuilder::default()
}
pub fn get_path(&self) -> String {
let mut path = format!("/containers/{}?", self.id);
if self.v.is_some() {
path.push_str(format!("v={}&", self.v.unwrap()).as_str());
}
if self.force.is_some() {
path.push_str(format!("force={}&", self.force.unwrap()).as_str());
}
if self.link.is_some() {
path.push_str(format!("link={}&", self.link.unwrap()).as_str());
}
path.pop();
path
}
}
impl RemoverBuilder {
pub fn new() -> Self {
RemoverBuilder::default()
}
pub fn id<T>(&mut self, id: T) -> &mut Self
where T: Into<String>
{
self.id = id.into();
self
}
pub fn with_remove_volumes(&mut self, v: bool) -> &mut Self {
self.v = Some(v);
self
}
pub fn with_force_delete(&mut self, v: bool) -> &mut Self {
self.force = Some(v);
self
}
pub fn with_remove_link(&mut self, v: bool) -> &mut Self {
self.link = Some(v);
self
}
pub fn build(&self) -> Remover {
Remover {
id: self.id.clone(),
v: self.v,
force: self.force,
link: self.link
}
}
}