use crate::presentation::text_value::push_optional_table_section;
use crate::presentation::text_value::yes_no;
use ic_host_text::table::Alignment;
use ic_query::ic::IcApiBoundaryNodeReport;
#[must_use]
pub fn ic_api_boundary_node_report_text(report: &IcApiBoundaryNodeReport) -> String {
let provenance = &report.provenance;
let mut lines = Vec::from(crate::presentation::text_value::report_fields!(report;
schema_version = provenance.schema_version,
network = provenance.network,
authority = provenance.authority,
source_endpoint = provenance.source_endpoint,
effective_canister_id = provenance.effective_canister_id,
fetched_at_unix_seconds = provenance.fetched_at_unix_seconds,
fetched_at = provenance.fetched_at,
fetched_by = provenance.fetched_by,
certificate_time_unix_seconds = provenance.certificate_time_unix_seconds,
certificate_time = provenance.certificate_time,
certified = yes_no(provenance.certified),
point_in_time_guaranteed = yes_no(provenance.point_in_time_guaranteed),
node_count = report.rows.len(),
));
push_optional_table_section(
&mut lines,
Some("api_boundary_nodes:"),
&["NODE ID", "DOMAIN", "IPV4", "IPV6"],
report.rows.iter().map(|row| {
[
row.node_id.clone(),
row.domain.clone(),
row.ipv4_address.clone().unwrap_or_else(|| "-".to_string()),
row.ipv6_address.clone(),
]
}),
&[Alignment::Left; 4],
);
lines.join("\n")
}
#[cfg(test)]
mod tests;