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;
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: crate::RemotePathCommitOptional,
10    #[serde(flatten)]
11    pub base: crate::cli::command::RequestBase,
12}
13
14#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
15#[schemars(rename = "cli.command.functions.profiles.get.Path")]
16pub enum Path {
17    #[serde(rename = "functions/profiles/get")]
18    FunctionsProfilesGet,
19}
20
21impl CommandRequest for Request {
22    fn into_command(&self) -> Vec<String> {
23        let mut argv = vec![
24            "functions".to_string(),
25            "profiles".to_string(),
26            "get".to_string(),
27            "--path".to_string(),
28            crate::cli::command::path_ref::remote_path_to_arg_string(&self.path),
29        ];
30        self.base.push_flags(&mut argv);
31        argv
32    }
33
34    fn request_base(&self) -> &crate::cli::command::RequestBase {
35        &self.base
36    }
37
38    fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
39        Some(&mut self.base)
40    }
41}
42
43/// Response for `functions profiles get` — a resolved Profile with its remote path.
44#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
45#[schemars(rename = "cli.command.functions.profiles.get.Response")]
46pub struct Response {
47    #[serde(flatten)]
48    #[schemars(schema_with = "crate::flatten_schema::<crate::RemotePath>")]
49    pub path: crate::RemotePath,
50    #[serde(flatten)]
51    #[schemars(
52        schema_with = "crate::flatten_schema::<crate::functions::RemoteProfile>"
53    )]
54    pub inner: crate::functions::RemoteProfile,
55}
56
57#[cfg(feature = "mcp")]
58impl crate::cli::command::CommandResponse for Response {
59    fn into_mcp(self) -> crate::cli::command::McpResponseItem {
60        crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
61    }
62}
63
64#[derive(clap::Args)]
65pub struct Args {
66    /// Path to the target entry.
67    #[arg(long)]
68    pub path: String,
69    #[command(flatten)]
70    pub base: crate::cli::command::RequestBaseArgs,
71}
72
73#[derive(clap::Args)]
74#[command(args_conflicts_with_subcommands = true)]
75pub struct Command {
76    #[command(flatten)]
77    pub args: Args,
78    #[command(subcommand)]
79    pub schema: Option<Schema>,
80}
81
82#[derive(clap::Subcommand)]
83pub enum Schema {
84    /// Emit the JSON Schema for this leaf's `Request` type and exit.
85    RequestSchema(request_schema::Args),
86    /// Emit the JSON Schema for this leaf's `Response` type and exit.
87    ResponseSchema(response_schema::Args),
88}
89
90impl TryFrom<Args> for Request {
91    type Error = crate::cli::command::FromArgsError;
92    fn try_from(args: Args) -> Result<Self, Self::Error> {
93        let path = args
94            .path
95            .parse::<crate::RemotePathCommitOptional>()
96            .map_err(|msg| crate::cli::command::FromArgsError::path_parse("path", msg))?;
97        Ok(Self { path_type: Path::FunctionsProfilesGet, path, base: args.base.into() })
98    }
99}
100
101#[cfg(feature = "cli-executor")]
102pub async fn execute<E: crate::cli::command::CommandExecutor>(
103    executor: &E,
104    mut request: Request,
105
106        agent_arguments: Option<&crate::cli::command::AgentArguments>,
107    ) -> Result<Response, E::Error> {
108    request.base.clear_transform();
109    executor.execute_one(request, agent_arguments).await
110}
111
112#[cfg(feature = "cli-executor")]
113pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
114    executor: &E,
115    mut request: Request,
116    transform: crate::cli::command::Transform,
117
118        agent_arguments: Option<&crate::cli::command::AgentArguments>,
119    ) -> Result<serde_json::Value, E::Error> {
120    request.base.set_transform(transform);
121    executor.execute_one(request, agent_arguments).await
122}
123
124pub mod request_schema;
125
126
127pub mod response_schema;