Skip to main content

objectiveai_sdk/cli/command/agents/queue/read/id/request_schema/
mod.rs

1use crate::cli::command::CommandRequest;
2
3#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
4#[schemars(rename = "cli.command.agents.queue.read.id.request_schema.Request")]
5pub struct Request {
6    pub path_type: Path,
7    #[serde(flatten)]
8    pub base: crate::cli::command::RequestBase,
9}
10
11#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
12#[schemars(rename = "cli.command.agents.queue.read.id.request_schema.Path")]
13pub enum Path {
14    #[serde(rename = "agents/queue/read/id/request_schema")]
15    AgentsQueueReadIdRequestSchema,
16}
17
18#[derive(clap::Args)]
19pub struct Args {
20    #[command(flatten)]
21    pub base: crate::cli::command::RequestBaseArgs,
22}
23
24impl CommandRequest for Request {
25    fn into_command(&self) -> Vec<String> {
26        let mut argv: Vec<String> =
27            vec!["agents", "message-queue", "read", "id", "request-schema"]
28                .into_iter()
29                .map(String::from)
30                .collect();
31        self.base.push_flags(&mut argv);
32        argv
33    }
34
35    fn request_base(&self) -> &crate::cli::command::RequestBase {
36        &self.base
37    }
38
39    fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
40        Some(&mut self.base)
41    }
42}
43
44pub type Response = crate::cli::command::ResponseSchema;
45
46impl TryFrom<Args> for Request {
47    type Error = crate::cli::command::FromArgsError;
48    fn try_from(args: Args) -> Result<Self, Self::Error> {
49        Ok(Self {
50            path_type: Path::AgentsQueueReadIdRequestSchema,
51            base: args.base.into(),
52        })
53    }
54}
55
56#[cfg(feature = "cli-executor")]
57pub async fn execute<E: crate::cli::command::CommandExecutor>(
58    executor: &E,
59    mut request: Request,
60    agent_arguments: Option<&crate::cli::command::AgentArguments>,
61) -> Result<Response, E::Error> {
62    request.base.clear_transform();
63    executor.execute_one(request, agent_arguments).await
64}
65
66#[cfg(feature = "cli-executor")]
67pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
68    executor: &E,
69    mut request: Request,
70    transform: crate::cli::command::Transform,
71    agent_arguments: Option<&crate::cli::command::AgentArguments>,
72) -> Result<serde_json::Value, E::Error> {
73    request.base.set_transform(transform);
74    executor.execute_one(request, agent_arguments).await
75}