diff --git a/Cargo.lock b/Cargo.lock index 9656140..8abf64d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1358,7 +1358,7 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "s2" version = "0.1.0" -source = "git+ssh://git@github.com/s2-streamstore/s2.rs.git?branch=basinstate-disp#12d3927993c9064651498ca46350cb0ca236e0c3" +source = "git+ssh://git@github.com/s2-streamstore/s2.rs.git?branch=main#153aa1b2d7e9eb328ce4ae50a1eeb972a780fdc9" dependencies = [ "backon", "http", diff --git a/Cargo.toml b/Cargo.toml index bbd0126..3483ee1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ dirs = "5.0.1" serde = { version = "1.0.210", features = ["derive"] } thiserror = "1.0.63" toml = "0.8.19" -s2 = { git = "ssh://git@github.com/s2-streamstore/s2.rs.git", branch = "basinstate-disp" } +s2 = { git = "ssh://git@github.com/s2-streamstore/s2.rs.git", branch = "main" } tokio = { version = "*", features = ["full"] } humantime = "2.1.0" miette = { version = "7.2.0", features = ["fancy"] } diff --git a/src/account.rs b/src/account.rs index fa27a9f..c72fc18 100644 --- a/src/account.rs +++ b/src/account.rs @@ -1,9 +1,9 @@ use s2::{ client::Client, - service_error::{CreateBasinError, DeleteBasinError, ServiceError}, + service_error::{CreateBasinError, DeleteBasinError, GetBasinConfigError, ServiceError}, types::{ - BasinConfig, CreateBasinResponse, ListBasinsResponse, RetentionPolicy, StorageClass, - StreamConfig, + BasinConfig, CreateBasinResponse, GetBasinConfigResponse, ListBasinsResponse, + RetentionPolicy, StorageClass, StreamConfig, }, }; @@ -21,6 +21,9 @@ pub enum AccountServiceError { #[error("Failed to delete basin")] DeleteBasin(#[from] ServiceError), + + #[error("Failed to get basin config")] + GetBasinConfig(#[from] ServiceError), } impl AccountService { @@ -84,4 +87,13 @@ impl AccountService { self.client.delete_basin(delete_basin_req).await?; Ok(()) } + + pub async fn get_basin_config(&self, name: String) -> Result { + let get_basin_config_req = s2::types::GetBasinConfigRequest::builder() + .basin(name) + .build(); + let GetBasinConfigResponse { config } = + self.client.get_basin_config(get_basin_config_req).await?; + Ok(config) + } } diff --git a/src/main.rs b/src/main.rs index 36b08d5..58877b1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -65,6 +65,7 @@ enum ConfigActions { }, } +#[deny(missing_docs)] #[derive(Subcommand, Debug)] enum AccountActions { /// List basins @@ -101,6 +102,22 @@ enum AccountActions { /// Basin name to delete. basin: String, }, + + /// Get basin config + GetBasinConfig { + /// Basin name to get config for. + basin: String, + }, + + /// Reconfigure a basin + ReconfigureBasin { + /// Basin name to reconfigure. + basin: String, + + /// Configuration to apply. + #[arg(short, long)] + config: Vec, + }, } #[derive(Subcommand, Debug)] @@ -122,6 +139,9 @@ enum BasinActions { #[arg(short, long)] limit: u32, }, + + /// Create a stream + CreateStream {}, } async fn s2_client(auth_token: String) -> Result { @@ -169,7 +189,6 @@ async fn run() -> Result<(), S2CliError> { Commands::Account { action } => { let cfg = config::load_config(&config_path)?; - println!("cfg: {:?}", cfg); let account_service = AccountService::new(s2_client(cfg.auth_token).await?); match action { AccountActions::ListBasins { @@ -212,6 +231,14 @@ async fn run() -> Result<(), S2CliError> { account_service.delete_basin(basin).await?; println!("{}", "✓ Basin deleted successfully".green().bold()); } + + AccountActions::GetBasinConfig { basin } => { + let basin_config = account_service.get_basin_config(basin).await?; + println!("{:?}", basin_config); + } + AccountActions::ReconfigureBasin { basin, config } => { + unimplemented!() + } } } Commands::Basins { action } => { @@ -232,6 +259,7 @@ async fn run() -> Result<(), S2CliError> { println!("{}", stream); } } + BasinActions::CreateStream {} => todo!(), } } }