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