From bc350ea9a2bfb219b17f4734ee706d72e415ca73 Mon Sep 17 00:00:00 2001 From: Vaibhav Rabber Date: Fri, 13 Dec 2024 22:29:55 +0530 Subject: [PATCH] list all basins Signed-off-by: Vaibhav Rabber --- examples/list_all_basins.rs | 33 +++++++++++++++++++++++++++++++++ src/types.rs | 15 --------------- 2 files changed, 33 insertions(+), 15 deletions(-) create mode 100644 examples/list_all_basins.rs diff --git a/examples/list_all_basins.rs b/examples/list_all_basins.rs new file mode 100644 index 0000000..84cbf85 --- /dev/null +++ b/examples/list_all_basins.rs @@ -0,0 +1,33 @@ +use streamstore::{ + client::{Client, ClientConfig}, + types::ListBasinsRequest, +}; + +#[tokio::main] +async fn main() -> Result<(), Box> { + let token = std::env::var("S2_AUTH_TOKEN")?; + let config = ClientConfig::new(token); + let client = Client::new(config); + + let mut all_basins = Vec::new(); + + let mut has_more = true; + let mut start_after: Option = None; + + while has_more { + let mut list_basins_request = ListBasinsRequest::new(); + if let Some(start_after) = start_after.take() { + list_basins_request = list_basins_request.with_start_after(start_after); + } + + let list_basins_response = client.list_basins(list_basins_request).await?; + + all_basins.extend(list_basins_response.basins); + + has_more = list_basins_response.has_more; + } + + println!("{all_basins:#?}"); + + Ok(()) +} diff --git a/src/types.rs b/src/types.rs index 3a11ff2..b759bab 100644 --- a/src/types.rs +++ b/src/types.rs @@ -101,21 +101,6 @@ pub struct BasinConfig { pub default_stream_config: Option, } -impl BasinConfig { - /// Create a new request. - pub fn new() -> Self { - Self::default() - } - - /// Overwrite default stream configuration. - pub fn with_default_stream_config(self, default_stream_config: StreamConfig) -> Self { - Self { - default_stream_config: Some(default_stream_config), - ..self - } - } -} - impl From for api::BasinConfig { fn from(value: BasinConfig) -> Self { let BasinConfig {