liurenjie1024 commented on code in PR #78:
URL: https://github.com/apache/iceberg-rust/pull/78#discussion_r1364807441


##########
crates/catalog/rest/src/catalog.rs:
##########
@@ -0,0 +1,845 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! This module contains rest catalog implementation.
+
+use std::collections::HashMap;
+
+use async_trait::async_trait;
+use reqwest::header::{self, HeaderMap, HeaderName, HeaderValue};
+use reqwest::{Client, Request};
+use serde::de::DeserializeOwned;
+use typed_builder::TypedBuilder;
+use urlencoding::encode;
+
+use iceberg::table::Table;
+use iceberg::Result;
+use iceberg::{
+    Catalog, Error, ErrorKind, Namespace, NamespaceIdent, TableCommit, 
TableCreation, TableIdent,
+};
+
+use self::_serde::{
+    CatalogConfig, ErrorModel, ErrorResponse, ListNamespaceResponse, 
ListTableResponse,
+    NamespaceSerde, RenameTableRequest, NO_CONTENT, OK,
+};
+
+const ICEBERG_REST_SPEC_VERSION: &str = "0.14.1";
+const PATH_V1: &str = "v1";
+
+/// Rest catalog configuration.
+#[derive(Debug, TypedBuilder)]
+pub struct RestCatalogConfig {
+    uri: String,
+    #[builder(default, setter(strip_option))]
+    warehouse: Option<String>,
+
+    #[builder(default)]
+    props: HashMap<String, String>,
+}
+
+impl RestCatalogConfig {
+    fn config_endpoint(&self) -> String {
+        [&self.uri, PATH_V1, "config"].join("/")
+    }
+
+    fn namespaces_endpoint(&self) -> String {
+        [&self.uri, PATH_V1, "namespaces"].join("/")
+    }
+
+    fn namespace_endpoint(&self, ns: &NamespaceIdent) -> String {
+        [&self.uri, PATH_V1, "namespaces", &ns.encode_in_url()].join("/")
+    }
+
+    fn tables_endpoint(&self, ns: &NamespaceIdent) -> String {
+        [
+            &self.uri,
+            PATH_V1,
+            "namespaces",
+            &ns.encode_in_url(),
+            "tables",
+        ]
+        .join("/")
+    }
+
+    fn rename_table_endpoint(&self) -> String {
+        [&self.uri, PATH_V1, "tables", "rename"].join("/")
+    }
+
+    fn table_endpoint(&self, table: &TableIdent) -> String {
+        [
+            &self.uri,
+            PATH_V1,
+            "namespaces",
+            &table.namespace.encode_in_url(),
+            "tables",
+            encode(&table.name).as_ref(),
+        ]
+        .join("/")
+    }
+
+    fn try_create_rest_client(&self) -> Result<HttpClient> {
+        //TODO: We will add oauth, ssl config, sigv4 later
+        let mut headers = HeaderMap::new();

Review Comment:
   Good catch!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to