#[cfg(feature = "cloud-engine-host")]
mod build;
#[cfg(all(feature = "cloud-engine-host", feature = "subnet-catalog-host"))]
mod list;
mod model;
#[cfg(feature = "cloud-engine-host")]
mod source;
mod text;
#[cfg(feature = "cloud-engine-host")]
mod wire;
#[cfg(feature = "cloud-engine-host")]
use crate::runtime::RuntimeError;
#[cfg(feature = "cloud-engine-host")]
use thiserror::Error as ThisError;
#[cfg(feature = "cloud-engine-host")]
pub use build::{
build_cloud_engine_operator_report, build_cloud_engine_operator_report_with_source,
build_cloud_engine_prices_report, build_cloud_engine_prices_report_with_source,
};
#[cfg(all(feature = "cloud-engine-host", feature = "subnet-catalog-host"))]
pub use list::{build_cloud_engine_list_report, build_cloud_engine_list_report_with_sources};
#[cfg(all(feature = "cloud-engine-host", feature = "subnet-catalog-host"))]
pub use model::{CloudEngineListReport, CloudEngineListRow, CloudEngineOperatorLookupStatus};
pub use model::{
CloudEngineNodeType, CloudEngineOperatorReport, CloudEnginePriceRow, CloudEnginePricesReport,
CloudEngineReportContext,
};
#[cfg(feature = "cloud-engine-host")]
pub use model::{
CloudEngineOperatorBindingSourceData, CloudEngineOperatorSourceData,
CloudEnginePricesSourceData,
};
#[cfg(feature = "cloud-engine-host")]
pub use source::{
CloudEngineOperatorBindingSource, CloudEngineSource, CloudEngineSourceRequest,
LiveCloudEngineSource,
};
#[cfg(all(feature = "cloud-engine-host", feature = "subnet-catalog-host"))]
pub use text::cloud_engine_list_report_text;
pub use text::{cloud_engine_operator_report_text, cloud_engine_prices_report_text};
pub const MAINNET_CLOUD_ENGINE_CANISTER_ID: &str = "q6cfj-fyaaa-aaaar-qb77q-cai";
pub const DEFAULT_CLOUD_ENGINE_SOURCE_ENDPOINT: &str = "https://icp-api.io";
pub const MAX_CLOUD_ENGINE_PRICE_ROWS: usize = 1_000;
pub const MAX_CLOUD_ENGINE_LIST_ROWS: usize = 100;
pub const MAX_CLOUD_ENGINE_DOMAINS: usize = 100;
pub const MAX_CLOUD_ENGINE_CYCLE_DECIMAL_DIGITS: usize = 256;
#[cfg(feature = "cloud-engine-host")]
const CLOUD_ENGINE_REPORT_SCHEMA_VERSION: u32 = 1;
#[cfg(feature = "cloud-engine-host")]
const CLOUD_ENGINE_AUTHORITY: &str = "cloud_engine_control_plane_canister";
#[cfg(feature = "cloud-engine-host")]
#[derive(Debug, ThisError)]
pub enum CloudEngineHostError {
#[error(
"`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"
)]
UnsupportedNetwork {
network: String,
},
#[error("invalid {field}: {reason}")]
InvalidPrincipal {
field: &'static str,
reason: String,
},
#[error("failed to build IC agent for {endpoint}: {reason}")]
AgentBuild {
endpoint: String,
reason: String,
},
#[error("invalid built-in CloudEngine canister principal: {reason}")]
CanisterId {
reason: String,
},
#[error("CloudEngine agent call {method} failed: {reason}")]
AgentCall {
method: &'static str,
reason: String,
},
#[error("failed to encode Candid {message}: {reason}")]
CandidEncode {
message: &'static str,
reason: String,
},
#[error("failed to decode Candid {message}: {reason}")]
CandidDecode {
message: &'static str,
reason: String,
},
#[error("invalid CloudEngine source data: {reason}")]
InvalidSourceData {
reason: String,
},
#[cfg(feature = "subnet-catalog-host")]
#[error(transparent)]
SubnetCatalog(#[from] crate::subnet_catalog::SubnetCatalogHostError),
#[error(transparent)]
Runtime(#[from] RuntimeError),
}
#[cfg(feature = "cloud-engine-host")]
fn enforce_mainnet_network(network: &str) -> Result<(), CloudEngineHostError> {
crate::network::enforce_mainnet_network_with(network, |network| {
CloudEngineHostError::UnsupportedNetwork { network }
})
}
#[cfg(all(test, feature = "cloud-engine-host"))]
mod tests;