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_subnet(mut self, subnet: impl Into<String>) -> Self {
32 self.filters.subnet = Some(subnet.into());
33 self
34 }
35
36 #[must_use]
37 pub const fn with_subnet_kind(mut self, subnet_kind: SubnetKind) -> Self {
38 self.filters.subnet_kind = Some(subnet_kind);
39 self
40 }
41
42 #[must_use]
43 pub fn with_data_center(mut self, data_center: impl Into<String>) -> Self {
44 self.filters.data_center = Some(data_center.into());
45 self
46 }
47
48 #[must_use]
49 pub fn with_node_provider(mut self, node_provider: impl Into<String>) -> Self {
50 self.filters.node_provider = Some(node_provider.into());
51 self
52 }
53
54 #[must_use]
55 pub fn with_node_operator(mut self, node_operator: impl Into<String>) -> Self {
56 self.filters.node_operator = Some(node_operator.into());
57 self
58 }
59}
60
61#[derive(Clone, Debug, Default, Eq, PartialEq)]
68pub struct NnsNodeListFilters {
69 pub subnet: Option<String>,
70 pub subnet_kind: Option<SubnetKind>,
71 pub data_center: Option<String>,
72 pub node_provider: Option<String>,
73 pub node_operator: Option<String>,
74}
75
76impl NnsNodeListFilters {
77 #[must_use]
78 pub const fn is_empty(&self) -> bool {
79 self.subnet.is_none()
80 && self.subnet_kind.is_none()
81 && self.data_center.is_none()
82 && self.node_provider.is_none()
83 && self.node_operator.is_none()
84 }
85}