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