objectiveai_sdk/cli/command/agents/queue/read/pending/response_schema/
mod.rs1use crate::cli::command::CommandRequest;
2
3#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
4#[schemars(rename = "cli.command.agents.queue.read.pending.response_schema.Request")]
5pub struct Request {
6 pub path_type: Path,
7 pub jq: Option<String>,
8}
9
10#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
11#[schemars(rename = "cli.command.agents.queue.read.pending.response_schema.Path")]
12pub enum Path {
13 #[serde(rename = "agents/queue/read/pending/response_schema")]
14 AgentsQueueReadPendingResponseSchema,
15}
16
17#[derive(clap::Args)]
18pub struct Args {
19 #[arg(long)]
20 pub jq: Option<String>,
21}
22
23impl CommandRequest for Request {
24 fn into_command(&self) -> Vec<String> {
25 let mut argv: Vec<String> = vec!["agents", "message-queue", "read", "pending", "response-schema"]
26 .into_iter()
27 .map(String::from)
28 .collect();
29 if let Some(jq) = &self.jq {
30 argv.push("--jq".to_string());
31 argv.push(jq.clone());
32 }
33 argv
34 }
35}
36
37pub type Response = crate::cli::command::ResponseSchema;
38
39impl TryFrom<Args> for Request {
40 type Error = crate::cli::command::FromArgsError;
41 fn try_from(args: Args) -> Result<Self, Self::Error> {
42 Ok(Self {
43 path_type: Path::AgentsQueueReadPendingResponseSchema,
44 jq: args.jq,
45 })
46 }
47}
48
49#[cfg(feature = "cli-executor")]
50pub async fn execute<E: crate::cli::command::CommandExecutor>(
51 executor: &E,
52 mut request: Request,
53 agent_arguments: Option<&crate::cli::command::AgentArguments>,
54) -> Result<Response, E::Error> {
55 request.jq = None;
56 executor.execute_one(request, agent_arguments).await
57}
58
59#[cfg(feature = "cli-executor")]
60pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
61 executor: &E,
62 mut request: Request,
63 jq: String,
64 agent_arguments: Option<&crate::cli::command::AgentArguments>,
65) -> Result<serde_json::Value, E::Error> {
66 request.jq = Some(jq);
67 executor.execute_one(request, agent_arguments).await
68}