Skip to content

Commit

Permalink
list all basins
Browse files Browse the repository at this point in the history
Signed-off-by: Vaibhav Rabber <[email protected]>
  • Loading branch information
vrongmeal committed Dec 13, 2024
1 parent 1ea6184 commit bc350ea
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
33 changes: 33 additions & 0 deletions examples/list_all_basins.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use streamstore::{
client::{Client, ClientConfig},
types::ListBasinsRequest,
};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
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<String> = 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(())
}
15 changes: 0 additions & 15 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,6 @@ pub struct BasinConfig {
pub default_stream_config: Option<StreamConfig>,
}

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<BasinConfig> for api::BasinConfig {
fn from(value: BasinConfig) -> Self {
let BasinConfig {
Expand Down

0 comments on commit bc350ea

Please sign in to comment.