ic_query/ic/model/reports.rs
1//! Module: ic::model::reports
2//!
3//! Responsibility: public serialized Dashboard report, row, and provenance contracts.
4//! Does not own: requests, host source data, errors, transport, or projection.
5//! Boundary: preserves raw Dashboard values and explicit off-chain provenance.
6
7use super::requests::{
8 IcCanisterFilters, IcDailyStatsQuery, IcIcrcIndexedCountKind, IcIcrcTokenValueQuery,
9 IcIcrcTotalSupplyQuery, IcMetricQuery,
10};
11use serde::Serialize;
12
13///
14/// IcCanisterUpgrade
15///
16/// One proposal-linked canister upgrade recorded by the Dashboard API.
17///
18
19#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
20pub struct IcCanisterUpgrade {
21 /// Proposal execution time as raw Unix seconds.
22 pub executed_timestamp_seconds: u64,
23 /// Wasm module hash as raw lowercase hexadecimal text.
24 pub module_hash: String,
25 /// NNS proposal that installed this module.
26 pub proposal_id: u64,
27}
28
29///
30/// IcDashboardReportProvenance
31///
32/// Shared off-chain provenance and authority guarantees for Dashboard reports.
33///
34
35#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
36pub struct IcDashboardReportProvenance {
37 /// Report schema version.
38 pub schema_version: u32,
39 /// Network represented by the official Dashboard API.
40 pub network: String,
41 /// Authority that supplied the report fields.
42 pub authority: String,
43 /// Dashboard API base endpoint queried by the source.
44 pub source_endpoint: String,
45 /// Time this report was collected.
46 pub fetched_at: String,
47 /// Collector identity.
48 pub fetched_by: String,
49 /// Whether the API response is cryptographically certified IC state.
50 pub certified: bool,
51 /// Whether every returned value is guaranteed to describe one point in time.
52 pub point_in_time_guaranteed: bool,
53}
54
55///
56/// IcMetricObservation
57///
58/// One raw timestamp and value returned by the Dashboard Metrics API.
59///
60
61#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
62pub struct IcMetricObservation {
63 /// Observation timestamp as Unix seconds.
64 pub timestamp_unix_secs: u64,
65 /// Raw value string returned by the Dashboard.
66 pub value: String,
67}
68
69///
70/// IcMetricSeries
71///
72/// One named raw series in a Dashboard metric response.
73///
74
75#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
76pub struct IcMetricSeries {
77 /// Raw Dashboard response field that names this series.
78 pub name: String,
79 /// Observations in strictly increasing timestamp order.
80 pub observations: Vec<IcMetricObservation>,
81}
82
83///
84/// IcMetricReport
85///
86/// One bounded time-series response from the official Dashboard Metrics API.
87///
88
89#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
90pub struct IcMetricReport {
91 /// Shared Dashboard provenance, flattened in serialized report JSON.
92 #[serde(flatten)]
93 pub provenance: IcDashboardReportProvenance,
94 /// Metric and explicit time-series bounds, flattened in report JSON.
95 #[serde(flatten)]
96 pub query: IcMetricQuery,
97 /// Number of named series returned by the API.
98 pub returned_series_count: usize,
99 /// Total number of observations across all returned series.
100 pub returned_observation_count: usize,
101 /// Raw named time series in canonical series-name order.
102 pub series: Vec<IcMetricSeries>,
103}
104
105///
106/// IcIcrcTotalSupplyObservation
107///
108/// One raw ICRC ledger total-supply observation returned by the Dashboard API.
109///
110
111#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
112pub struct IcIcrcTotalSupplyObservation {
113 /// Observation timestamp as Unix seconds.
114 pub timestamp_unix_secs: u64,
115 /// Raw total supply in ledger base units.
116 pub total_supply_base_units: String,
117}
118
119///
120/// IcIcrcTotalSupplyReport
121///
122/// One bounded total-supply series from the official Dashboard ICRC API.
123///
124
125#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
126pub struct IcIcrcTotalSupplyReport {
127 /// Shared Dashboard provenance, flattened in serialized report JSON.
128 #[serde(flatten)]
129 pub provenance: IcDashboardReportProvenance,
130 /// Canonical ICRC ledger canister principal requested from the API.
131 pub ledger_canister_id: String,
132 /// Exact requested time bounds, flattened in report JSON.
133 #[serde(flatten)]
134 pub query: IcIcrcTotalSupplyQuery,
135 /// Maximum observations implied by the requested inclusive window.
136 pub requested_observation_limit: u64,
137 /// Number of observations returned by the API.
138 pub returned_observation_count: usize,
139 /// Raw observations in strictly increasing timestamp order.
140 pub observations: Vec<IcIcrcTotalSupplyObservation>,
141}
142
143///
144/// IcIcrcIndexedCountReport
145///
146/// One current scalar count from the official Dashboard ICRC index.
147///
148
149#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
150pub struct IcIcrcIndexedCountReport {
151 /// Shared Dashboard provenance, flattened in serialized report JSON.
152 #[serde(flatten)]
153 pub provenance: IcDashboardReportProvenance,
154 /// Canonical ICRC ledger canister principal requested from the API.
155 pub ledger_canister_id: String,
156 /// Indexed resource represented by this count.
157 pub kind: IcIcrcIndexedCountKind,
158 /// Number of matching resources currently represented by the Dashboard index.
159 pub total: u64,
160}
161
162///
163/// IcIcrcTokenValueRow
164///
165/// One raw externally sourced token-value record returned by the Dashboard API.
166///
167
168#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
169pub struct IcIcrcTokenValueRow {
170 /// Raw legacy price field in USD, when returned.
171 pub price: Option<String>,
172 /// Raw legacy 24-hour volume field in USD, when returned.
173 pub volume_24h: Option<String>,
174 /// Raw explicit price-in-USD field, when returned.
175 pub price_usd: Option<String>,
176 /// Raw explicit 24-hour volume-in-USD field, when returned.
177 pub volume_24h_usd: Option<String>,
178 /// External value provider named by the Dashboard, when returned.
179 pub source: Option<String>,
180 /// External value-provider URL returned by the Dashboard, when present.
181 pub source_url: Option<String>,
182 /// Observation timestamp as Unix seconds.
183 pub timestamp_unix_secs: u64,
184}
185
186///
187/// IcIcrcTokenValueReport
188///
189/// One bounded token-value series from the official Dashboard ICRC API.
190///
191
192#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
193pub struct IcIcrcTokenValueReport {
194 /// Shared Dashboard provenance, flattened in serialized report JSON.
195 #[serde(flatten)]
196 pub provenance: IcDashboardReportProvenance,
197 /// Canonical ICRC ledger canister principal requested from the API.
198 pub ledger_canister_id: String,
199 /// Exact requested time and row bounds, flattened in report JSON.
200 #[serde(flatten)]
201 pub query: IcIcrcTokenValueQuery,
202 /// Number of rows returned by the API.
203 pub returned_row_count: usize,
204 /// Whether the response reached the requested limit and may be truncated.
205 pub limit_reached: bool,
206 /// Raw token-value rows in nondecreasing timestamp order.
207 pub rows: Vec<IcIcrcTokenValueRow>,
208}
209
210///
211/// IcDailyStatsRow
212///
213/// Selected raw daily network-activity values returned by the Dashboard API.
214///
215
216#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
217pub struct IcDailyStatsRow {
218 /// Raw UTC calendar day returned by the Dashboard.
219 pub day: String,
220 /// Observation timestamp as Unix seconds.
221 pub timestamp_unix_secs: u64,
222 /// Raw average query-transaction rate.
223 pub average_query_transactions_per_second: String,
224 /// Raw average update-transaction rate.
225 pub average_update_transactions_per_second: String,
226 /// Raw average total-transaction rate.
227 pub average_transactions_per_second: String,
228 /// Raw maximum query-transaction rate.
229 pub max_query_transactions_per_second: String,
230 /// Raw maximum update-transaction rate.
231 pub max_update_transactions_per_second: String,
232 /// Raw maximum total-transaction rate.
233 pub max_total_transactions_per_second: String,
234 /// Raw average block-production rate.
235 pub blocks_per_second_average: String,
236}
237
238///
239/// IcDailyStatsReport
240///
241/// One bounded daily network-activity response from the official Dashboard API.
242///
243
244#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
245pub struct IcDailyStatsReport {
246 /// Shared Dashboard provenance, flattened in serialized report JSON.
247 #[serde(flatten)]
248 pub provenance: IcDashboardReportProvenance,
249 /// Exact requested time bounds, flattened in report JSON.
250 #[serde(flatten)]
251 pub query: IcDailyStatsQuery,
252 /// Number of daily rows returned by the API.
253 pub returned_day_count: usize,
254 /// Rows in strictly increasing timestamp order.
255 pub rows: Vec<IcDailyStatsRow>,
256}
257
258///
259/// IcBoundaryNodeDataCenterRow
260///
261/// One raw data-center aggregate returned by the boundary-node API.
262///
263
264#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
265pub struct IcBoundaryNodeDataCenterRow {
266 /// Dashboard data-center identifier.
267 pub dc_id: String,
268 /// Raw data-center display name.
269 pub name: String,
270 /// Raw infrastructure-owner label.
271 pub owner: String,
272 /// Raw Dashboard region label.
273 pub region: String,
274 /// Raw decimal latitude.
275 pub latitude: String,
276 /// Raw decimal longitude.
277 pub longitude: String,
278 /// Raw decimal count of boundary nodes assigned to this data center.
279 pub total_nodes: String,
280}
281
282///
283/// IcBoundaryNodeDataCentersReport
284///
285/// One complete response from the official boundary-node data-center resource.
286///
287
288#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
289pub struct IcBoundaryNodeDataCentersReport {
290 /// Shared Dashboard provenance, flattened in serialized report JSON.
291 #[serde(flatten)]
292 pub provenance: IcDashboardReportProvenance,
293 /// Number of data-center rows returned by the API.
294 pub data_center_count: usize,
295 /// Sum of the raw per-data-center boundary-node counts.
296 pub total_node_count: u64,
297 /// Rows in canonical data-center-id order, including zero-node locations.
298 pub rows: Vec<IcBoundaryNodeDataCenterRow>,
299}
300
301///
302/// IcCanisterReport
303///
304/// One live canister metadata report from the official Dashboard API.
305///
306
307#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
308pub struct IcCanisterReport {
309 /// Shared Dashboard provenance, flattened in serialized report JSON.
310 #[serde(flatten)]
311 pub provenance: IcDashboardReportProvenance,
312 /// Canonical canister principal.
313 pub canister_id: String,
314 /// Dashboard database row identifier.
315 pub dashboard_id: u64,
316 /// Raw optional Dashboard canister classification.
317 pub canister_type: Option<String>,
318 /// Raw Dashboard canister name; an empty string means no name was recorded.
319 pub name: String,
320 /// Canonical Subnet principal recorded by the Dashboard.
321 pub subnet_id: String,
322 /// Canonically ordered controller principals recorded by the Dashboard.
323 pub controllers: Vec<String>,
324 /// Raw Dashboard language label; an empty string means no language was recorded.
325 pub language: String,
326 /// Raw current module hash; an empty string means no hash was recorded.
327 pub module_hash: String,
328 /// Raw Dashboard row update timestamp.
329 pub dashboard_updated_at: String,
330 /// Number of proposal-linked upgrades when history is available.
331 pub upgrade_count: Option<usize>,
332 /// Proposal-linked upgrade history, or `None` when the Dashboard returned `null`.
333 pub upgrades: Option<Vec<IcCanisterUpgrade>>,
334}
335
336///
337/// IcCanisterCountReport
338///
339/// One filtered canister count from the official Dashboard API.
340///
341
342#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
343pub struct IcCanisterCountReport {
344 /// Shared Dashboard provenance, flattened in serialized report JSON.
345 #[serde(flatten)]
346 pub provenance: IcDashboardReportProvenance,
347 /// Filters applied by the Dashboard.
348 pub filters: IcCanisterFilters,
349 /// Number of matching Dashboard canister records.
350 pub total: u64,
351}
352
353///
354/// IcCanisterPageController
355///
356/// One controller entry returned by the Dashboard canister collection API.
357///
358
359#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
360pub struct IcCanisterPageController {
361 /// Canonical controller principal.
362 pub principal_id: String,
363 /// Raw optional Dashboard metadata associated with the controller.
364 pub raw_metadata: Option<String>,
365}
366
367///
368/// IcCanisterPageRow
369///
370/// One discovery row from a bounded Dashboard canister page.
371///
372
373#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
374pub struct IcCanisterPageRow {
375 /// Canonical canister principal.
376 pub canister_id: String,
377 /// Dashboard database row identifier.
378 pub dashboard_id: u64,
379 /// Raw optional Dashboard canister classification.
380 pub canister_type: Option<String>,
381 /// Raw Dashboard canister name.
382 pub name: String,
383 /// Canonical Subnet principal recorded by the Dashboard.
384 pub subnet_id: String,
385 /// Canonically ordered controller entries recorded by the Dashboard.
386 pub controllers: Vec<IcCanisterPageController>,
387 /// Raw Dashboard language label.
388 pub language: String,
389 /// Raw current module hash.
390 pub module_hash: String,
391 /// Raw Dashboard row update timestamp.
392 pub dashboard_updated_at: String,
393}
394
395///
396/// IcCanisterPageReport
397///
398/// One explicitly bounded page from the official Dashboard canister collection.
399///
400
401#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
402pub struct IcCanisterPageReport {
403 /// Shared Dashboard provenance, flattened in serialized report JSON.
404 #[serde(flatten)]
405 pub provenance: IcDashboardReportProvenance,
406 /// Filters applied by the Dashboard.
407 pub filters: IcCanisterFilters,
408 /// Maximum rows requested from the API.
409 pub requested_limit: u16,
410 /// Number of rows returned in this report.
411 pub returned_count: usize,
412 /// Exclusive forward cursor supplied to this request.
413 pub after: Option<String>,
414 /// Exclusive backward cursor supplied to this request.
415 pub before: Option<String>,
416 /// Cursor for an explicit request for the preceding page.
417 pub previous_cursor: Option<String>,
418 /// Cursor for an explicit request for the following page.
419 pub next_cursor: Option<String>,
420 /// Canister discovery rows in Dashboard canister-id order.
421 pub rows: Vec<IcCanisterPageRow>,
422}