Skip to main content

objectiveai_sdk/cli/command/kill_all/response_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.response_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.response_schema.Path")]
13pub enum Path {
14    #[serde(rename = "kill-all/response_schema")]
15    KillAllResponseSchema,
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 request_base(&self) -> &crate::cli::command::RequestBase {
26        &self.base
27    }
28
29    fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
30        Some(&mut self.base)
31    }
32}
33
34pub type Response = crate::cli::command::ResponseSchema;
35
36impl TryFrom<Args> for Request {
37    type Error = crate::cli::command::FromArgsError;
38    fn try_from(args: Args) -> Result<Self, Self::Error> {
39        Ok(Self { path_type: Path::KillAllResponseSchema, base: args.base.into() })
40    }
41}
42
43#[cfg(feature = "cli-executor")]
44pub async fn execute<E: crate::cli::command::CommandExecutor>(
45    executor: &E,
46    mut request: Request,
47
48    agent_arguments: Option<&crate::cli::command::AgentArguments>,
49) -> Result<Response, E::Error> {
50    request.base.clear_transform();
51    executor.execute_one(request, agent_arguments).await
52}
53
54#[cfg(feature = "cli-executor")]
55pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
56    executor: &E,
57    mut request: Request,
58    transform: crate::cli::command::Transform,
59
60    agent_arguments: Option<&crate::cli::command::AgentArguments>,
61) -> Result<serde_json::Value, E::Error> {
62    request.base.set_transform(transform);
63    executor.execute_one(request, agent_arguments).await
64}