1#[cfg(feature = "cloud-engine-host")]
4mod build;
5#[cfg(all(feature = "cloud-engine-host", feature = "subnet-catalog-host"))]
6mod list;
7mod model;
8mod node;
9mod provider;
10#[cfg(feature = "cloud-engine-host")]
11mod source;
12mod text;
13#[cfg(feature = "cloud-engine-host")]
14mod wire;
15
16#[cfg(feature = "cloud-engine-host")]
17use thiserror::Error as ThisError;
18
19#[cfg(feature = "cloud-engine-host")]
20pub use build::{
21 build_cloud_engine_operator_report, build_cloud_engine_operator_report_with_source,
22 build_cloud_engine_prices_report, build_cloud_engine_prices_report_with_source,
23};
24#[cfg(all(feature = "cloud-engine-host", feature = "subnet-catalog-host"))]
25pub use list::{
26 build_cloud_engine_list_report, build_cloud_engine_list_report_with_progress,
27 build_cloud_engine_list_report_with_sources,
28 build_cloud_engine_list_report_with_sources_and_progress,
29};
30#[cfg(all(feature = "cloud-engine-host", feature = "subnet-catalog-host"))]
31pub use model::{CloudEngineListReport, CloudEngineListRow, CloudEngineOperatorLookupStatus};
32pub use model::{
33 CloudEngineNodeType, CloudEngineOperatorReport, CloudEnginePriceRow, CloudEnginePricesReport,
34 CloudEngineReportContext,
35};
36#[cfg(feature = "cloud-engine-host")]
37pub use model::{
38 CloudEngineOperatorBindingSourceData, CloudEngineOperatorSourceData,
39 CloudEnginePricesSourceData,
40};
41pub use node::{
42 CLOUD_ENGINE_NODE_INCLUDED_STATUSES, CLOUD_ENGINE_NODE_REWARD_TYPE, CloudEngineNodeInfoReport,
43 CloudEngineNodeInfoRequest, CloudEngineNodeListReport, CloudEngineNodeListRequest,
44 CloudEngineNodeRow, MAX_CLOUD_ENGINE_NODE_ROWS, cloud_engine_node_info_report_text,
45 cloud_engine_node_list_report_text,
46};
47#[cfg(feature = "dashboard-host")]
48pub use node::{
49 CloudEngineNodeInfoSourceData, CloudEngineNodeListSourceData, CloudEngineNodeSource,
50 build_cloud_engine_node_info_report, build_cloud_engine_node_info_report_with_source,
51 build_cloud_engine_node_list_report, build_cloud_engine_node_list_report_with_source,
52};
53pub use provider::{
54 CloudEngineProviderInfoReport, CloudEngineProviderInfoRequest, CloudEngineProviderListReport,
55 CloudEngineProviderListRequest, CloudEngineProviderLocation, CloudEngineProviderRow,
56 MAX_CLOUD_ENGINE_PROVIDER_LOCATIONS, MAX_CLOUD_ENGINE_PROVIDER_SOURCE_ROWS,
57 cloud_engine_provider_info_report_text, cloud_engine_provider_list_report_text,
58};
59#[cfg(feature = "dashboard-host")]
60pub use provider::{
61 CloudEngineProviderInfoSourceData, CloudEngineProviderListSourceData,
62 CloudEngineProviderSource, build_cloud_engine_provider_info_report,
63 build_cloud_engine_provider_info_report_with_source, build_cloud_engine_provider_list_report,
64 build_cloud_engine_provider_list_report_with_source,
65};
66#[cfg(feature = "cloud-engine-host")]
67pub use source::{
68 CloudEngineOperatorBindingSource, CloudEngineSource, CloudEngineSourceRequest,
69 LiveCloudEngineSource,
70};
71#[cfg(all(feature = "cloud-engine-host", feature = "subnet-catalog-host"))]
72pub use text::cloud_engine_list_report_text;
73pub use text::{cloud_engine_operator_report_text, cloud_engine_prices_report_text};
74
75pub const MAINNET_CLOUD_ENGINE_CANISTER_ID: &str = "q6cfj-fyaaa-aaaar-qb77q-cai";
77
78pub const DEFAULT_CLOUD_ENGINE_SOURCE_ENDPOINT: &str = "https://icp-api.io";
80
81pub const DEFAULT_CLOUD_ENGINE_DASHBOARD_SOURCE_ENDPOINT: &str =
83 "https://ic-api.internetcomputer.org/api/v3";
84
85pub const MAX_CLOUD_ENGINE_PRICE_ROWS: usize = 1_000;
87
88pub const MAX_CLOUD_ENGINE_LIST_ROWS: usize = 100;
90
91pub const MAX_CLOUD_ENGINE_DOMAINS: usize = 100;
93
94pub const MAX_CLOUD_ENGINE_CYCLE_DECIMAL_DIGITS: usize = 256;
96
97#[cfg(feature = "cloud-engine-host")]
98const CLOUD_ENGINE_REPORT_SCHEMA_VERSION: u32 = 1;
99#[cfg(feature = "cloud-engine-host")]
100const CLOUD_ENGINE_AUTHORITY: &str = "cloud_engine_control_plane_canister";
101
102#[cfg(feature = "cloud-engine-host")]
109#[derive(Debug, ThisError)]
110pub enum CloudEngineHostError {
111 #[error(
113 "`icq cloud-engine` supports only the mainnet `ic` network\n\nThese reports query the mainnet CloudEngine control-plane canister.\n\nTry:\n icq --network ic cloud-engine prices"
114 )]
115 UnsupportedNetwork {
116 network: String,
118 },
119
120 #[error("invalid {field}: {reason}")]
122 InvalidPrincipal {
123 field: &'static str,
125 reason: String,
127 },
128
129 #[error("failed to build IC agent for {endpoint}: {reason}")]
131 AgentBuild {
132 endpoint: String,
134 reason: String,
136 },
137
138 #[error("invalid built-in CloudEngine canister principal: {reason}")]
140 CanisterId {
141 reason: String,
143 },
144
145 #[error("CloudEngine agent call {method} failed: {reason}")]
147 AgentCall {
148 method: &'static str,
150 reason: String,
152 },
153
154 #[error("failed to encode Candid {message}: {reason}")]
156 CandidEncode {
157 message: &'static str,
159 reason: String,
161 },
162
163 #[error("failed to decode Candid {message}: {reason}")]
165 CandidDecode {
166 message: &'static str,
168 reason: String,
170 },
171
172 #[error("invalid CloudEngine source data: {reason}")]
174 InvalidSourceData {
175 reason: String,
177 },
178
179 #[cfg(feature = "subnet-catalog-host")]
181 #[error(transparent)]
182 SubnetCatalog(#[from] crate::subnet_catalog::SubnetCatalogHostError),
183}
184
185#[cfg(feature = "cloud-engine-host")]
186fn enforce_mainnet_network(network: &str) -> Result<(), CloudEngineHostError> {
187 crate::network::enforce_mainnet_network_with(network, |network| {
188 CloudEngineHostError::UnsupportedNetwork { network }
189 })
190}
191
192#[cfg(all(test, feature = "cloud-engine-host"))]
193mod tests;