rdblue commented on code in PR #4495: URL: https://github.com/apache/iceberg/pull/4495#discussion_r842228671
########## core/src/main/java/org/apache/iceberg/rest/HTTPClientFactory.java: ########## @@ -0,0 +1,49 @@ +/* + * 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.iceberg.rest; + +import java.util.Map; +import org.apache.iceberg.CatalogProperties; +import org.apache.iceberg.relocated.com.google.common.base.Preconditions; + +/** + * Takes in the full configuration for the {@link RESTCatalog}, 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. + */ +public class HTTPClientFactory implements RESTClientFactory { + + @Override + public RESTClient apply(Map<String, String> properties) { + Preconditions.checkArgument(properties != null, "Invalid initial configuration: null"); + Preconditions.checkArgument(properties.containsKey(CatalogProperties.URI), "REST Catalog server URI is required"); + Preconditions.checkArgument(properties.containsKey(RESTCatalogProperties.AUTH_TOKEN), + "Invalid http client configuration. Missing authentication token"); + + String baseURI = properties.get(CatalogProperties.URI); + + return HTTPClient.builder() + .withBearerAuth(properties.get(RESTCatalogProperties.AUTH_TOKEN)) + .uri(baseURI) + .mapper(RESTObjectMapper.mapper()) Review Comment: Can you remove `mapper` from the client builder API? I don't think it is something that we need to expose and it leaks Jackson in the API. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
