Skip to main content

ic_query/cloud_engine/provider/
model.rs

1//! Module: cloud_engine::provider::model
2//!
3//! Responsibility: CloudEngine provider requests, location rows, reports, and source data.
4//! Does not own: source validation, HTTP decoding, rendering, or command parsing.
5//! Boundary: preserves raw Dashboard provider and location fields without Registry promotion.
6
7use crate::ic::IcDashboardReportProvenance;
8use serde::{Deserialize, Serialize};
9
10#[cfg(feature = "dashboard-host")]
11use crate::ic::IcSourceRequest;
12
13///
14/// CloudEngineProviderListRequest
15///
16/// Request for one complete official Dashboard provider resource filtered to CloudEngine rows.
17///
18
19#[derive(Clone, Debug, Eq, PartialEq)]
20pub struct CloudEngineProviderListRequest {
21    /// Requested network identity; the built-in source accepts only `ic`.
22    pub network: String,
23    /// Official Dashboard v3 base endpoint.
24    pub source_endpoint: String,
25    /// Caller collection time as Unix seconds.
26    pub now_unix_secs: u64,
27}
28
29impl CloudEngineProviderListRequest {
30    /// Construct one live CloudEngine provider-list request.
31    #[must_use]
32    pub fn new(
33        network: impl Into<String>,
34        source_endpoint: impl Into<String>,
35        now_unix_secs: u64,
36    ) -> Self {
37        Self {
38            network: network.into(),
39            source_endpoint: source_endpoint.into(),
40            now_unix_secs,
41        }
42    }
43}
44
45///
46/// CloudEngineProviderInfoRequest
47///
48/// Request for one exact official Dashboard node-provider record and its CloudEngine fields.
49///
50
51#[derive(Clone, Debug, Eq, PartialEq)]
52pub struct CloudEngineProviderInfoRequest {
53    /// Requested network identity; the built-in source accepts only `ic`.
54    pub network: String,
55    /// Official Dashboard v3 base endpoint.
56    pub source_endpoint: String,
57    /// Caller collection time as Unix seconds.
58    pub now_unix_secs: u64,
59    /// Exact node-provider principal.
60    pub node_provider_id: String,
61}
62
63impl CloudEngineProviderInfoRequest {
64    /// Construct one exact live provider request.
65    #[must_use]
66    pub fn new(
67        network: impl Into<String>,
68        source_endpoint: impl Into<String>,
69        now_unix_secs: u64,
70        node_provider_id: impl Into<String>,
71    ) -> Self {
72        Self {
73            network: network.into(),
74            source_endpoint: source_endpoint.into(),
75            now_unix_secs,
76            node_provider_id: node_provider_id.into(),
77        }
78    }
79}
80
81///
82/// CloudEngineProviderLocation
83///
84/// Raw official Dashboard location attached to one node provider.
85///
86
87#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
88pub struct CloudEngineProviderLocation {
89    /// Dashboard data-center key.
90    pub dc_key: String,
91    /// Human-facing Dashboard location label.
92    pub display_name: String,
93    /// Raw decimal latitude decoded as a finite number.
94    pub latitude: f64,
95    /// Raw decimal longitude decoded as a finite number.
96    pub longitude: f64,
97    /// Dashboard data-center owner label.
98    pub owner: String,
99    /// Raw Dashboard region label.
100    pub region: String,
101}
102
103///
104/// CloudEngineProviderRow
105///
106/// One raw official Dashboard node-provider record with CloudEngine-specific evidence.
107///
108
109#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
110pub struct CloudEngineProviderRow {
111    /// Canonical node-provider principal.
112    pub principal_id: String,
113    /// Human-facing provider name.
114    pub display_name: String,
115    /// Raw optional website text.
116    pub website: Option<String>,
117    /// Raw optional Dashboard logo URL.
118    pub logo_url: Option<String>,
119    /// Number of all Dashboard locations represented by `locations`.
120    pub location_count: usize,
121    /// Dashboard locations associated with the provider's ordinary IC nodes.
122    pub locations: Vec<CloudEngineProviderLocation>,
123    /// Number of CloudEngine locations represented by `cloud_engine_locations`.
124    pub cloud_engine_location_count: usize,
125    /// Independent Dashboard locations carrying CloudEngine evidence.
126    pub cloud_engine_locations: Vec<CloudEngineProviderLocation>,
127    /// Raw Dashboard total for CloudEngine nodes.
128    pub total_cloud_engine_nodes: u64,
129    /// Raw Dashboard total for unassigned CloudEngine nodes.
130    pub total_cloud_engine_unassigned_nodes: u64,
131    /// Raw Dashboard total for CloudEngine instances.
132    pub total_cloud_engines: u64,
133    /// Raw Dashboard total node allowance.
134    pub total_node_allowance: u64,
135    /// Raw Dashboard total ordinary nodes.
136    pub total_nodes: u64,
137    /// Raw Dashboard total rewardable nodes.
138    pub total_rewardable_nodes: u64,
139    /// Raw Dashboard total Subnets.
140    pub total_subnets: u64,
141    /// Raw Dashboard total unassigned ordinary nodes.
142    pub total_unassigned_nodes: u64,
143}
144
145impl CloudEngineProviderRow {
146    /// Whether any returned CloudEngine-specific field carries nonempty evidence.
147    #[must_use]
148    pub const fn has_cloud_engine_evidence(&self) -> bool {
149        self.cloud_engine_location_count > 0
150            || !self.cloud_engine_locations.is_empty()
151            || self.total_cloud_engine_nodes > 0
152            || self.total_cloud_engine_unassigned_nodes > 0
153            || self.total_cloud_engines > 0
154    }
155}
156
157///
158/// CloudEngineProviderListReport
159///
160/// Complete Dashboard provider resource filtered to rows with explicit CloudEngine evidence.
161///
162
163#[derive(Clone, Debug, PartialEq, Serialize)]
164pub struct CloudEngineProviderListReport {
165    /// Shared official Dashboard provenance, flattened in report JSON.
166    #[serde(flatten)]
167    pub provenance: IcDashboardReportProvenance,
168    /// Number of provider rows in the complete source resource before filtering.
169    pub source_node_provider_count: usize,
170    /// Number of rows with explicit CloudEngine evidence.
171    pub cloud_engine_provider_count: usize,
172    /// CloudEngine-bearing providers in canonical principal order.
173    pub providers: Vec<CloudEngineProviderRow>,
174}
175
176///
177/// CloudEngineProviderInfoReport
178///
179/// One exact Dashboard provider record with an explicit CloudEngine-scope classification.
180///
181
182#[derive(Clone, Debug, PartialEq, Serialize)]
183pub struct CloudEngineProviderInfoReport {
184    /// Shared official Dashboard provenance, flattened in report JSON.
185    #[serde(flatten)]
186    pub provenance: IcDashboardReportProvenance,
187    /// Whether the exact row contains any explicit CloudEngine evidence.
188    pub cloud_engine_evidence_present: bool,
189    /// Exact raw provider record.
190    pub provider: CloudEngineProviderRow,
191}
192
193///
194/// CloudEngineProviderListSourceData
195///
196/// Complete decoded official Dashboard provider resource returned by a source.
197///
198
199#[cfg(feature = "dashboard-host")]
200#[derive(Clone, Debug, PartialEq)]
201pub struct CloudEngineProviderListSourceData {
202    /// Source request and collection provenance echoed by the source.
203    pub source: IcSourceRequest,
204    /// Every provider row returned by the complete resource before filtering.
205    pub providers: Vec<CloudEngineProviderRow>,
206}
207
208///
209/// CloudEngineProviderInfoSourceData
210///
211/// Exact decoded official Dashboard provider record returned by a source.
212///
213
214#[cfg(feature = "dashboard-host")]
215#[derive(Clone, Debug, PartialEq)]
216pub struct CloudEngineProviderInfoSourceData {
217    /// Source request and collection provenance echoed by the source.
218    pub source: IcSourceRequest,
219    /// Exact provider row returned by the source.
220    pub provider: CloudEngineProviderRow,
221}