objectiveai_sdk/cli/command/config/api/port/set/
mod.rs1use crate::cli::command::CommandRequest;
4
5#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
6#[schemars(rename = "cli.command.config.api.port.set.Request")]
7pub struct Request {
8 pub path_type: Path,
9 pub value: u16,
10}
11
12#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
13#[schemars(rename = "cli.command.config.api.port.set.Path")]
14pub enum Path {
15 #[serde(rename = "config/api/port/set")]
16 ConfigApiPortSet,
17}
18
19impl CommandRequest for Request {
20 fn into_command(&self) -> Vec<String> {
21 vec!["config".to_string(), "api".to_string(), "port".to_string(), "set".to_string(), self.value.to_string()]
22 }
23}
24
25pub type Response = crate::cli::command::Ok;
26
27#[derive(clap::Args)]
28pub struct Args {
29 pub value: u16,
31}
32
33#[derive(clap::Args)]
34#[command(args_conflicts_with_subcommands = true)]
35pub struct Command {
36 #[command(flatten)]
37 pub args: Args,
38 #[command(subcommand)]
39 pub schema: Option<Schema>,
40}
41
42#[derive(clap::Subcommand)]
43pub enum Schema {
44 RequestSchema(request_schema::Args),
46 ResponseSchema(response_schema::Args),
48}
49
50impl TryFrom<Args> for Request {
51 type Error = crate::cli::command::FromArgsError;
52 fn try_from(args: Args) -> Result<Self, Self::Error> {
53 Ok(Self { path_type: Path::ConfigApiPortSet,
54 value: args.value,
55 })
56 }
57}
58
59#[cfg(feature = "cli-executor")]
60pub async fn execute<E: crate::cli::command::CommandExecutor>(
61 executor: &E,
62 request: Request,
63
64 agent_arguments: Option<&crate::cli::command::AgentArguments>,
65 ) -> Result<Response, E::Error> {
66 executor.execute_one(request, agent_arguments).await
67}
68
69pub mod request_schema;
70
71
72pub mod response_schema;
73
74#[cfg(feature = "cli-executor")]
75pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
76 executor: &E,
77 request: Request,
78 _jq: String,
79
80 agent_arguments: Option<&crate::cli::command::AgentArguments>,
81 ) -> Result<serde_json::Value, E::Error> {
82 let resp: Response = executor.execute_one(request, agent_arguments).await?;
83 Ok(serde_json::to_value(resp).expect("Response serializes"))
84}