Skip to content
Permalink
Browse files
Core: Refactor REST catalog to RESTSessionCatalog (#4846)
  • Loading branch information
rdblue committed May 23, 2022
1 parent c666c49 commit a91162324263d7715943dd86ec2ab019cc4fde5e
Showing 5 changed files with 133 additions and 105 deletions.
@@ -25,7 +25,7 @@
import org.apache.iceberg.relocated.com.google.common.base.Preconditions;

/**
* Takes in the full configuration for the {@link RESTCatalog}, which should already have
* Takes in the full configuration for the {@link RESTSessionCatalog}, which should already have
* called the server's initial configuration route.
* Using the merged configuration, an instance of {@link RESTClient} is obtained that can be used with the
* RESTCatalog.
@@ -22,24 +22,50 @@
import java.io.Closeable;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Supplier;
import org.apache.iceberg.rest.responses.ErrorResponse;

/**
* Interface for a basic HTTP Client for interfacing with the REST catalog.
*/
public interface RESTClient extends Closeable {

default void head(String path, Supplier<Map<String, String>> headers, Consumer<ErrorResponse> errorHandler) {
head(path, headers.get(), errorHandler);
}

void head(String path, Map<String, String> headers, Consumer<ErrorResponse> errorHandler);

default <T extends RESTResponse> T delete(String path, Class<T> responseType, Supplier<Map<String, String>> headers,
Consumer<ErrorResponse> errorHandler) {
return delete(path, responseType, headers.get(), errorHandler);
}

<T extends RESTResponse> T delete(String path, Class<T> responseType, Map<String, String> headers,
Consumer<ErrorResponse> errorHandler);

default <T extends RESTResponse> T get(String path, Class<T> responseType, Supplier<Map<String, String>> headers,
Consumer<ErrorResponse> errorHandler) {
return get(path, responseType, headers.get(), errorHandler);
}

<T extends RESTResponse> T get(String path, Class<T> responseType, Map<String, String> headers,
Consumer<ErrorResponse> errorHandler);

default <T extends RESTResponse> T post(String path, RESTRequest body, Class<T> responseType,
Supplier<Map<String, String>> headers, Consumer<ErrorResponse> errorHandler) {
return post(path, body, responseType, headers.get(), errorHandler);
}

<T extends RESTResponse> T post(String path, RESTRequest body, Class<T> responseType, Map<String, String> headers,
Consumer<ErrorResponse> errorHandler);

default <T extends RESTResponse> T postForm(String path, Map<String, String> formData, Class<T> responseType,
Supplier<Map<String, String>> headers,
Consumer<ErrorResponse> errorHandler) {
return postForm(path, formData, responseType, headers.get(), errorHandler);
}

<T extends RESTResponse> T postForm(String path, Map<String, String> formData, Class<T> responseType,
Map<String, String> headers, Consumer<ErrorResponse> errorHandler);
}

0 comments on commit a911623

Please sign in to comment.