Skip to main content

objectiveai_sdk/cli/command/config/api/openrouter_authorization/set/
mod.rs

1//! `config api openrouter-authorization set` — 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.config.api.openrouter_authorization.set.Request")]
7pub struct Request {
8    pub path_type: Path,
9    pub value: String,
10}
11
12#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
13#[schemars(rename = "cli.command.config.api.openrouter_authorization.set.Path")]
14pub enum Path {
15    #[serde(rename = "config/api/openrouter_authorization/set")]
16    ConfigApiOpenrouterAuthorizationSet,
17}
18
19impl CommandRequest for Request {
20    fn into_command(&self) -> Vec<String> {
21        vec!["config".to_string(), "api".to_string(), "openrouter-authorization".to_string(), "set".to_string(), self.value.clone()]
22    }
23}
24
25pub type Response = crate::cli::command::Ok;
26
27#[derive(clap::Args)]
28pub struct Args {
29    /// New value.
30    pub value: String,
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    /// Emit the JSON Schema for this leaf's `Request` type and exit.
45    RequestSchema(request_schema::Args),
46    /// Emit the JSON Schema for this leaf's `Response` type and exit.
47    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::ConfigApiOpenrouterAuthorizationSet,
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}