Skip to main content

objectiveai_sdk/cli/command/api/config/mcp_authorization/del/
mod.rs

1//! `config api mcp-authorization del` — async handler stub.
2
3use crate::cli::command::CommandRequest;
4
5#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
6#[schemars(rename = "cli.command.api.config.mcp_authorization.del.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 key: String,
13}
14
15#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
16#[schemars(rename = "cli.command.api.config.mcp_authorization.del.Path")]
17pub enum Path {
18    #[serde(rename = "api/config/mcp_authorization/del")]
19    ApiConfigMcpAuthorizationDel,
20}
21
22impl CommandRequest for Request {
23    fn request_base(&self) -> &crate::cli::command::RequestBase {
24        &self.base
25    }
26
27    fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
28        Some(&mut self.base)
29    }
30}
31
32pub type Response = crate::cli::command::Ok;
33
34#[derive(clap::Args)]
35#[command(group(clap::ArgGroup::new("key_required").required(true).args(["key"])))]
36pub struct Args {
37    /// Mutate the global config layer.
38    #[arg(long)]
39    pub global: bool,
40    /// Mutate the state config layer.
41    #[arg(long)]
42    pub state: bool,
43    #[command(flatten)]
44    pub base: crate::cli::command::RequestBaseArgs,
45    /// Entry key (MCP server name).
46    #[arg(long)]
47    pub key: Option<String>,
48}
49
50#[derive(clap::Args)]
51#[command(args_conflicts_with_subcommands = true)]
52pub struct Command {
53    #[command(flatten)]
54    pub args: Args,
55    #[command(subcommand)]
56    pub schema: Option<Schema>,
57}
58
59#[derive(clap::Subcommand)]
60pub enum Schema {
61    /// Emit the JSON Schema for this leaf's `Request` type and exit.
62    RequestSchema(request_schema::Args),
63    /// Emit the JSON Schema for this leaf's `Response` type and exit.
64    ResponseSchema(response_schema::Args),
65}
66
67impl TryFrom<Args> for Request {
68    type Error = crate::cli::command::FromArgsError;
69    fn try_from(args: Args) -> Result<Self, Self::Error> {
70        let scope = match (args.global, args.state) {
71            (true, false) => crate::cli::command::SetScope::Global,
72            (false, true) => crate::cli::command::SetScope::State,
73            _ => {
74                return Err(crate::cli::command::FromArgsError {
75                    field: "scope",
76                    source: crate::cli::command::FromArgsErrorSource::Plain(
77                        "exactly one of --global, --state is required".to_string(),
78                    ),
79                });
80            }
81        };
82        Ok(Self {
83            base: args.base.into(), path_type: Path::ApiConfigMcpAuthorizationDel,
84            scope,
85            key: args.key.ok_or_else(|| {
86                crate::cli::command::FromArgsError::path_parse(
87                    "key",
88                    "--key is required".to_string(),
89                )
90            })?,
91        })
92    }
93}
94
95#[cfg(feature = "cli-executor")]
96pub async fn execute<E: crate::cli::command::CommandExecutor>(
97    executor: &E,
98    request: Request,
99
100        agent_arguments: Option<&crate::cli::command::AgentArguments>,
101    ) -> Result<Response, E::Error> {
102    executor.execute_one(request, agent_arguments).await
103}
104
105pub mod request_schema;
106
107
108pub mod response_schema;
109
110#[cfg(feature = "cli-executor")]
111pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
112    executor: &E,
113    request: Request,
114    _transform: crate::cli::command::Transform,
115
116        agent_arguments: Option<&crate::cli::command::AgentArguments>,
117    ) -> Result<serde_json::Value, E::Error> {
118    let resp: Response = executor.execute_one(request, agent_arguments).await?;
119    Ok(serde_json::to_value(resp).expect("Response serializes"))
120}