ic_query/cloud_engine/node/model.rs
1//! Module: cloud_engine::node::model
2//!
3//! Responsibility: CloudEngine Type4 node request, report, and source-data contracts.
4//! Does not own: source validation, HTTP transport, rendering, or command parsing.
5//! Boundary: reuses the canonical raw Dashboard node row without changing its authority.
6
7use crate::ic::{IcDashboardReportProvenance, IcNodeStatusCounts};
8use serde::Serialize;
9
10#[cfg(feature = "dashboard-host")]
11use crate::ic::IcSourceRequest;
12
13///
14/// CloudEngineNodeRow
15///
16/// Raw official Dashboard node observation selected by the Type4 reward-type scope.
17///
18
19pub type CloudEngineNodeRow = crate::ic::IcNodeStatusRow;
20
21///
22/// CloudEngineNodeListRequest
23///
24/// Request for one complete official Dashboard Type4 node resource.
25///
26
27#[derive(Clone, Debug, Eq, PartialEq)]
28pub struct CloudEngineNodeListRequest {
29 /// Requested network identity; the built-in source accepts only `ic`.
30 pub network: String,
31 /// Official Dashboard v3 base endpoint.
32 pub source_endpoint: String,
33 /// Caller collection time as Unix seconds.
34 pub now_unix_secs: u64,
35 /// Optional exact node-provider principal applied by the remote resource.
36 pub node_provider_id: Option<String>,
37}
38
39impl CloudEngineNodeListRequest {
40 /// Construct one complete live Type4 node-list request.
41 #[must_use]
42 pub fn new(
43 network: impl Into<String>,
44 source_endpoint: impl Into<String>,
45 now_unix_secs: u64,
46 ) -> Self {
47 Self {
48 network: network.into(),
49 source_endpoint: source_endpoint.into(),
50 now_unix_secs,
51 node_provider_id: None,
52 }
53 }
54
55 /// Restrict collection to one exact node-provider principal.
56 #[must_use]
57 pub fn with_node_provider_id(mut self, node_provider_id: impl Into<String>) -> Self {
58 self.node_provider_id = Some(node_provider_id.into());
59 self
60 }
61}
62
63///
64/// CloudEngineNodeInfoRequest
65///
66/// Request for one exact official Dashboard node required to be Type4.
67///
68
69#[derive(Clone, Debug, Eq, PartialEq)]
70pub struct CloudEngineNodeInfoRequest {
71 /// Requested network identity; the built-in source accepts only `ic`.
72 pub network: String,
73 /// Official Dashboard v3 base endpoint.
74 pub source_endpoint: String,
75 /// Caller collection time as Unix seconds.
76 pub now_unix_secs: u64,
77 /// Exact node principal.
78 pub node_id: String,
79}
80
81impl CloudEngineNodeInfoRequest {
82 /// Construct one exact live Type4 node request.
83 #[must_use]
84 pub fn new(
85 network: impl Into<String>,
86 source_endpoint: impl Into<String>,
87 now_unix_secs: u64,
88 node_id: impl Into<String>,
89 ) -> Self {
90 Self {
91 network: network.into(),
92 source_endpoint: source_endpoint.into(),
93 now_unix_secs,
94 node_id: node_id.into(),
95 }
96 }
97}
98
99///
100/// CloudEngineNodeListReport
101///
102/// Complete bounded Dashboard Type4 node scope, optionally restricted to one provider.
103///
104
105#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
106pub struct CloudEngineNodeListReport {
107 /// Shared official Dashboard provenance, flattened in report JSON.
108 #[serde(flatten)]
109 pub provenance: IcDashboardReportProvenance,
110 /// Exact raw reward type selected by the request.
111 pub node_reward_type: String,
112 /// Complete current Dashboard status values explicitly selected by the request.
113 pub included_statuses: Vec<String>,
114 /// Canonical provider filter, or `None` for the complete Type4 network scope.
115 pub requested_node_provider_id: Option<String>,
116 /// Number of returned Type4 node rows.
117 pub node_count: usize,
118 /// Raw operational-status totals across returned rows.
119 pub status_counts: IcNodeStatusCounts,
120 /// Distinct provider principals represented by returned rows.
121 pub node_provider_count: usize,
122 /// Distinct non-null CloudEngine Subnet principals represented by returned rows.
123 pub cloud_engine_subnet_count: usize,
124 /// Rows without a current `cloud_engine_subnet_id` observation.
125 pub unassigned_cloud_engine_node_count: usize,
126 /// Canonically ordered raw Type4 node observations.
127 pub nodes: Vec<CloudEngineNodeRow>,
128}
129
130///
131/// CloudEngineNodeInfoReport
132///
133/// One exact official Dashboard node observation validated as Type4.
134///
135
136#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
137pub struct CloudEngineNodeInfoReport {
138 /// Shared official Dashboard provenance, flattened in report JSON.
139 #[serde(flatten)]
140 pub provenance: IcDashboardReportProvenance,
141 /// Exact raw Type4 node observation.
142 pub node: CloudEngineNodeRow,
143}
144
145///
146/// CloudEngineNodeListSourceData
147///
148/// Untrusted complete Type4 node resource and query echo returned by a source.
149///
150
151#[cfg(feature = "dashboard-host")]
152#[derive(Clone, Debug, Eq, PartialEq)]
153pub struct CloudEngineNodeListSourceData {
154 /// Source request and collection provenance echoed by the source.
155 pub source: IcSourceRequest,
156 /// Canonical provider filter echoed by the source.
157 pub requested_node_provider_id: Option<String>,
158 /// Raw reward-type filter echoed by the source.
159 pub node_reward_type: String,
160 /// Explicit status filters echoed in request order.
161 pub included_statuses: Vec<String>,
162 /// Raw node rows returned by the source.
163 pub nodes: Vec<CloudEngineNodeRow>,
164}
165
166///
167/// CloudEngineNodeInfoSourceData
168///
169/// Untrusted exact Dashboard node observation returned by a source.
170///
171
172#[cfg(feature = "dashboard-host")]
173#[derive(Clone, Debug, Eq, PartialEq)]
174pub struct CloudEngineNodeInfoSourceData {
175 /// Source request and collection provenance echoed by the source.
176 pub source: IcSourceRequest,
177 /// Exact canonical node target echoed by the source.
178 pub node_id: String,
179 /// Raw exact node observation.
180 pub node: CloudEngineNodeRow,
181}