use serde::{Deserialize, Serialize};
use std::fmt;
#[cfg(feature = "cloud-engine-host")]
use super::CloudEngineSourceRequest;
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct CloudEngineReportContext {
pub schema_version: u32,
pub network: String,
pub authority: String,
pub engine_canister_id: String,
pub fetched_at: String,
pub source_endpoint: String,
pub fetched_by: String,
pub certified: bool,
pub point_in_time_guaranteed: bool,
pub query_call_count: usize,
}
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct CloudEngineOperatorReport {
#[serde(flatten)]
pub context: CloudEngineReportContext,
pub subnet_id: String,
pub operator_binding_present: bool,
pub operator_canister_id: Option<String>,
pub engine_owner: Option<String>,
pub platform_admin: Option<String>,
pub caffeine_enabled: Option<bool>,
pub claimed_domain_count: Option<usize>,
pub claimed_domains: Option<Vec<String>>,
}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Deserialize, Serialize)]
pub enum CloudEngineNodeType {
#[serde(rename = "type4.1")]
Type4_1,
#[serde(rename = "type4.2")]
Type4_2,
#[serde(rename = "type4.3")]
Type4_3,
#[serde(rename = "type4.4")]
Type4_4,
#[serde(rename = "type4.5")]
Type4_5,
}
impl CloudEngineNodeType {
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Type4_1 => "type4.1",
Self::Type4_2 => "type4.2",
Self::Type4_3 => "type4.3",
Self::Type4_4 => "type4.4",
Self::Type4_5 => "type4.5",
}
}
}
impl fmt::Display for CloudEngineNodeType {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str(self.as_str())
}
}
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct CloudEnginePriceRow {
pub key: String,
pub node_type: CloudEngineNodeType,
pub data_center_id: Option<String>,
pub provider_id: Option<String>,
pub net_cycles_per_month: String,
pub gross_cycles_per_month: String,
pub updated_at_unix_nanos: i64,
}
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub struct CloudEnginePricesReport {
#[serde(flatten)]
pub context: CloudEngineReportContext,
pub network_fee: f64,
pub price_count: usize,
pub prices: Vec<CloudEnginePriceRow>,
}
#[cfg(feature = "cloud-engine-host")]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct CloudEngineOperatorSourceData {
pub source: CloudEngineSourceRequest,
pub subnet_id: String,
pub operator_canister_id: Option<String>,
pub engine_owner: Option<String>,
pub platform_admin: Option<String>,
pub caffeine_enabled: Option<bool>,
pub claimed_domains: Option<Vec<String>>,
pub query_call_count: usize,
}
#[cfg(feature = "cloud-engine-host")]
#[derive(Clone, Debug, PartialEq)]
pub struct CloudEnginePricesSourceData {
pub source: CloudEngineSourceRequest,
pub network_fee: f64,
pub prices: Vec<CloudEnginePriceRow>,
pub query_call_count: usize,
}