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