ic_query/cloud_engine/
mod.rs1#[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};
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::{CloudEngineOperatorBindingSource, CloudEngineSource, LiveCloudEngineSource};
68#[cfg(all(feature = "cloud-engine-host", feature = "subnet-catalog-host"))]
69pub use text::cloud_engine_list_report_text;
70pub use text::{cloud_engine_operator_report_text, cloud_engine_prices_report_text};
71
72pub const MAINNET_CLOUD_ENGINE_CANISTER_ID: &str = "q6cfj-fyaaa-aaaar-qb77q-cai";
74
75pub const DEFAULT_CLOUD_ENGINE_SOURCE_ENDPOINT: &str = "https://icp-api.io";
77
78pub const DEFAULT_CLOUD_ENGINE_DASHBOARD_SOURCE_ENDPOINT: &str =
80 "https://ic-api.internetcomputer.org/api/v3";
81
82pub const MAX_CLOUD_ENGINE_PRICE_ROWS: usize = 1_000;
84
85pub const MAX_CLOUD_ENGINE_LIST_ROWS: usize = 100;
87
88pub const MAX_CLOUD_ENGINE_DOMAINS: usize = 100;
90
91pub const MAX_CLOUD_ENGINE_CYCLE_DECIMAL_DIGITS: usize = 256;
93
94#[cfg(feature = "cloud-engine-host")]
95const CLOUD_ENGINE_REPORT_SCHEMA_VERSION: u32 = 1;
96#[cfg(feature = "cloud-engine-host")]
97const CLOUD_ENGINE_AUTHORITY: &str = "cloud_engine_control_plane_canister";
98
99#[cfg(feature = "cloud-engine-host")]
106#[derive(Debug, ThisError)]
107pub enum CloudEngineHostError {
108 #[error(
110 "`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"
111 )]
112 UnsupportedNetwork {
113 network: String,
115 },
116
117 #[error("invalid {field}: {reason}")]
119 InvalidPrincipal {
120 field: &'static str,
122 reason: String,
124 },
125
126 #[error("failed to build IC agent for {endpoint}: {reason}")]
128 AgentBuild {
129 endpoint: String,
131 reason: String,
133 },
134
135 #[error("invalid built-in CloudEngine canister principal: {reason}")]
137 CanisterId {
138 reason: String,
140 },
141
142 #[error("CloudEngine agent call {method} failed: {reason}")]
144 AgentCall {
145 method: &'static str,
147 reason: String,
149 },
150
151 #[error("failed to encode Candid {message}: {reason}")]
153 CandidEncode {
154 message: &'static str,
156 reason: String,
158 },
159
160 #[error("failed to decode Candid {message}: {reason}")]
162 CandidDecode {
163 message: &'static str,
165 reason: String,
167 },
168
169 #[error("invalid CloudEngine source data: {reason}")]
171 InvalidSourceData {
172 reason: String,
174 },
175
176 #[cfg(feature = "subnet-catalog-host")]
178 #[error(transparent)]
179 SubnetCatalog(#[from] crate::subnet_catalog::SubnetCatalogHostError),
180}
181
182#[cfg(feature = "cloud-engine-host")]
183fn enforce_mainnet_network(network: &str) -> Result<(), CloudEngineHostError> {
184 crate::network::enforce_mainnet_network_with(network, |network| {
185 CloudEngineHostError::UnsupportedNetwork { network }
186 })
187}
188
189#[cfg(all(test, feature = "cloud-engine-host"))]
190mod tests;