#[tokio::main]
#[cfg(feature = "aws-auth")]
pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
use std::convert::TryInto;
use opensearch::{
cat::CatIndicesParts,
http::transport::{SingleNodeConnectionPool, TransportBuilder},
OpenSearch,
};
use url::Url;
let aws_config = aws_config::load_from_env().await;
let host = ""; let transport = TransportBuilder::new(SingleNodeConnectionPool::new(Url::parse(host).unwrap()))
.auth(aws_config.try_into()?)
.build()?;
let client = OpenSearch::new(transport);
let response = client
.cat()
.indices(CatIndicesParts::None)
.v(true)
.send()
.await?;
let text = response.text().await?;
println!("{}", text);
Ok(())
}
#[cfg(not(feature = "aws-auth"))]
pub fn main() {
panic!("Requires the `aws-auth` feature to be enabled")
}