Files
kumomta/crates/kcli/src/inspect_message.rs
T
Wez Furlong dde4b29fba api/cli: add inspect-message API for looking at a message by id
More detailed docs will follow once some other similar APIs are
completed.
2023-07-18 11:22:57 -07:00

31 lines
863 B
Rust

use clap::Parser;
use kumo_api_types::{InspectMessageV1Request, InspectMessageV1Response};
use reqwest::Url;
#[derive(Debug, Parser)]
/// Returns information about a message in the spool
pub struct InspectMessageCommand {
#[arg(long)]
pub want_body: bool,
pub id: String,
}
impl InspectMessageCommand {
pub async fn run(&self, endpoint: &Url) -> anyhow::Result<()> {
let mut url = endpoint.join("/api/admin/inspect-message/v1")?;
let request = InspectMessageV1Request {
id: self.id.clone().try_into()?,
want_body: self.want_body,
};
request.apply_to_url(&mut url);
let result: InspectMessageV1Response =
crate::request_with_json_response(reqwest::Method::GET, url, &()).await?;
println!("{}", serde_json::to_string_pretty(&result)?);
Ok(())
}
}