objectiveai_sdk/cli/command/api/config/mcp_authorization/get/
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_authorization.get.Request")]
7pub struct Request {
8 pub path_type: Path,
9 pub scope: crate::cli::command::GetScope,
10 #[serde(flatten)]
11 pub base: crate::cli::command::RequestBase,
12}
13
14#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
15#[schemars(rename = "cli.command.api.config.mcp_authorization.get.Path")]
16pub enum Path {
17 #[serde(rename = "api/config/mcp_authorization/get")]
18 ApiConfigMcpAuthorizationGet,
19}
20
21impl CommandRequest for Request {
22 fn request_base(&self) -> &crate::cli::command::RequestBase {
23 &self.base
24 }
25
26 fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
27 Some(&mut self.base)
28 }
29}
30
31#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
32#[schemars(rename = "cli.command.api.config.mcp_authorization.get.Response")]
33pub struct Response {
34 #[serde(skip_serializing_if = "Option::is_none")]
35 #[schemars(extend("omitempty" = true))]
36 pub mcp_authorization: Option<indexmap::IndexMap<String, String>>,
37}
38
39#[derive(clap::Args)]
40pub struct Args {
41 #[arg(long)]
43 pub global: bool,
44 #[arg(long)]
46 pub state: bool,
47 #[arg(long)]
49 pub r#final: bool,
50 #[command(flatten)]
51 pub base: crate::cli::command::RequestBaseArgs,
52}
53
54#[derive(clap::Args)]
55#[command(args_conflicts_with_subcommands = true)]
56pub struct Command {
57 #[command(flatten)]
58 pub args: Args,
59 #[command(subcommand)]
60 pub schema: Option<Schema>,
61}
62
63#[derive(clap::Subcommand)]
64pub enum Schema {
65 RequestSchema(request_schema::Args),
67 ResponseSchema(response_schema::Args),
69}
70
71impl TryFrom<Args> for Request {
72 type Error = crate::cli::command::FromArgsError;
73 fn try_from(args: Args) -> Result<Self, Self::Error> {
74 let scope = match (args.global, args.state, args.r#final) {
75 (true, false, false) => crate::cli::command::GetScope::Global,
76 (false, true, false) => crate::cli::command::GetScope::State,
77 (false, false, true) => crate::cli::command::GetScope::Final,
78 _ => {
79 return Err(crate::cli::command::FromArgsError {
80 field: "scope",
81 source: crate::cli::command::FromArgsErrorSource::Plain(
82 "exactly one of --global, --state, --final is required".to_string(),
83 ),
84 });
85 }
86 };
87 Ok(Self { path_type: Path::ApiConfigMcpAuthorizationGet,
88 scope,
89 base: args.base.into(),
90 })
91 }
92}
93
94#[cfg(feature = "cli-executor")]
95pub async fn execute<E: crate::cli::command::CommandExecutor>(
96 executor: &E,
97 mut request: Request,
98
99 agent_arguments: Option<&crate::cli::command::AgentArguments>,
100 ) -> Result<Response, E::Error> {
101 request.base.clear_transform();
102 executor.execute_one(request, agent_arguments).await
103}
104
105#[cfg(feature = "cli-executor")]
106pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
107 executor: &E,
108 mut request: Request,
109 transform: crate::cli::command::Transform,
110
111 agent_arguments: Option<&crate::cli::command::AgentArguments>,
112 ) -> Result<serde_json::Value, E::Error> {
113 request.base.set_transform(transform);
114 executor.execute_one(request, agent_arguments).await
115}
116
117#[cfg(feature = "mcp")]
118impl crate::cli::command::CommandResponse for Response {
119 fn into_mcp(self) -> crate::cli::command::McpResponseItem {
120 crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
121 }
122}
123
124pub mod request_schema;
125
126
127pub mod response_schema;