Skip to main content

objectiveai_sdk/cli/command/functions/profiles/get/
mod.rs

1//! `functions profiles get` — async handler stub.
2
3use crate::cli::command::{CommandRequest, RemotePathCommitOptionalOrFavorite};
4
5#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
6#[schemars(rename = "cli.command.functions.profiles.get.Request")]
7pub struct Request {
8    pub path_type: Path,
9    pub path: RemotePathCommitOptionalOrFavorite,
10    pub jq: Option<String>,
11}
12
13#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
14#[schemars(rename = "cli.command.functions.profiles.get.Path")]
15pub enum Path {
16    #[serde(rename = "functions/profiles/get")]
17    FunctionsProfilesGet,
18}
19
20impl CommandRequest for Request {
21    fn into_command(&self) -> Vec<String> {
22        let mut argv = vec![
23            "functions".to_string(),
24            "profiles".to_string(),
25            "get".to_string(),
26            "--path".to_string(),
27            self.path.into_arg_string(),
28        ];
29        if let Some(jq) = &self.jq {
30            argv.push("--jq".to_string());
31            argv.push(jq.clone());
32        }
33        argv
34    }
35}
36
37pub type Response = crate::functions::profiles::response::GetProfileResponse;
38
39#[derive(clap::Args)]
40pub struct Args {
41    /// Path to the target entry.
42    #[arg(long)]
43    pub path: String,
44    /// jq filter applied to the JSON output.
45    #[arg(long)]
46    pub jq: Option<String>,
47}
48
49#[derive(clap::Args)]
50#[command(args_conflicts_with_subcommands = true)]
51pub struct Command {
52    #[command(flatten)]
53    pub args: Args,
54    #[command(subcommand)]
55    pub schema: Option<Schema>,
56}
57
58#[derive(clap::Subcommand)]
59pub enum Schema {
60    /// Emit the JSON Schema for this leaf's `Request` type and exit.
61    RequestSchema(request_schema::Args),
62    /// Emit the JSON Schema for this leaf's `Response` type and exit.
63    ResponseSchema(response_schema::Args),
64}
65
66impl TryFrom<Args> for Request {
67    type Error = crate::cli::command::FromArgsError;
68    fn try_from(args: Args) -> Result<Self, Self::Error> {
69        let path = args
70            .path
71            .parse::<RemotePathCommitOptionalOrFavorite>()
72            .map_err(|msg| crate::cli::command::FromArgsError::path_parse("path", msg))?;
73        Ok(Self { path_type: Path::FunctionsProfilesGet, path, jq: args.jq })
74    }
75}
76
77#[cfg(feature = "cli-executor")]
78pub async fn execute<E: crate::cli::command::CommandExecutor>(
79    executor: &E,
80    mut request: Request,
81
82        agent_arguments: Option<&crate::cli::command::AgentArguments>,
83    ) -> Result<Response, E::Error> {
84    request.jq = None;
85    executor.execute_one(request, agent_arguments).await
86}
87
88#[cfg(feature = "cli-executor")]
89pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
90    executor: &E,
91    mut request: Request,
92    jq: String,
93
94        agent_arguments: Option<&crate::cli::command::AgentArguments>,
95    ) -> Result<serde_json::Value, E::Error> {
96    request.jq = Some(jq);
97    executor.execute_one(request, agent_arguments).await
98}
99
100pub mod request_schema;
101
102
103pub mod response_schema;