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