JingsongLi commented on code in PR #4553:
URL: https://github.com/apache/paimon/pull/4553#discussion_r1860280619


##########
paimon-core/src/main/java/org/apache/paimon/rest/RESTCatalog.java:
##########
@@ -0,0 +1,206 @@
+/*
+ * 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.
+ */
+
+package org.apache.paimon.rest;
+
+import org.apache.paimon.annotation.VisibleForTesting;
+import org.apache.paimon.catalog.Catalog;
+import org.apache.paimon.catalog.Database;
+import org.apache.paimon.catalog.Identifier;
+import org.apache.paimon.fs.FileIO;
+import org.apache.paimon.fs.Path;
+import org.apache.paimon.manifest.PartitionEntry;
+import org.apache.paimon.options.Options;
+import org.apache.paimon.rest.requests.ConfigRequest;
+import org.apache.paimon.rest.responses.ConfigResponse;
+import org.apache.paimon.schema.Schema;
+import org.apache.paimon.schema.SchemaChange;
+import org.apache.paimon.table.Table;
+
+import org.apache.paimon.shade.guava30.com.google.common.collect.ImmutableMap;
+import org.apache.paimon.shade.guava30.com.google.common.collect.Maps;
+import 
org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.time.Duration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+
+/** A catalog implementation for REST. */
+public class RESTCatalog implements Catalog {
+    private RESTClient client;
+    private String token;
+    private ResourcePaths resourcePaths;
+    private Map<String, String> options;
+
+    private static final ObjectMapper objectMapper = RESTObjectMapper.create();
+
+    public RESTCatalog(Options options) {
+        String uri = options.get(RESTCatalogOptions.URI);
+        token = options.get(RESTCatalogOptions.TOKEN);
+        Optional<Duration> connectTimeout =
+                options.getOptional(RESTCatalogOptions.CONNECTION_TIMEOUT);
+        Optional<Duration> readTimeout = 
options.getOptional(RESTCatalogOptions.READ_TIMEOUT);
+        Integer threadPoolSize = 
options.get(RESTCatalogOptions.THREAD_POOL_SIZE);
+        int queueSize = options.get(RESTCatalogOptions.THREAD_POOL_QUEUE_SIZE);
+        HttpClientOptions httpClientOptions =
+                new HttpClientOptions(
+                        uri,
+                        connectTimeout,
+                        readTimeout,
+                        objectMapper,
+                        threadPoolSize,
+                        queueSize,
+                        DefaultErrorHandler.getInstance());
+        this.client = new HttpClient(httpClientOptions);
+        this.options = mergeOptions(optionsInner(), options.toMap());
+        this.resourcePaths =
+                ResourcePaths.forCatalogProperties(
+                        this.options.get(RESTCatalogInternalOptions.PREFIX));
+    }
+
+    @Override
+    public String warehouse() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Map<String, String> options() {
+        return this.options;
+    }
+
+    @Override
+    public FileIO fileIO() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public List<String> listDatabases() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void createDatabase(String name, boolean ignoreIfExists, 
Map<String, String> properties)
+            throws DatabaseAlreadyExistException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Database getDatabase(String name) throws DatabaseNotExistException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void dropDatabase(String name, boolean ignoreIfNotExists, boolean 
cascade)
+            throws DatabaseNotExistException, DatabaseNotEmptyException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Table getTable(Identifier identifier) throws TableNotExistException 
{
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Path getTableLocation(Identifier identifier) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public List<String> listTables(String databaseName) throws 
DatabaseNotExistException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void dropTable(Identifier identifier, boolean ignoreIfNotExists)
+            throws TableNotExistException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void createTable(Identifier identifier, Schema schema, boolean 
ignoreIfExists)
+            throws TableAlreadyExistException, DatabaseNotExistException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void renameTable(Identifier fromTable, Identifier toTable, boolean 
ignoreIfNotExists)
+            throws TableNotExistException, TableAlreadyExistException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void alterTable(
+            Identifier identifier, List<SchemaChange> changes, boolean 
ignoreIfNotExists)
+            throws TableNotExistException, ColumnAlreadyExistException, 
ColumnNotExistException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void createPartition(Identifier identifier, Map<String, String> 
partitionSpec)
+            throws TableNotExistException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void dropPartition(Identifier identifier, Map<String, String> 
partitions)
+            throws TableNotExistException, PartitionNotExistException {}
+
+    @Override
+    public List<PartitionEntry> listPartitions(Identifier identifier)
+            throws TableNotExistException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public boolean allowUpperCase() {
+        return false;
+    }
+
+    @Override
+    public void close() throws Exception {}
+
+    @VisibleForTesting
+    Map<String, String> optionsInner() {
+        ConfigResponse response =
+                client.post(
+                        ResourcePaths.config(),
+                        new ConfigRequest(),
+                        ConfigResponse.class,
+                        headers());

Review Comment:
   It should be init headers. Headers can be enriched from config response.



##########
paimon-core/src/main/java/org/apache/paimon/rest/requests/ConfigRequest.java:
##########
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+package org.apache.paimon.rest.requests;
+
+import org.apache.paimon.rest.RESTRequest;
+
+import org.apache.paimon.shade.com.fasterxml.jackson.annotation.JsonCreator;
+import 
org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+/** Request to get config. */
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ConfigRequest implements RESTRequest {

Review Comment:
   Should it contains warehouse? Or maybe we cannot let user to config 
warehouse option.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to