ic-query-cli 0.103.0

Command-line wrapper for read-only Internet Computer metadata queries
Documentation
//! Module: ic::api_boundary_node
//!
//! Responsibility: parse and dispatch certified API boundary-node commands.
//! Does not own: certificate authentication, state-tree projection, or rendering.
//! Boundary: exposes one complete live state-tree collection to the IC CLI facade.

use super::IcCommandError;
use crate::cli::common::{
    COLLECTION_MODE_LIVE, SourceOutputOptions, collection_help, current_unix_secs,
    write_text_or_json,
};
use crate::presentation::ic::ic_api_boundary_node_report_text;
use clap::Subcommand;
use ic_query::ic::DEFAULT_IC_STATE_SOURCE_ENDPOINT;
use ic_query::ic::IcApiBoundaryNodeRequest;
use ic_query::ic::build_ic_api_boundary_node_report_with_source;

const LIST_HELP_AFTER: &str = "\
Examples:
  icq ic api-boundary-node list
  icq ic api-boundary-node list --json

This command makes exactly one response-bounded IC read_state request and
authenticates its certificate with the built-in mainnet root key. It returns
the complete certified api_boundary_nodes subtree at one certificate time,
including node principals, domains, and IPv4/IPv6 addresses. The fixed NNS
Registry effective canister only routes the read_state request; Registry
canister data is not queried. No cache or per-node follow-up is used.

Rows identify configured API boundary nodes, not HTTP gateways or operational
health, reachability, latency, ownership, or physical location.";

pub(super) async fn run(command: ApiBoundaryNodeCommand) -> Result<(), IcCommandError> {
    let ApiBoundaryNodeCommand::List(options) = command;
    let format = options.format();
    let request = IcApiBoundaryNodeRequest::new(options.source_endpoint, current_unix_secs()?);
    let report =
        build_ic_api_boundary_node_report_with_source(&request, &ic_query::ic::LiveIcStateSource)
            .await?;
    write_text_or_json(format, &report, ic_api_boundary_node_report_text)
}

///
/// ApiBoundaryNodeCommand
///
/// Typed certified API boundary-node operation.
///

#[derive(Subcommand)]
#[command(about = "Inspect certified API boundary-node configuration", long_about = None)]
pub(super) enum ApiBoundaryNodeCommand {
    #[command(about = "List the complete certified API boundary-node state tree", long_about = None, after_help = collection_help(COLLECTION_MODE_LIVE, LIST_HELP_AFTER))]
    #[command(mut_arg("source-endpoint", |arg| arg.default_value(DEFAULT_IC_STATE_SOURCE_ENDPOINT).help("Mainnet IC API endpoint used for certified read_state")))]
    List(SourceOutputOptions),
}

#[cfg(test)]
mod tests;