Skip to content

Commit

Permalink
Core: Refactor REST catalog to RESTSessionCatalog (apache#4846)
Browse files Browse the repository at this point in the history
  • Loading branch information
rdblue authored May 23, 2022
1 parent c666c49 commit a911623
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
26 changes: 26 additions & 0 deletions core/src/main/java/org/apache/iceberg/rest/RESTClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading

0 comments on commit a911623

Please sign in to comment.