use crate::catalog::rest::IcebergRestCatalog;
use crate::catalog::Catalog;
use std::sync::Arc;
#[derive(Debug, Clone)]
pub struct CatalogConfig {
pub catalog_url: Option<String>,
pub token: Option<String>,
}
impl CatalogConfig {
pub async fn create_catalog(&self) -> Result<Arc<dyn Catalog>, String> {
let url = self.catalog_url.as_ref().ok_or_else(|| {
"Catalog URL required. Use --catalog-url or ICEPICK_CATALOG_URL".to_string()
})?;
let token = self
.token
.as_ref()
.ok_or_else(|| "Token required. Use --token or ICEPICK_TOKEN".to_string())?;
let catalog = IcebergRestCatalog::from_url("icepick", url, token, None)
.await
.map_err(|e| format!("Failed to create catalog: {}", e))?;
Ok(Arc::new(catalog))
}
pub fn catalog_type(&self) -> &'static str {
"REST Catalog"
}
}