kura_cli/commands/
projection.rs1use clap::Subcommand;
2
3use crate::util::api_request;
4
5#[derive(Subcommand)]
6pub enum ProjectionCommands {
7 Get {
9 #[arg(long)]
11 projection_type: String,
12 #[arg(long)]
14 key: String,
15 },
16 List {
18 #[arg(long)]
20 projection_type: String,
21 },
22}
23
24pub async fn run(api_url: &str, token: Option<&str>, command: ProjectionCommands) -> i32 {
25 match command {
26 ProjectionCommands::Get {
27 projection_type,
28 key,
29 } => get(api_url, token, &projection_type, &key).await,
30 ProjectionCommands::List { projection_type } => {
31 list(api_url, token, &projection_type).await
32 }
33 }
34}
35
36async fn get(api_url: &str, token: Option<&str>, projection_type: &str, key: &str) -> i32 {
37 api_request(
38 api_url,
39 reqwest::Method::GET,
40 &format!("/v1/projections/{projection_type}/{key}"),
41 token,
42 None,
43 &[],
44 &[],
45 false,
46 false,
47 )
48 .await
49}
50
51async fn list(api_url: &str, token: Option<&str>, projection_type: &str) -> i32 {
52 api_request(
53 api_url,
54 reqwest::Method::GET,
55 &format!("/v1/projections/{projection_type}"),
56 token,
57 None,
58 &[],
59 &[],
60 false,
61 false,
62 )
63 .await
64}