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//! # Pagination
59//!
60//! Set a page size for namespace and table listings with
61//! [`RestSessionCatalogBuilder::with_page_size`] or [`REST_CATALOG_PROP_PAGE_SIZE`].
62//!
63//! # Session catalog API
64//!
65//! ```rust, no_run
66//! use std::collections::HashMap;
67//!
68//! use iceberg::{SessionCatalog, SessionContext};
69//! use iceberg_catalog_rest::{REST_CATALOG_PROP_URI, RestSessionCatalogBuilder};
70//!
71//! #[tokio::main]
72//! async fn main() {
73//! let catalog = RestSessionCatalogBuilder::default()
74//! .load(
75//! "rest",
76//! HashMap::from([(
77//! REST_CATALOG_PROP_URI.to_string(),
78//! "http://localhost:8181".to_string(),
79//! )]),
80//! )
81//! .await
82//! .unwrap();
83//! let context = SessionContext::builder()
84//! .identity("user123".to_string())
85//! .build();
86//!
87//! let namespaces = catalog.list_namespaces(&context, None).await.unwrap();
88//! }
89//! ```
90
91#![deny(missing_docs)]
92
93mod auth;
94mod catalog;
95mod client;
96pub use client::HttpClient;
97mod request;
98pub use request::{HttpRequest, HttpRequestBody};
99mod response;
100pub use response::HttpResponse;
101mod endpoint;
102mod types;
103
104pub use auth::*;
105pub use catalog::*;
106pub use endpoint::Endpoint;
107pub use types::*;