ic_query_cli/presentation/ic/api_boundary_node/
mod.rs1use crate::presentation::text_value::table;
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 if !report.rows.is_empty() {
34 let rows = report
35 .rows
36 .iter()
37 .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 .collect::<Vec<_>>();
46 lines.push(String::new());
47 lines.push("api_boundary_nodes:".to_string());
48 lines.push(table(
49 &["NODE ID", "DOMAIN", "IPV4", "IPV6"],
50 &rows,
51 &[Alignment::Left; 4],
52 ));
53 }
54
55 lines.join("\n")
56}
57
58#[cfg(test)]
59mod tests;