Skip to main content

objectiveai_sdk/cli/command/kill_all/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.kill_all.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.kill_all.request_schema.Path")]
13pub enum Path {
14    #[serde(rename = "kill-all/request_schema")]
15    KillAllRequestSchema,
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> = vec!["kill-all", "request-schema"].into_iter().map(String::from).collect();
27        self.base.push_flags(&mut argv);
28        argv
29    }
30
31    fn request_base(&self) -> &crate::cli::command::RequestBase {
32        &self.base
33    }
34
35    fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
36        Some(&mut self.base)
37    }
38}
39
40pub type Response = crate::cli::command::ResponseSchema;
41
42impl TryFrom<Args> for Request {
43    type Error = crate::cli::command::FromArgsError;
44    fn try_from(args: Args) -> Result<Self, Self::Error> {
45        Ok(Self { path_type: Path::KillAllRequestSchema, base: args.base.into() })
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
54    agent_arguments: Option<&crate::cli::command::AgentArguments>,
55) -> Result<Response, E::Error> {
56    request.base.clear_transform();
57    executor.execute_one(request, agent_arguments).await
58}
59
60#[cfg(feature = "cli-executor")]
61pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
62    executor: &E,
63    mut request: Request,
64    transform: crate::cli::command::Transform,
65
66    agent_arguments: Option<&crate::cli::command::AgentArguments>,
67) -> Result<serde_json::Value, E::Error> {
68    request.base.set_transform(transform);
69    executor.execute_one(request, agent_arguments).await
70}