iceberg_catalog_rest/lib.rs
1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements. See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership. The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License. You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied. See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18//! Iceberg REST API implementation.
19//!
20//! The crate provides two REST catalog APIs:
21//!
22//! - [`RestCatalog`] implements [`iceberg::Catalog`] by binding one
23//! [`iceberg::SessionContext`] to every operation.
24//! - [`RestSessionCatalog`] implements [`iceberg::SessionCatalog`] and accepts a
25//! session context with each operation.
26//!
27//! # Catalog compatibility API
28//!
29//! ```rust, no_run
30//! use std::collections::HashMap;
31//!
32//! use iceberg::CatalogBuilder;
33//! use iceberg_catalog_rest::{
34//! REST_CATALOG_PROP_URI, REST_CATALOG_PROP_WAREHOUSE, RestCatalogBuilder,
35//! };
36//!
37//! #[tokio::main]
38//! async fn main() {
39//! let catalog = RestCatalogBuilder::default()
40//! .load(
41//! "rest",
42//! HashMap::from([
43//! (
44//! REST_CATALOG_PROP_URI.to_string(),
45//! "http://localhost:8181".to_string(),
46//! ),
47//! (
48//! REST_CATALOG_PROP_WAREHOUSE.to_string(),
49//! "s3://warehouse".to_string(),
50//! ),
51//! ]),
52//! )
53//! .await
54//! .unwrap();
55//! }
56//! ```
57//!
58//! # Session catalog API
59//!
60//! ```rust, no_run
61//! use std::collections::HashMap;
62//!
63//! use iceberg::{SessionCatalog, SessionContext};
64//! use iceberg_catalog_rest::{REST_CATALOG_PROP_URI, RestSessionCatalogBuilder};
65//!
66//! #[tokio::main]
67//! async fn main() {
68//! let catalog = RestSessionCatalogBuilder::default()
69//! .load(
70//! "rest",
71//! HashMap::from([(
72//! REST_CATALOG_PROP_URI.to_string(),
73//! "http://localhost:8181".to_string(),
74//! )]),
75//! )
76//! .await
77//! .unwrap();
78//! let context = SessionContext::builder()
79//! .identity("user123".to_string())
80//! .build();
81//!
82//! let namespaces = catalog.list_namespaces(&context, None).await.unwrap();
83//! }
84//! ```
85
86#![deny(missing_docs)]
87
88mod auth;
89mod catalog;
90mod client;
91pub use client::HttpClient;
92mod request;
93pub use request::{HttpRequest, HttpRequestBody};
94mod response;
95pub use response::HttpResponse;
96mod endpoint;
97mod types;
98
99pub use auth::*;
100pub use catalog::*;
101pub use endpoint::Endpoint;
102pub use types::*;