Skip to main content

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, IcDashboardRequest, 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    /// Explicit Dashboard endpoint and caller collection clock.
32    pub dashboard: IcDashboardRequest,
33    /// Optional exact node-provider principal applied by the remote resource.
34    pub node_provider_id: Option<String>,
35}
36
37impl CloudEngineNodeListRequest {
38    /// Construct one complete live Type4 node-list request.
39    #[must_use]
40    pub fn new(network: impl Into<String>, dashboard: IcDashboardRequest) -> Self {
41        Self {
42            network: network.into(),
43            dashboard,
44            node_provider_id: None,
45        }
46    }
47
48    /// Restrict collection to one exact node-provider principal.
49    #[must_use]
50    pub fn with_node_provider_id(mut self, node_provider_id: impl Into<String>) -> Self {
51        self.node_provider_id = Some(node_provider_id.into());
52        self
53    }
54}
55
56///
57/// CloudEngineNodeInfoRequest
58///
59/// Request for one exact official Dashboard node required to be Type4.
60///
61
62#[derive(Clone, Debug, Eq, PartialEq)]
63pub struct CloudEngineNodeInfoRequest {
64    /// Requested network identity; the built-in source accepts only `ic`.
65    pub network: String,
66    /// Explicit Dashboard endpoint and caller collection clock.
67    pub dashboard: IcDashboardRequest,
68    /// Exact node principal.
69    pub node_id: String,
70}
71
72impl CloudEngineNodeInfoRequest {
73    /// Construct one exact live Type4 node request.
74    #[must_use]
75    pub fn new(
76        network: impl Into<String>,
77        dashboard: IcDashboardRequest,
78        node_id: impl Into<String>,
79    ) -> Self {
80        Self {
81            network: network.into(),
82            dashboard,
83            node_id: node_id.into(),
84        }
85    }
86}
87
88///
89/// CloudEngineNodeListReport
90///
91/// Complete bounded Dashboard Type4 node scope, optionally restricted to one provider.
92///
93
94#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
95pub struct CloudEngineNodeListReport {
96    /// Shared official Dashboard provenance, flattened in report JSON.
97    #[serde(flatten)]
98    pub provenance: IcDashboardReportProvenance,
99    /// Exact raw reward type selected by the request.
100    pub node_reward_type: String,
101    /// Complete current Dashboard status values explicitly selected by the request.
102    pub included_statuses: Vec<String>,
103    /// Canonical provider filter, or `None` for the complete Type4 network scope.
104    pub requested_node_provider_id: Option<String>,
105    /// Number of returned Type4 node rows.
106    pub node_count: usize,
107    /// Raw operational-status totals across returned rows.
108    pub status_counts: IcNodeStatusCounts,
109    /// Distinct provider principals represented by returned rows.
110    pub node_provider_count: usize,
111    /// Distinct non-null CloudEngine Subnet principals represented by returned rows.
112    pub cloud_engine_subnet_count: usize,
113    /// Rows without a current `cloud_engine_subnet_id` observation.
114    pub unassigned_cloud_engine_node_count: usize,
115    /// Canonically ordered raw Type4 node observations.
116    pub nodes: Vec<CloudEngineNodeRow>,
117}
118
119///
120/// CloudEngineNodeInfoReport
121///
122/// One exact official Dashboard node observation validated as Type4.
123///
124
125#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
126pub struct CloudEngineNodeInfoReport {
127    /// Shared official Dashboard provenance, flattened in report JSON.
128    #[serde(flatten)]
129    pub provenance: IcDashboardReportProvenance,
130    /// Exact raw Type4 node observation.
131    pub node: CloudEngineNodeRow,
132}
133
134///
135/// CloudEngineNodeListSourceData
136///
137/// Untrusted complete Type4 node resource and query echo returned by a source.
138///
139
140#[cfg(feature = "dashboard-host")]
141#[derive(Clone, Debug, Eq, PartialEq)]
142pub struct CloudEngineNodeListSourceData {
143    /// Source request and collection provenance echoed by the source.
144    pub source: IcSourceRequest,
145    /// Canonical provider filter echoed by the source.
146    pub requested_node_provider_id: Option<String>,
147    /// Raw reward-type filter echoed by the source.
148    pub node_reward_type: String,
149    /// Explicit status filters echoed in request order.
150    pub included_statuses: Vec<String>,
151    /// Raw node rows returned by the source.
152    pub nodes: Vec<CloudEngineNodeRow>,
153}
154
155///
156/// CloudEngineNodeInfoSourceData
157///
158/// Untrusted exact Dashboard node observation returned by a source.
159///
160
161#[cfg(feature = "dashboard-host")]
162#[derive(Clone, Debug, Eq, PartialEq)]
163pub struct CloudEngineNodeInfoSourceData {
164    /// Source request and collection provenance echoed by the source.
165    pub source: IcSourceRequest,
166    /// Exact canonical node target echoed by the source.
167    pub node_id: String,
168    /// Raw exact node observation.
169    pub node: CloudEngineNodeRow,
170}