Skip to main content

ic_query/nns/data_center/report/model/
report.rs

1#[cfg(feature = "host")]
2use crate::cache_file::JsonCacheReport;
3use serde::{Deserialize, Serialize};
4
5///
6/// NnsDataCenterListReport
7///
8/// Complete NNS data center inventory report with source metadata.
9///
10
11#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
12pub struct NnsDataCenterListReport {
13    pub schema_version: u32,
14    pub network: String,
15    pub registry_canister_id: String,
16    pub registry_version: u64,
17    pub fetched_at: String,
18    pub source_endpoint: String,
19    pub fetched_by: String,
20    pub data_center_count: usize,
21    pub data_centers: Vec<NnsDataCenterRow>,
22}
23
24#[cfg(feature = "host")]
25impl JsonCacheReport for NnsDataCenterListReport {
26    fn schema_version(&self) -> u32 {
27        self.schema_version
28    }
29
30    fn network(&self) -> &str {
31        &self.network
32    }
33}
34
35#[cfg(feature = "host")]
36impl_nns_inventory_report!(
37    NnsDataCenterListReport,
38    super::super::NNS_DATA_CENTER_LIST_REPORT_SCHEMA_VERSION,
39    "data_center",
40    data_center_count,
41    data_centers,
42);
43
44///
45/// NnsDataCenterRow
46///
47/// One data center row projected from the NNS registry inventory.
48///
49
50#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
51pub struct NnsDataCenterRow {
52    pub data_center_id: String,
53    pub region: String,
54    pub owner: String,
55    pub latitude: Option<f32>,
56    pub longitude: Option<f32>,
57    pub node_operator_count: u32,
58    pub node_provider_count: u32,
59    pub node_count: u32,
60}
61
62///
63/// NnsDataCenterInfoReport
64///
65/// Detailed report for one resolved NNS data center.
66///
67
68#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
69pub struct NnsDataCenterInfoReport {
70    pub schema_version: u32,
71    pub input: String,
72    pub resolved_from: String,
73    pub network: String,
74    pub registry_canister_id: String,
75    pub registry_version: u64,
76    pub fetched_at: String,
77    pub source_endpoint: String,
78    pub fetched_by: String,
79    pub data_center_id: String,
80    pub region: String,
81    pub owner: String,
82    pub latitude: Option<f32>,
83    pub longitude: Option<f32>,
84    pub node_operator_count: u32,
85    pub node_provider_count: u32,
86    pub node_count: u32,
87}
88
89///
90/// NnsDataCenterRefreshReport
91///
92/// Outcome of refreshing the cached NNS data center inventory.
93///
94
95#[cfg(feature = "host")]
96#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
97pub struct NnsDataCenterRefreshReport {
98    pub schema_version: u32,
99    pub network: String,
100    pub cache_path: String,
101    pub refresh_lock_path: String,
102    pub output_path: Option<String>,
103    pub registry_canister_id: String,
104    pub registry_version: u64,
105    pub fetched_at: String,
106    pub source_endpoint: String,
107    pub fetched_by: String,
108    pub dry_run: bool,
109    pub wrote_cache: bool,
110    pub replaced_existing_cache: bool,
111    pub data_center_count: usize,
112}