use crate::subnet_catalog::{
CacheDisposition, CatalogAssurance, CatalogReadPolicy, CatalogSourceSelection,
ClassificationSource, GeographicScope, ResolveAs, RoutingRange, SubnetCatalogCacheRequest,
SubnetKind, SubnetSpecialization,
};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct SubnetCatalogInfoRequest {
pub cache: SubnetCatalogCacheRequest,
pub read_policy: CatalogReadPolicy,
pub input: String,
pub forced: Option<ResolveAs>,
pub now_unix_secs: u64,
pub stale_after_seconds: u64,
}
impl SubnetCatalogInfoRequest {
#[must_use]
pub fn new(
cache: SubnetCatalogCacheRequest,
source_endpoint: impl Into<String>,
input: impl Into<String>,
now_unix_secs: u64,
stale_after_seconds: u64,
) -> Self {
Self {
cache,
read_policy: CatalogReadPolicy::RefreshMissingOrInvalid {
source: CatalogSourceSelection::uncertified_query(source_endpoint),
},
input: input.into(),
forced: None,
now_unix_secs,
stale_after_seconds,
}
}
#[must_use]
pub const fn with_forced(mut self, forced: ResolveAs) -> Self {
self.forced = Some(forced);
self
}
#[must_use]
pub fn with_read_policy(mut self, read_policy: CatalogReadPolicy) -> Self {
self.read_policy = read_policy;
self
}
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct SubnetCatalogInfoReport {
pub schema_version: u32,
pub input_principal: String,
pub resolved_as: String,
pub resolved_from: String,
pub subnet_principal: String,
pub registry_subnet_type: i32,
pub subnet_kind: SubnetKind,
pub subnet_kind_source: ClassificationSource,
pub subnet_specialization: SubnetSpecialization,
pub subnet_specialization_source: ClassificationSource,
pub geographic_scope: GeographicScope,
pub geographic_scope_source: ClassificationSource,
pub subnet_label: String,
pub subnet_label_source: ClassificationSource,
pub node_count: Option<u32>,
pub charges_apply_to_subject: bool,
pub charge_applicability_reason: String,
pub registry_canister_id: String,
pub registry_version: u64,
pub assurance: CatalogAssurance,
pub source_endpoints: Vec<String>,
pub agreement_digest: Option<String>,
pub registry_query_call_count: u64,
pub catalog_digest: String,
pub cache_disposition: CacheDisposition,
pub catalog_schema_version: u32,
pub catalog_path: String,
pub fetched_at: String,
pub catalog_stale: bool,
pub stale_reason: String,
pub resolver_backend: String,
pub collector_version: String,
pub classification_schema_version: u32,
pub classification_policy_digest: String,
pub resolver_schema_version: u32,
pub matched_canister_principal: Option<String>,
pub matched_routing_range: Option<RoutingRange>,
pub cycles_per_billion_instructions: Option<u128>,
pub rate_source: Option<String>,
pub formula_version: Option<String>,
}