objectiveai_sdk/cli/command/agents/list/
mod.rs1use crate::cli::command::CommandRequest;
4
5#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
6#[schemars(rename = "cli.command.agents.list.Request")]
7pub struct Request {
8 pub path_type: Path,
9 #[serde(flatten)]
10 pub base: crate::cli::command::RequestBase,
11}
12
13#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
14#[schemars(rename = "cli.command.agents.list.Path")]
15pub enum Path {
16 #[serde(rename = "agents/list")]
17 AgentsList,
18}
19
20impl CommandRequest for Request {
21 fn request_base(&self) -> &crate::cli::command::RequestBase {
22 &self.base
23 }
24
25 fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
26 Some(&mut self.base)
27 }
28}
29
30pub type ResponseItem = crate::RemotePath;
35
36#[derive(clap::Args)]
37pub struct Args {
38 #[command(flatten)]
39 pub base: crate::cli::command::RequestBaseArgs,
40}
41
42#[derive(clap::Args)]
43#[command(args_conflicts_with_subcommands = true)]
44pub struct Command {
45 #[command(flatten)]
46 pub args: Args,
47 #[command(subcommand)]
48 pub schema: Option<Schema>,
49}
50
51#[derive(clap::Subcommand)]
52pub enum Schema {
53 RequestSchema(request_schema::Args),
55 ResponseSchema(response_schema::Args),
57}
58
59impl TryFrom<Args> for Request {
60 type Error = crate::cli::command::FromArgsError;
61 fn try_from(args: Args) -> Result<Self, Self::Error> {
62 Ok(Self { path_type: Path::AgentsList,
63 base: args.base.into(),
64 })
65 }
66}
67
68#[cfg(feature = "cli-executor")]
69pub async fn execute<E: crate::cli::command::CommandExecutor>(
70 executor: &E,
71 mut request: Request,
72
73 agent_arguments: Option<&crate::cli::command::AgentArguments>,
74 ) -> Result<E::Stream<ResponseItem>, E::Error> {
75 request.base.clear_transform();
76 executor.execute(request, agent_arguments).await
77}
78
79#[cfg(feature = "cli-executor")]
80pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
81 executor: &E,
82 mut request: Request,
83 transform: crate::cli::command::Transform,
84
85 agent_arguments: Option<&crate::cli::command::AgentArguments>,
86 ) -> Result<E::Stream<serde_json::Value>, E::Error> {
87 request.base.set_transform(transform);
88 executor.execute(request, agent_arguments).await
89}
90
91pub mod request_schema;
96
97
98pub mod response_schema;