ic_query/nns/node/report/model/
request.rs1use crate::nns::NnsInventoryCacheRequest;
2
3#[derive(Clone, Debug, Eq, PartialEq)]
10pub struct NnsNodeListRequest {
11 pub cache: NnsInventoryCacheRequest,
12 pub source_endpoint: String,
13 pub now_unix_secs: u64,
14 pub filters: NnsNodeListFilters,
15}
16
17impl NnsNodeListRequest {
18 #[must_use]
19 pub fn new(
20 cache: NnsInventoryCacheRequest,
21 source_endpoint: impl Into<String>,
22 now_unix_secs: u64,
23 ) -> Self {
24 Self {
25 cache,
26 source_endpoint: source_endpoint.into(),
27 now_unix_secs,
28 filters: NnsNodeListFilters::default(),
29 }
30 }
31
32 #[must_use]
33 pub fn with_filters(mut self, filters: NnsNodeListFilters) -> Self {
34 self.filters = filters;
35 self
36 }
37
38 #[must_use]
39 pub fn with_subnet(mut self, subnet: impl Into<String>) -> Self {
40 self.filters.subnet = Some(subnet.into());
41 self
42 }
43
44 #[must_use]
45 pub fn with_subnet_kind(mut self, subnet_kind: impl Into<String>) -> Self {
46 self.filters.subnet_kind = Some(subnet_kind.into());
47 self
48 }
49
50 #[must_use]
51 pub fn with_data_center(mut self, data_center: impl Into<String>) -> Self {
52 self.filters.data_center = Some(data_center.into());
53 self
54 }
55
56 #[must_use]
57 pub fn with_node_provider(mut self, node_provider: impl Into<String>) -> Self {
58 self.filters.node_provider = Some(node_provider.into());
59 self
60 }
61
62 #[must_use]
63 pub fn with_node_operator(mut self, node_operator: impl Into<String>) -> Self {
64 self.filters.node_operator = Some(node_operator.into());
65 self
66 }
67}
68
69#[derive(Clone, Debug, Default, Eq, PartialEq)]
76pub struct NnsNodeListFilters {
77 pub subnet: Option<String>,
78 pub subnet_kind: Option<String>,
79 pub data_center: Option<String>,
80 pub node_provider: Option<String>,
81 pub node_operator: Option<String>,
82}
83
84impl NnsNodeListFilters {
85 #[must_use]
86 pub const fn is_empty(&self) -> bool {
87 self.subnet.is_none()
88 && self.subnet_kind.is_none()
89 && self.data_center.is_none()
90 && self.node_provider.is_none()
91 && self.node_operator.is_none()
92 }
93}