nullnet_libdatastore/builders/
batch_delete_request_builder.rs1use crate::datastore::{AdvanceFilter, BatchDeleteBody, BatchDeleteRequest, Params};
2
3#[derive(Debug, Default)]
4pub struct BatchDeleteRequestBuilder {
5 id: Option<String>,
6 table: Option<String>,
7 is_root: bool,
8 advance_filters: Vec<AdvanceFilter>,
9}
10
11impl BatchDeleteRequestBuilder {
12 pub fn new() -> Self {
13 Default::default()
14 }
15
16 pub fn id(mut self, id: impl Into<String>) -> Self {
17 self.id = Some(id.into());
18 self
19 }
20
21 pub fn table(mut self, table: impl Into<String>) -> Self {
22 self.table = Some(table.into());
23 self
24 }
25
26 pub fn performed_by_root(mut self, value: bool) -> Self {
27 self.is_root = value;
28 self
29 }
30
31 pub fn advance_filter(mut self, filter: AdvanceFilter) -> Self {
32 self.advance_filters.push(filter);
33 self
34 }
35
36 pub fn advance_filters(mut self, filters: impl IntoIterator<Item = AdvanceFilter>) -> Self {
37 self.advance_filters.extend(filters);
38 self
39 }
40
41 pub fn build(self) -> BatchDeleteRequest {
42 BatchDeleteRequest {
43 params: Some(Params {
44 id: self.id.unwrap_or_default(),
45 table: self.table.unwrap_or_default(),
46 r#type: if self.is_root {
47 String::from("root")
48 } else {
49 String::new()
50 },
51 }),
52 body: Some(BatchDeleteBody {
53 advance_filters: self.advance_filters,
54 }),
55 }
56 }
57}