objectiveai_sdk/cli/command/api/config/mcp_timeout_ms/set/
mod.rs1use crate::cli::command::CommandRequest;
4
5#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
6#[schemars(rename = "cli.command.api.config.mcp_timeout_ms.set.Request")]
7pub struct Request {
8 pub path_type: Path,
9 #[serde(flatten)]
10 pub base: crate::cli::command::RequestBase,
11 pub scope: crate::cli::command::SetScope,
12 pub value: String,
15}
16
17#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
18#[schemars(rename = "cli.command.api.config.mcp_timeout_ms.set.Path")]
19pub enum Path {
20 #[serde(rename = "api/config/mcp_timeout_ms/set")]
21 ApiConfigMcpTimeoutMsSet,
22}
23
24impl CommandRequest for Request {
25 fn into_command(&self) -> Vec<String> {
26 let mut argv = vec!["api".to_string(), "config".to_string(), "mcp-timeout-ms".to_string(), "set".to_string(), self.value.clone()];
27 argv.push(match self.scope {
28 crate::cli::command::SetScope::Global => "--global".to_string(),
29 crate::cli::command::SetScope::State => "--state".to_string(),
30 });
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::Ok;
45
46#[derive(clap::Args)]
47pub struct Args {
48 #[arg(long)]
50 pub global: bool,
51 #[arg(long)]
53 pub state: bool,
54 #[command(flatten)]
55 pub base: crate::cli::command::RequestBaseArgs,
56 pub value: String,
58}
59
60#[derive(clap::Args)]
61#[command(args_conflicts_with_subcommands = true)]
62pub struct Command {
63 #[command(flatten)]
64 pub args: Args,
65 #[command(subcommand)]
66 pub schema: Option<Schema>,
67}
68
69#[derive(clap::Subcommand)]
70pub enum Schema {
71 RequestSchema(request_schema::Args),
73 ResponseSchema(response_schema::Args),
75}
76
77impl TryFrom<Args> for Request {
78 type Error = crate::cli::command::FromArgsError;
79 fn try_from(args: Args) -> Result<Self, Self::Error> {
80 let scope = match (args.global, args.state) {
81 (true, false) => crate::cli::command::SetScope::Global,
82 (false, true) => crate::cli::command::SetScope::State,
83 _ => {
84 return Err(crate::cli::command::FromArgsError {
85 field: "scope",
86 source: crate::cli::command::FromArgsErrorSource::Plain(
87 "exactly one of --global, --state is required".to_string(),
88 ),
89 });
90 }
91 };
92 Ok(Self {
93 base: args.base.into(), path_type: Path::ApiConfigMcpTimeoutMsSet,
94 scope,
95 value: args.value,
96 })
97 }
98}
99
100#[cfg(feature = "cli-executor")]
101pub async fn execute<E: crate::cli::command::CommandExecutor>(
102 executor: &E,
103 request: Request,
104
105 agent_arguments: Option<&crate::cli::command::AgentArguments>,
106 ) -> Result<Response, E::Error> {
107 executor.execute_one(request, agent_arguments).await
108}
109
110pub mod request_schema;
111
112
113pub mod response_schema;
114
115#[cfg(feature = "cli-executor")]
116pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
117 executor: &E,
118 request: Request,
119 _transform: crate::cli::command::Transform,
120
121 agent_arguments: Option<&crate::cli::command::AgentArguments>,
122 ) -> Result<serde_json::Value, E::Error> {
123 let resp: Response = executor.execute_one(request, agent_arguments).await?;
124 Ok(serde_json::to_value(resp).expect("Response serializes"))
125}