Skip to main content

objectiveai_sdk/cli/command/viewer/generate_secret_signature_pair/
mod.rs

1//! `viewer generate-secret-signature-pair` — 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.viewer.generate_secret_signature_pair.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.viewer.generate_secret_signature_pair.Path")]
15pub enum Path {
16    #[serde(rename = "viewer/generate_secret_signature_pair")]
17    ViewerGenerateSecretSignaturePair,
18}
19impl CommandRequest for Request {
20    fn into_command(&self) -> Vec<String> {
21        let mut argv = vec!["viewer".to_string(), "generate-secret-signature-pair".to_string()];
22        self.base.push_flags(&mut argv);
23        argv
24    }
25
26    fn request_base(&self) -> &crate::cli::command::RequestBase {
27        &self.base
28    }
29
30    fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
31        Some(&mut self.base)
32    }
33}
34
35#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
36#[schemars(rename = "cli.command.viewer.generate_secret_signature_pair.Response")]
37pub struct Response {
38    pub secret: String,
39    pub signature: String,
40}
41
42#[derive(clap::Args)]
43pub struct Args {
44    #[command(flatten)]
45    pub base: crate::cli::command::RequestBaseArgs,
46}
47
48#[derive(clap::Args)]
49#[command(args_conflicts_with_subcommands = true)]
50pub struct Command {
51    #[command(flatten)]
52    pub args: Args,
53    #[command(subcommand)]
54    pub schema: Option<Schema>,
55}
56
57#[derive(clap::Subcommand)]
58pub enum Schema {
59    /// Emit the JSON Schema for this leaf's `Request` type and exit.
60    RequestSchema(request_schema::Args),
61    /// Emit the JSON Schema for this leaf's `Response` type and exit.
62    ResponseSchema(response_schema::Args),
63}
64
65impl TryFrom<Args> for Request {
66    type Error = crate::cli::command::FromArgsError;
67    fn try_from(args: Args) -> Result<Self, Self::Error> {
68        Ok(Self { path_type: Path::ViewerGenerateSecretSignaturePair, base: args.base.into() })
69    }
70}
71
72#[cfg(feature = "cli-executor")]
73pub async fn execute<E: crate::cli::command::CommandExecutor>(
74    executor: &E,
75    mut request: Request,
76
77        agent_arguments: Option<&crate::cli::command::AgentArguments>,
78    ) -> Result<Response, E::Error> {
79    request.base.clear_transform();
80    executor.execute_one(request, agent_arguments).await
81}
82
83#[cfg(feature = "cli-executor")]
84pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
85    executor: &E,
86    mut request: Request,
87    transform: crate::cli::command::Transform,
88
89        agent_arguments: Option<&crate::cli::command::AgentArguments>,
90    ) -> Result<serde_json::Value, E::Error> {
91    request.base.set_transform(transform);
92    executor.execute_one(request, agent_arguments).await
93}
94
95#[cfg(feature = "mcp")]
96impl crate::cli::command::CommandResponse for Response {
97    fn into_mcp(self) -> crate::cli::command::McpResponseItem {
98        crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
99    }
100}
101
102pub mod request_schema;
103
104pub mod response_schema;