ic_query_cli/presentation/ic/api_boundary_node/
mod.rs1use crate::presentation::text_value::push_optional_table_section;
8use crate::presentation::text_value::yes_no;
9use ic_host_text::table::Alignment;
10
11use ic_query::ic::IcApiBoundaryNodeReport;
12
13#[must_use]
15pub fn ic_api_boundary_node_report_text(report: &IcApiBoundaryNodeReport) -> String {
16 let provenance = &report.provenance;
17 let mut lines = Vec::from(crate::presentation::text_value::report_fields!(report;
18 schema_version = provenance.schema_version,
19 network = provenance.network,
20 authority = provenance.authority,
21 source_endpoint = provenance.source_endpoint,
22 effective_canister_id = provenance.effective_canister_id,
23 fetched_at_unix_seconds = provenance.fetched_at_unix_seconds,
24 fetched_at = provenance.fetched_at,
25 fetched_by = provenance.fetched_by,
26 certificate_time_unix_seconds = provenance.certificate_time_unix_seconds,
27 certificate_time = provenance.certificate_time,
28 certified = yes_no(provenance.certified),
29 point_in_time_guaranteed = yes_no(provenance.point_in_time_guaranteed),
30 node_count = report.rows.len(),
31 ));
32
33 push_optional_table_section(
34 &mut lines,
35 Some("api_boundary_nodes:"),
36 &["NODE ID", "DOMAIN", "IPV4", "IPV6"],
37 report.rows.iter().map(|row| {
38 [
39 row.node_id.clone(),
40 row.domain.clone(),
41 row.ipv4_address.clone().unwrap_or_else(|| "-".to_string()),
42 row.ipv6_address.clone(),
43 ]
44 }),
45 &[Alignment::Left; 4],
46 );
47
48 lines.join("\n")
49}
50
51#[cfg(test)]
52mod tests;