use crate::context::Context;
use elasticctl_core::Result;
use elasticctl_core::capabilities::{probe_license_tier, probe_spaces};
use serde_json::{Value, json};
pub async fn run(ctx: &Context) -> Result<Value> {
ctx.require_credential()?;
let caps = ctx.capabilities().await?;
let transport = ctx.transport().await?;
let spaces = probe_spaces(transport).await;
let license_tier = probe_license_tier(transport, caps.flavor).await;
Ok(json!({
"elasticctl_version": env!("CARGO_PKG_VERSION"),
"profile": ctx.resolved.name,
"kibana_url": ctx.resolved.profile.kibana_url,
"space": ctx.resolved.profile.space,
"spaces": spaces,
"flavor": caps.flavor.as_str(),
"stack_version": caps.version,
"license_tier": license_tier,
}))
}