use crate::cli::command::{CommandRequest, RemotePathCommitOptionalOrFavorite};
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
#[schemars(rename = "cli.command.functions.profiles.get.Request")]
pub struct Request {
pub path_type: Path,
pub path: RemotePathCommitOptionalOrFavorite,
pub jq: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
#[schemars(rename = "cli.command.functions.profiles.get.Path")]
pub enum Path {
#[serde(rename = "functions/profiles/get")]
FunctionsProfilesGet,
}
impl CommandRequest for Request {
fn into_command(&self) -> Vec<String> {
let mut argv = vec![
"functions".to_string(),
"profiles".to_string(),
"get".to_string(),
"--path".to_string(),
self.path.into_arg_string(),
];
if let Some(jq) = &self.jq {
argv.push("--jq".to_string());
argv.push(jq.clone());
}
argv
}
}
pub type Response = crate::functions::profiles::response::GetProfileResponse;
#[derive(clap::Args)]
pub struct Args {
#[arg(long)]
pub path: String,
#[arg(long)]
pub jq: Option<String>,
}
#[derive(clap::Args)]
#[command(args_conflicts_with_subcommands = true)]
pub struct Command {
#[command(flatten)]
pub args: Args,
#[command(subcommand)]
pub schema: Option<Schema>,
}
#[derive(clap::Subcommand)]
pub enum Schema {
RequestSchema(request_schema::Args),
ResponseSchema(response_schema::Args),
}
impl TryFrom<Args> for Request {
type Error = crate::cli::command::FromArgsError;
fn try_from(args: Args) -> Result<Self, Self::Error> {
let path = args
.path
.parse::<RemotePathCommitOptionalOrFavorite>()
.map_err(|msg| crate::cli::command::FromArgsError::path_parse("path", msg))?;
Ok(Self { path_type: Path::FunctionsProfilesGet, path, jq: args.jq })
}
}
#[cfg(feature = "cli-executor")]
pub async fn execute<E: crate::cli::command::CommandExecutor>(
executor: &E,
mut request: Request,
agent_arguments: Option<&crate::cli::command::AgentArguments>,
) -> Result<Response, E::Error> {
request.jq = None;
executor.execute_one(request, agent_arguments).await
}
#[cfg(feature = "cli-executor")]
pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
executor: &E,
mut request: Request,
jq: String,
agent_arguments: Option<&crate::cli::command::AgentArguments>,
) -> Result<serde_json::Value, E::Error> {
request.jq = Some(jq);
executor.execute_one(request, agent_arguments).await
}
pub mod request_schema;
pub mod response_schema;