objectiveai_sdk/cli/command/api/config/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.get.Request")]
7pub struct Request {
8 pub path_type: Path,
9 #[serde(flatten)]
10 pub base: crate::cli::command::RequestBase,
11}
12
13#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
14#[schemars(rename = "cli.command.api.config.get.Path")]
15pub enum Path {
16 #[serde(rename = "api/config/get")]
17 ApiConfigGet,
18}
19
20impl CommandRequest for Request {
21 fn request_base(&self) -> &crate::cli::command::RequestBase {
22 &self.base
23 }
24
25 fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
26 Some(&mut self.base)
27 }
28}
29
30#[derive(PartialEq, Debug, Clone, Default, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
31#[schemars(rename = "cli.command.api.config.get.Response")]
32pub struct Response {
33 #[serde(skip_serializing_if = "Option::is_none")]
34 #[schemars(extend("omitempty" = true))]
35 pub address: Option<String>,
36 #[serde(skip_serializing_if = "Option::is_none")]
37 #[schemars(extend("omitempty" = true))]
38 pub objectiveai_authorization: Option<String>,
39 #[serde(skip_serializing_if = "Option::is_none")]
40 #[schemars(extend("omitempty" = true))]
41 pub openrouter_authorization: Option<String>,
42 #[serde(skip_serializing_if = "Option::is_none")]
43 #[schemars(extend("omitempty" = true))]
44 pub github_authorization: Option<String>,
45 #[serde(skip_serializing_if = "Option::is_none")]
46 #[schemars(extend("omitempty" = true))]
47 pub mcp_authorization: Option<indexmap::IndexMap<String, String>>,
48 #[serde(skip_serializing_if = "Option::is_none")]
49 #[schemars(extend("omitempty" = true))]
50 pub user_agent: Option<String>,
51 #[serde(skip_serializing_if = "Option::is_none")]
52 #[schemars(extend("omitempty" = true))]
53 pub http_referer: Option<String>,
54 #[serde(skip_serializing_if = "Option::is_none")]
55 #[schemars(extend("omitempty" = true))]
56 pub x_title: Option<String>,
57 #[serde(skip_serializing_if = "Option::is_none")]
58 #[schemars(extend("omitempty" = true))]
59 pub commit_author_name: Option<String>,
60 #[serde(skip_serializing_if = "Option::is_none")]
61 #[schemars(extend("omitempty" = true))]
62 pub commit_author_email: Option<String>,
63}
64
65#[derive(clap::Args)]
66pub struct Args {
67 #[command(flatten)]
68 pub base: crate::cli::command::RequestBaseArgs,
69}
70
71#[derive(clap::Args)]
72#[command(args_conflicts_with_subcommands = true)]
73pub struct Command {
74 #[command(flatten)]
75 pub args: Args,
76 #[command(subcommand)]
77 pub schema: Option<Schema>,
78}
79
80#[derive(clap::Subcommand)]
81pub enum Schema {
82 RequestSchema(request_schema::Args),
84 ResponseSchema(response_schema::Args),
86}
87
88impl TryFrom<Args> for Request {
89 type Error = crate::cli::command::FromArgsError;
90 fn try_from(args: Args) -> Result<Self, Self::Error> {
91 Ok(Self { path_type: Path::ApiConfigGet,
92 base: args.base.into(),
93 })
94 }
95}
96
97#[cfg(feature = "cli-executor")]
98pub async fn execute<E: crate::cli::command::CommandExecutor>(
99 executor: &E,
100 mut request: Request,
101
102 agent_arguments: Option<&crate::cli::command::AgentArguments>,
103 ) -> Result<Response, E::Error> {
104 request.base.clear_transform();
105 executor.execute_one(request, agent_arguments).await
106}
107
108#[cfg(feature = "cli-executor")]
109pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
110 executor: &E,
111 mut request: Request,
112 transform: crate::cli::command::Transform,
113
114 agent_arguments: Option<&crate::cli::command::AgentArguments>,
115 ) -> Result<serde_json::Value, E::Error> {
116 request.base.set_transform(transform);
117 executor.execute_one(request, agent_arguments).await
118}
119
120#[cfg(feature = "mcp")]
121impl crate::cli::command::CommandResponse for Response {
122 fn into_mcp(self) -> crate::cli::command::McpResponseItem {
123 crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
124 }
125}
126
127pub mod request_schema;
128
129pub mod response_schema;
130
131#[cfg(feature = "cli-listener")]
136pub struct ListenerExecution {
137 pub request: Request,
138 pub agent_arguments: crate::cli::command::AgentArguments,
139 pub response: crate::cli::broadcast_listener::UnaryResponse<Response>,
140}