use crate::report::ReportProvenance;
use crate::sns::report::model::MainnetSnsCanisters;
use serde::Serialize;
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub struct SnsListReport {
pub schema_version: u32,
pub network: String,
pub sns_wasm_canister_id: String,
pub fetched_at: String,
pub source_endpoint: String,
pub fetched_by: String,
#[serde(flatten)]
pub provenance: ReportProvenance,
pub all_lifecycles: bool,
pub sort: String,
pub catalog_sns_count: usize,
pub excluded_sns_count: usize,
pub sns_count: usize,
pub metadata_error_count: usize,
pub lifecycle_error_count: usize,
pub sns_instances: Vec<SnsListRow>,
}
#[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, Serialize)]
#[serde(tag = "status", rename_all = "snake_case", deny_unknown_fields)]
pub enum SnsLifecycleOutcome {
NotCollected,
Value {
code: i32,
},
Failed {
error: String,
},
}
impl SnsLifecycleOutcome {
#[must_use]
pub const fn value(&self) -> Option<i32> {
match self {
Self::Value { code } => Some(*code),
Self::NotCollected | Self::Failed { .. } => None,
}
}
#[must_use]
pub fn error(&self) -> Option<&str> {
match self {
Self::Failed { error } => Some(error),
Self::NotCollected | Self::Value { .. } => None,
}
}
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub struct SnsListRow {
pub id: usize,
pub name: String,
#[serde(flatten)]
pub canisters: MainnetSnsCanisters,
pub metadata_error: Option<String>,
pub lifecycle: SnsLifecycleOutcome,
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub struct SnsInfoReport {
pub schema_version: u32,
pub network: String,
pub sns_wasm_canister_id: String,
pub fetched_at: String,
pub source_endpoint: String,
pub fetched_by: String,
pub id: usize,
pub name: String,
pub description: Option<String>,
pub url: Option<String>,
#[serde(flatten)]
pub canisters: MainnetSnsCanisters,
pub metadata_error: Option<String>,
}