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