You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/02/22 00:56:02 UTC

[GitHub] [iceberg] kbendick opened a new pull request #4184: CORE: REST Catalog - Response class for server provided configuration

kbendick opened a new pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184


   Defines the response class used to populate the server-provided configuration.
   
   Per the spec, the catalog client will call the `/v1/config` endpoint to retrieve a set of `overrides` and `defaults`. The `default` configurations are there to allow clients to not have to provide _all_ details, and the `overrides` are there so that the server can require a certain value be used.
   
   I've also started updating the REST catalog spec to be more detailed for this part (though I'll probably move that to another PR).


-- 
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-unsubscribe@iceberg.apache.org

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



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


[GitHub] [iceberg] rdblue commented on a change in pull request #4184: CORE: REST Catalog - Response class for server provided configuration

Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184#discussion_r813376625



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/RESTCatalogConfigResponse.java
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.responses;
+
+import java.util.Collections;
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+
+/**
+ * Represents a response to requesting server-side provided configuration for the REST catalog.
+ * This allows client provided values to be overridden by the server or defaulted if not provided by the client.
+ * <p>
+ * This configuration should be fetched with a one time initial HTTP request during the REST catalog initialization.
+ * The connection used to fetch the configuration should then be disposed and a new http client should be
+ * created for use with the catalog.
+ * <p>
+ * Configuration from the server consists of two sets of key/value pairs.
+ * <ul>
+ *   <li> defaults - properties that should be used as default configuration </li>
+ *   <li> overrides - properties that should be used to override client configuration </li>
+ * </ul>
+ */
+public class RESTCatalogConfigResponse {
+
+  private Map<String, String> defaults;
+  private Map<String, String> overrides;
+
+  public RESTCatalogConfigResponse() {
+    // Required for Jackson deserialization
+  }
+
+  private RESTCatalogConfigResponse(Map<String, String> defaults, Map<String, String> overrides) {
+    this.defaults = defaults;
+    this.overrides = overrides;
+    validate();
+  }
+
+  RESTCatalogConfigResponse validate() {
+    return this;
+  }
+
+  /**
+   * Properties that should be used as default configuration. {@code defaults} have the lowest priority
+   * and should be applied before the client provided configuration.
+   *
+   * @return properties that should be used as default configuration
+   */
+  public Map<String, String> defaults() {
+    return defaults != null ? Maps.newHashMap(defaults) : Collections.emptyMap();

Review comment:
       Why not use `ImmutableMap.of()` here like in the other places? Similarly, why not just return the defaults without copying?




-- 
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-unsubscribe@iceberg.apache.org

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



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


[GitHub] [iceberg] kbendick commented on a change in pull request #4184: CORE: REST Catalog - Response class for server provided configuration

Posted by GitBox <gi...@apache.org>.
kbendick commented on a change in pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184#discussion_r814258433



##########
File path: core/src/test/java/org/apache/iceberg/rest/responses/TESTRESTCatalogConfigResponse.java
##########
@@ -0,0 +1,247 @@
+/*
+ * 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.responses;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import java.util.Map;
+import org.apache.iceberg.AssertHelpers;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+import org.apache.iceberg.rest.RequestResponseTestBase;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class TESTRESTCatalogConfigResponse extends RequestResponseTestBase<RESTCatalogConfigResponse> {

Review comment:
       Renamed.




-- 
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-unsubscribe@iceberg.apache.org

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



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


[GitHub] [iceberg] rdblue commented on a change in pull request #4184: CORE: REST Catalog - Response class for server provided configuration

Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184#discussion_r814267733



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/RESTCatalogConfigResponse.java
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.responses;
+
+import java.util.Collections;
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+
+/**
+ * Represents a response to requesting server-side provided configuration for the REST catalog.
+ * This allows client provided values to be overridden by the server or defaulted if not provided by the client.
+ * <p>
+ * This configuration should be fetched with a one time initial HTTP request during the REST catalog initialization.
+ * The connection used to fetch the configuration should then be disposed and a new http client should be
+ * created for use with the catalog.
+ * <p>
+ * Configuration from the server consists of two sets of key/value pairs.
+ * <ul>
+ *   <li> defaults - properties that should be used as default configuration </li>
+ *   <li> overrides - properties that should be used to override client configuration </li>
+ * </ul>
+ */
+public class RESTCatalogConfigResponse {
+
+  private Map<String, String> defaults;
+  private Map<String, String> overrides;
+
+  public RESTCatalogConfigResponse() {
+    // Required for Jackson deserialization
+  }
+
+  private RESTCatalogConfigResponse(Map<String, String> defaults, Map<String, String> overrides) {
+    this.defaults = defaults;
+    this.overrides = overrides;
+    validate();
+  }
+
+  RESTCatalogConfigResponse validate() {
+    return this;
+  }
+
+  /**
+   * Properties that should be used as default configuration. {@code defaults} have the lowest priority
+   * and should be applied before the client provided configuration.
+   *
+   * @return properties that should be used as default configuration
+   */
+  public Map<String, String> defaults() {
+    return defaults != null ? Maps.newHashMap(defaults) : Collections.emptyMap();
+  }
+
+  /**
+   * Properties that should be used to override client configuration. {@code overrides} have the highest priority
+   * and should be applied after defaults and any client-provided configuration properties.
+   *
+   * @return properties that should be given higher precedence than any client provided input
+   */
+  public Map<String, String> overrides() {
+    return overrides != null ? Maps.newHashMap(overrides) : Collections.emptyMap();
+  }
+
+  /**
+   * Merge client-provided config with server side provided configuration to return a single
+   * properties map which will be used for instantiating and configuring the REST catalog.
+   *
+   * @param clientProperties - Client provided configuration
+   * @return Merged configuration, with precedence in the order overrides, then client properties, and then defaults.
+   */
+  public Map<String, String> merge(Map<String, String> clientProperties) {
+    Preconditions.checkNotNull(clientProperties,
+        "Cannot merge client properties with server-provided properties. Invalid client configuration: null");
+    Map<String, String> merged = Maps.newHashMap(defaults);
+    merged.putAll(clientProperties);
+    merged.putAll(overrides);
+    return merged;
+  }
+
+  @Override
+  public String toString() {
+    return MoreObjects.toStringHelper(this)
+        .add("defaults", defaults)
+        .add("overrides", overrides)
+        .toString();
+  }
+
+  public static Builder builder() {
+    return new Builder();
+  }
+
+  public static class Builder {
+    private final Map<String, String> defaults;
+    private final Map<String, String> overrides;
+
+    private Builder() {
+      this.defaults = Maps.newHashMap();
+      this.overrides = Maps.newHashMap();

Review comment:
       Oh, very good point. +1 for keeping it `HashMap` here.




-- 
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-unsubscribe@iceberg.apache.org

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



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


[GitHub] [iceberg] rdblue commented on a change in pull request #4184: CORE: REST Catalog - Response class for server provided configuration

Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184#discussion_r813380418



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/RESTCatalogConfigResponse.java
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.responses;
+
+import java.util.Collections;
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+
+/**
+ * Represents a response to requesting server-side provided configuration for the REST catalog.
+ * This allows client provided values to be overridden by the server or defaulted if not provided by the client.
+ * <p>
+ * This configuration should be fetched with a one time initial HTTP request during the REST catalog initialization.
+ * The connection used to fetch the configuration should then be disposed and a new http client should be
+ * created for use with the catalog.
+ * <p>
+ * Configuration from the server consists of two sets of key/value pairs.
+ * <ul>
+ *   <li> defaults - properties that should be used as default configuration </li>
+ *   <li> overrides - properties that should be used to override client configuration </li>
+ * </ul>
+ */
+public class RESTCatalogConfigResponse {
+
+  private Map<String, String> defaults;
+  private Map<String, String> overrides;
+
+  public RESTCatalogConfigResponse() {
+    // Required for Jackson deserialization
+  }
+
+  private RESTCatalogConfigResponse(Map<String, String> defaults, Map<String, String> overrides) {
+    this.defaults = defaults;
+    this.overrides = overrides;
+    validate();
+  }
+
+  RESTCatalogConfigResponse validate() {
+    return this;
+  }
+
+  /**
+   * Properties that should be used as default configuration. {@code defaults} have the lowest priority
+   * and should be applied before the client provided configuration.
+   *
+   * @return properties that should be used as default configuration
+   */
+  public Map<String, String> defaults() {
+    return defaults != null ? Maps.newHashMap(defaults) : Collections.emptyMap();
+  }
+
+  /**
+   * Properties that should be used to override client configuration. {@code overrides} have the highest priority
+   * and should be applied after defaults and any client-provided configuration properties.
+   *
+   * @return properties that should be given higher precedence than any client provided input
+   */
+  public Map<String, String> overrides() {
+    return overrides != null ? Maps.newHashMap(overrides) : Collections.emptyMap();
+  }
+
+  /**
+   * Merge client-provided config with server side provided configuration to return a single
+   * properties map which will be used for instantiating and configuring the REST catalog.
+   *
+   * @param clientProperties - Client provided configuration
+   * @return Merged configuration, with precedence in the order overrides, then client properties, and then defaults.
+   */
+  public Map<String, String> merge(Map<String, String> clientProperties) {
+    Preconditions.checkNotNull(clientProperties,
+        "Cannot merge client properties with server-provided properties. Invalid client configuration: null");
+    Map<String, String> merged = Maps.newHashMap(defaults);
+    merged.putAll(clientProperties);
+    merged.putAll(overrides);
+    return merged;
+  }
+
+  @Override
+  public String toString() {
+    return MoreObjects.toStringHelper(this)
+        .add("defaults", defaults)
+        .add("overrides", overrides)
+        .toString();
+  }
+
+  public static Builder builder() {
+    return new Builder();
+  }
+
+  public static class Builder {
+    private final Map<String, String> defaults;
+    private final Map<String, String> overrides;
+
+    private Builder() {
+      this.defaults = Maps.newHashMap();
+      this.overrides = Maps.newHashMap();
+    }
+
+    public Builder withDefault(String key, String value) {
+      Preconditions.checkNotNull(key, "Invalid config: null");
+      defaults.put(key, value);
+      return this;
+    }
+
+    public Builder withOverride(String key, String value) {
+      Preconditions.checkNotNull(key, "Invalid config: null");
+      overrides.put(key, value);
+      return this;
+    }
+
+    /**
+     * Adds the passed in map entries to the existing `defaults` of this Builder.
+     */
+    public Builder withDefaults(Map<String, String> defaultsToAdd) {
+      Preconditions.checkNotNull(defaultsToAdd, "Invalid configuration properties map: null");
+      Preconditions.checkArgument(!defaultsToAdd.containsKey(null), "Invalid config: null");
+      defaults.putAll(defaultsToAdd);
+      return this;
+    }
+
+    /**
+     * Adds the passed in map entires to the existing `overrides` of this Builder.
+     */
+    public Builder withOverrides(Map<String, String> overridesToAdd) {
+      Preconditions.checkNotNull(overridesToAdd, "Invalid configuration properties map: null");
+      Preconditions.checkArgument(!overridesToAdd.containsKey(null), "Invalid config: null");

Review comment:
       Minor: You may want to use "override" or "property" instead of just "config".




-- 
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-unsubscribe@iceberg.apache.org

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



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


[GitHub] [iceberg] kbendick commented on a change in pull request #4184: CORE: REST Catalog - Response class for server provided configuration

Posted by GitBox <gi...@apache.org>.
kbendick commented on a change in pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184#discussion_r814254368



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/RESTCatalogConfigResponse.java
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.responses;
+
+import java.util.Collections;
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+
+/**
+ * Represents a response to requesting server-side provided configuration for the REST catalog.
+ * This allows client provided values to be overridden by the server or defaulted if not provided by the client.
+ * <p>
+ * This configuration should be fetched with a one time initial HTTP request during the REST catalog initialization.
+ * The connection used to fetch the configuration should then be disposed and a new http client should be
+ * created for use with the catalog.
+ * <p>
+ * Configuration from the server consists of two sets of key/value pairs.
+ * <ul>
+ *   <li> defaults - properties that should be used as default configuration </li>
+ *   <li> overrides - properties that should be used to override client configuration </li>
+ * </ul>
+ */
+public class RESTCatalogConfigResponse {
+
+  private Map<String, String> defaults;
+  private Map<String, String> overrides;
+
+  public RESTCatalogConfigResponse() {
+    // Required for Jackson deserialization
+  }
+
+  private RESTCatalogConfigResponse(Map<String, String> defaults, Map<String, String> overrides) {
+    this.defaults = defaults;
+    this.overrides = overrides;
+    validate();
+  }
+
+  RESTCatalogConfigResponse validate() {
+    return this;
+  }
+
+  /**
+   * Properties that should be used as default configuration. {@code defaults} have the lowest priority
+   * and should be applied before the client provided configuration.
+   *
+   * @return properties that should be used as default configuration
+   */
+  public Map<String, String> defaults() {
+    return defaults != null ? Maps.newHashMap(defaults) : Collections.emptyMap();

Review comment:
       I can do that. I avoided `ImmutableMap` as it doesn't allow for `null` values, but since it's an empty one it doesn't really matter. Will udpdate.




-- 
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-unsubscribe@iceberg.apache.org

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



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


[GitHub] [iceberg] rdblue merged pull request #4184: CORE: REST Catalog - Response class for server provided configuration

Posted by GitBox <gi...@apache.org>.
rdblue merged pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184


   


-- 
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-unsubscribe@iceberg.apache.org

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



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


[GitHub] [iceberg] kbendick commented on a change in pull request #4184: CORE: REST Catalog - Response class for server provided configuration

Posted by GitBox <gi...@apache.org>.
kbendick commented on a change in pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184#discussion_r811521576



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/RESTCatalogConfigResponse.java
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.responses;
+
+import java.util.Collections;
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+
+/**
+ * Represents a response to requesting server-side provided configuration for the REST catalog.
+ * This allows client provided values to be overridden by the server or defaulted if not provided by the client.
+ * <p>
+ * This configuration should be fetched with a one time initial HTTP request during the REST catalog initialization.
+ * The connection used to fetch the configuration should then be disposed and a new http client should be
+ * created for use with the catalog.
+ * <p>
+ * Configuration from the server consists of two sets of key/value pairs.
+ * <ul>
+ *   <li> defaults - properties that should be used as default configuration </li>
+ *   <li> overrides - properties that should be used to override client configuration </li>
+ * </ul>
+ */
+public class RESTCatalogConfigResponse {
+
+  private Map<String, String> defaults;
+  private Map<String, String> overrides;
+
+  public RESTCatalogConfigResponse() {
+    // Required for Jackson deserialization
+  }
+
+  private RESTCatalogConfigResponse(Map<String, String> defaults, Map<String, String> overrides) {
+    this.defaults = defaults;
+    this.overrides = overrides;
+    validate();
+  }
+
+  RESTCatalogConfigResponse validate() {
+    return this;
+  }
+
+  /**
+   * Properties that should be used as default configuration. {@code defaults} have the lowest priority
+   * and should be applied before the client provided configuration.
+   *
+   * @return properties that should be used as default configuration
+   */
+  public Map<String, String> defaults() {
+    return defaults != null ? Maps.newHashMap(defaults) : Collections.emptyMap();
+  }

Review comment:
       Make a defensive copy, as the `defaults` are merged with `overrides` and we don't want anybody mutating them incorrectly in the process.




-- 
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-unsubscribe@iceberg.apache.org

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



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


[GitHub] [iceberg] rdblue commented on a change in pull request #4184: CORE: REST Catalog - Response class for server provided configuration

Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184#discussion_r814258285



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/RESTCatalogConfigResponse.java
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.responses;
+
+import java.util.Collections;
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+
+/**
+ * Represents a response to requesting server-side provided configuration for the REST catalog.
+ * This allows client provided values to be overridden by the server or defaulted if not provided by the client.
+ * <p>
+ * This configuration should be fetched with a one time initial HTTP request during the REST catalog initialization.
+ * The connection used to fetch the configuration should then be disposed and a new http client should be
+ * created for use with the catalog.
+ * <p>
+ * Configuration from the server consists of two sets of key/value pairs.
+ * <ul>
+ *   <li> defaults - properties that should be used as default configuration </li>
+ *   <li> overrides - properties that should be used to override client configuration </li>
+ * </ul>
+ */
+public class RESTCatalogConfigResponse {
+
+  private Map<String, String> defaults;
+  private Map<String, String> overrides;
+
+  public RESTCatalogConfigResponse() {
+    // Required for Jackson deserialization
+  }
+
+  private RESTCatalogConfigResponse(Map<String, String> defaults, Map<String, String> overrides) {
+    this.defaults = defaults;
+    this.overrides = overrides;
+    validate();
+  }
+
+  RESTCatalogConfigResponse validate() {
+    return this;
+  }
+
+  /**
+   * Properties that should be used as default configuration. {@code defaults} have the lowest priority
+   * and should be applied before the client provided configuration.
+   *
+   * @return properties that should be used as default configuration
+   */
+  public Map<String, String> defaults() {
+    return defaults != null ? Maps.newHashMap(defaults) : Collections.emptyMap();
+  }
+
+  /**
+   * Properties that should be used to override client configuration. {@code overrides} have the highest priority
+   * and should be applied after defaults and any client-provided configuration properties.
+   *
+   * @return properties that should be given higher precedence than any client provided input
+   */
+  public Map<String, String> overrides() {
+    return overrides != null ? Maps.newHashMap(overrides) : Collections.emptyMap();
+  }
+
+  /**
+   * Merge client-provided config with server side provided configuration to return a single
+   * properties map which will be used for instantiating and configuring the REST catalog.
+   *
+   * @param clientProperties - Client provided configuration
+   * @return Merged configuration, with precedence in the order overrides > client properties > defaults.
+   */
+  public Map<String, String> merge(Map<String, String> clientProperties) {
+    Preconditions.checkNotNull(clientProperties,
+        "Cannot merge client properties with server-provided properties. Invalid client configuration: null");
+    Map<String, String> merged = Maps.newHashMap(defaults);
+    merged.putAll(clientProperties);
+    merged.putAll(overrides);
+    return merged;
+  }

Review comment:
       I'm fine with it here for now. We can move it later if we think it doesn't fit.




-- 
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-unsubscribe@iceberg.apache.org

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



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


[GitHub] [iceberg] kbendick commented on a change in pull request #4184: CORE: REST Catalog - Response class for server provided configuration

Posted by GitBox <gi...@apache.org>.
kbendick commented on a change in pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184#discussion_r814253429



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/RESTCatalogConfigResponse.java
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.responses;
+
+import java.util.Collections;
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+
+/**
+ * Represents a response to requesting server-side provided configuration for the REST catalog.
+ * This allows client provided values to be overridden by the server or defaulted if not provided by the client.
+ * <p>
+ * This configuration should be fetched with a one time initial HTTP request during the REST catalog initialization.
+ * The connection used to fetch the configuration should then be disposed and a new http client should be
+ * created for use with the catalog.

Review comment:
       Ok. That makes sense.




-- 
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-unsubscribe@iceberg.apache.org

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



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


[GitHub] [iceberg] kbendick commented on a change in pull request #4184: CORE: REST Catalog - Response class for server provided configuration

Posted by GitBox <gi...@apache.org>.
kbendick commented on a change in pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184#discussion_r814267797



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/RESTCatalogConfigResponse.java
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.responses;
+
+import java.util.Collections;
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+
+/**
+ * Represents a response to requesting server-side provided configuration for the REST catalog.
+ * This allows client provided values to be overridden by the server or defaulted if not provided by the client.
+ * <p>
+ * This configuration should be fetched with a one time initial HTTP request during the REST catalog initialization.
+ * The connection used to fetch the configuration should then be disposed and a new http client should be
+ * created for use with the catalog.

Review comment:
       Updated.




-- 
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-unsubscribe@iceberg.apache.org

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



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


[GitHub] [iceberg] kbendick commented on a change in pull request #4184: CORE: REST Catalog - Response class for server provided configuration

Posted by GitBox <gi...@apache.org>.
kbendick commented on a change in pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184#discussion_r814283525



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/RESTCatalogConfigResponse.java
##########
@@ -0,0 +1,153 @@
+/*
+ * 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.responses;
+
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+
+/**
+ * Represents a response to requesting server-side provided configuration for the REST catalog.
+ * This allows client provided values to be overridden by the server or defaulted if not provided by the client.
+ * <p>
+ * The catalog properties, with overrides and defaults applied, should be used to configure the catalog and for all
+ * subsequent requests after this initial config request.
+ * <p>
+ * Configuration from the server consists of two sets of key/value pairs.
+ * <ul>
+ *   <li> defaults - properties that should be used as default configuration </li>
+ *   <li> overrides - properties that should be used to override client configuration </li>
+ * </ul>
+ */
+public class RESTCatalogConfigResponse {
+
+  private Map<String, String> defaults;
+  private Map<String, String> overrides;
+
+  public RESTCatalogConfigResponse() {
+    // Required for Jackson deserialization
+  }
+
+  private RESTCatalogConfigResponse(Map<String, String> defaults, Map<String, String> overrides) {
+    this.defaults = defaults;
+    this.overrides = overrides;
+    validate();
+  }
+
+  RESTCatalogConfigResponse validate() {
+    return this;
+  }
+
+  /**
+   * Properties that should be used as default configuration. {@code defaults} have the lowest priority
+   * and should be applied before the client provided configuration.
+   *
+   * @return properties that should be used as default configuration
+   */
+  public Map<String, String> defaults() {
+    return defaults != null ? defaults : ImmutableMap.of();
+  }
+
+  /**
+   * Properties that should be used to override client configuration. {@code overrides} have the highest priority
+   * and should be applied after defaults and any client-provided configuration properties.
+   *
+   * @return properties that should be given higher precedence than any client provided input
+   */
+  public Map<String, String> overrides() {
+    return overrides != null ? overrides : ImmutableMap.of();
+  }
+
+  /**
+   * Merge client-provided config with server side provided configuration to return a single
+   * properties map which will be used for instantiating and configuring the REST catalog.
+   *
+   * @param clientProperties - Client provided configuration
+   * @return Merged configuration, with precedence in the order overrides, then client properties, and then defaults.
+   */
+  public Map<String, String> merge(Map<String, String> clientProperties) {
+    Preconditions.checkNotNull(clientProperties,
+        "Cannot merge client properties with server-provided properties. Invalid client configuration: null");
+    Map<String, String> merged = Maps.newHashMap(defaults);
+    merged.putAll(clientProperties);
+    merged.putAll(overrides);
+    return merged;

Review comment:
       That's not a bad idea. I'll add that.




-- 
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-unsubscribe@iceberg.apache.org

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



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


[GitHub] [iceberg] kbendick commented on a change in pull request #4184: CORE: REST Catalog - Response class for server provided configuration

Posted by GitBox <gi...@apache.org>.
kbendick commented on a change in pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184#discussion_r811521702



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/RESTCatalogConfigResponse.java
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.responses;
+
+import java.util.Collections;
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+
+/**
+ * Represents a response to requesting server-side provided configuration for the REST catalog.
+ * This allows client provided values to be overridden by the server or defaulted if not provided by the client.
+ * <p>
+ * This configuration should be fetched with a one time initial HTTP request during the REST catalog initialization.
+ * The connection used to fetch the configuration should then be disposed and a new http client should be
+ * created for use with the catalog.
+ * <p>
+ * Configuration from the server consists of two sets of key/value pairs.
+ * <ul>
+ *   <li> defaults - properties that should be used as default configuration </li>
+ *   <li> overrides - properties that should be used to override client configuration </li>
+ * </ul>
+ */
+public class RESTCatalogConfigResponse {
+
+  private Map<String, String> defaults;
+  private Map<String, String> overrides;
+
+  public RESTCatalogConfigResponse() {
+    // Required for Jackson deserialization
+  }
+
+  private RESTCatalogConfigResponse(Map<String, String> defaults, Map<String, String> overrides) {
+    this.defaults = defaults;
+    this.overrides = overrides;
+    validate();
+  }
+
+  RESTCatalogConfigResponse validate() {
+    return this;
+  }
+
+  /**
+   * Properties that should be used as default configuration. {@code defaults} have the lowest priority
+   * and should be applied before the client provided configuration.
+   *
+   * @return properties that should be used as default configuration
+   */
+  public Map<String, String> defaults() {
+    return defaults != null ? Maps.newHashMap(defaults) : Collections.emptyMap();
+  }
+
+  /**
+   * Properties that should be used to override client configuration. {@code overrides} have the highest priority
+   * and should be applied after defaults and any client-provided configuration properties.
+   *
+   * @return properties that should be given higher precedence than any client provided input
+   */
+  public Map<String, String> overrides() {
+    return overrides != null ? Maps.newHashMap(overrides) : Collections.emptyMap();
+  }
+
+  /**
+   * Merge client-provided config with server side provided configuration to return a single
+   * properties map which will be used for instantiating and configuring the REST catalog.
+   *
+   * @param clientProperties - Client provided configuration
+   * @return Merged configuration, with precedence in the order overrides > client properties > defaults.
+   */
+  public Map<String, String> merge(Map<String, String> clientProperties) {
+    Preconditions.checkNotNull(clientProperties,
+        "Cannot merge client properties with server-provided properties. Invalid client configuration: null");
+    Map<String, String> merged = Maps.newHashMap(defaults);
+    merged.putAll(clientProperties);
+    merged.putAll(overrides);
+    return merged;
+  }

Review comment:
       This function might be better placed outside of the response object. I haven't written any tests yet, in case we want to move it to some other utility class or elsewhere (as the request / response object should arguably be data classes).




-- 
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-unsubscribe@iceberg.apache.org

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



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


[GitHub] [iceberg] kbendick commented on a change in pull request #4184: CORE: REST Catalog - Response class for server provided configuration

Posted by GitBox <gi...@apache.org>.
kbendick commented on a change in pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184#discussion_r811521576



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/RESTCatalogConfigResponse.java
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.responses;
+
+import java.util.Collections;
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+
+/**
+ * Represents a response to requesting server-side provided configuration for the REST catalog.
+ * This allows client provided values to be overridden by the server or defaulted if not provided by the client.
+ * <p>
+ * This configuration should be fetched with a one time initial HTTP request during the REST catalog initialization.
+ * The connection used to fetch the configuration should then be disposed and a new http client should be
+ * created for use with the catalog.
+ * <p>
+ * Configuration from the server consists of two sets of key/value pairs.
+ * <ul>
+ *   <li> defaults - properties that should be used as default configuration </li>
+ *   <li> overrides - properties that should be used to override client configuration </li>
+ * </ul>
+ */
+public class RESTCatalogConfigResponse {
+
+  private Map<String, String> defaults;
+  private Map<String, String> overrides;
+
+  public RESTCatalogConfigResponse() {
+    // Required for Jackson deserialization
+  }
+
+  private RESTCatalogConfigResponse(Map<String, String> defaults, Map<String, String> overrides) {
+    this.defaults = defaults;
+    this.overrides = overrides;
+    validate();
+  }
+
+  RESTCatalogConfigResponse validate() {
+    return this;
+  }
+
+  /**
+   * Properties that should be used as default configuration. {@code defaults} have the lowest priority
+   * and should be applied before the client provided configuration.
+   *
+   * @return properties that should be used as default configuration
+   */
+  public Map<String, String> defaults() {
+    return defaults != null ? Maps.newHashMap(defaults) : Collections.emptyMap();
+  }

Review comment:
       Make a defensive copy, as the `defaults` are merged with `overrides` and we don't want anybody mutating them incorrectly in the process.




-- 
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-unsubscribe@iceberg.apache.org

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



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


[GitHub] [iceberg] rdblue commented on a change in pull request #4184: CORE: REST Catalog - Response class for server provided configuration

Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184#discussion_r813376625



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/RESTCatalogConfigResponse.java
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.responses;
+
+import java.util.Collections;
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+
+/**
+ * Represents a response to requesting server-side provided configuration for the REST catalog.
+ * This allows client provided values to be overridden by the server or defaulted if not provided by the client.
+ * <p>
+ * This configuration should be fetched with a one time initial HTTP request during the REST catalog initialization.
+ * The connection used to fetch the configuration should then be disposed and a new http client should be
+ * created for use with the catalog.
+ * <p>
+ * Configuration from the server consists of two sets of key/value pairs.
+ * <ul>
+ *   <li> defaults - properties that should be used as default configuration </li>
+ *   <li> overrides - properties that should be used to override client configuration </li>
+ * </ul>
+ */
+public class RESTCatalogConfigResponse {
+
+  private Map<String, String> defaults;
+  private Map<String, String> overrides;
+
+  public RESTCatalogConfigResponse() {
+    // Required for Jackson deserialization
+  }
+
+  private RESTCatalogConfigResponse(Map<String, String> defaults, Map<String, String> overrides) {
+    this.defaults = defaults;
+    this.overrides = overrides;
+    validate();
+  }
+
+  RESTCatalogConfigResponse validate() {
+    return this;
+  }
+
+  /**
+   * Properties that should be used as default configuration. {@code defaults} have the lowest priority
+   * and should be applied before the client provided configuration.
+   *
+   * @return properties that should be used as default configuration
+   */
+  public Map<String, String> defaults() {
+    return defaults != null ? Maps.newHashMap(defaults) : Collections.emptyMap();

Review comment:
       Why not use `ImmutableMap.of()` here like in the other places?




-- 
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-unsubscribe@iceberg.apache.org

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



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


[GitHub] [iceberg] rdblue commented on a change in pull request #4184: CORE: REST Catalog - Response class for server provided configuration

Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184#discussion_r813376260



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/RESTCatalogConfigResponse.java
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.responses;
+
+import java.util.Collections;
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+
+/**
+ * Represents a response to requesting server-side provided configuration for the REST catalog.
+ * This allows client provided values to be overridden by the server or defaulted if not provided by the client.
+ * <p>
+ * This configuration should be fetched with a one time initial HTTP request during the REST catalog initialization.
+ * The connection used to fetch the configuration should then be disposed and a new http client should be
+ * created for use with the catalog.

Review comment:
       It may be easier to state the slightly less strict version, which is that the defaults and overrides should be used to configure the catalog and for all subsequent HTTP requests after the initial config request.




-- 
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-unsubscribe@iceberg.apache.org

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



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


[GitHub] [iceberg] kbendick commented on a change in pull request #4184: CORE: REST Catalog - Response class for server provided configuration

Posted by GitBox <gi...@apache.org>.
kbendick commented on a change in pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184#discussion_r814310892



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/RESTCatalogConfigResponse.java
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.responses;
+
+import java.util.Collections;
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+
+/**
+ * Represents a response to requesting server-side provided configuration for the REST catalog.
+ * This allows client provided values to be overridden by the server or defaulted if not provided by the client.
+ * <p>
+ * This configuration should be fetched with a one time initial HTTP request during the REST catalog initialization.
+ * The connection used to fetch the configuration should then be disposed and a new http client should be
+ * created for use with the catalog.
+ * <p>
+ * Configuration from the server consists of two sets of key/value pairs.
+ * <ul>
+ *   <li> defaults - properties that should be used as default configuration </li>
+ *   <li> overrides - properties that should be used to override client configuration </li>
+ * </ul>
+ */
+public class RESTCatalogConfigResponse {
+
+  private Map<String, String> defaults;
+  private Map<String, String> overrides;
+
+  public RESTCatalogConfigResponse() {
+    // Required for Jackson deserialization
+  }
+
+  private RESTCatalogConfigResponse(Map<String, String> defaults, Map<String, String> overrides) {
+    this.defaults = defaults;
+    this.overrides = overrides;
+    validate();
+  }
+
+  RESTCatalogConfigResponse validate() {
+    return this;
+  }
+
+  /**
+   * Properties that should be used as default configuration. {@code defaults} have the lowest priority
+   * and should be applied before the client provided configuration.
+   *
+   * @return properties that should be used as default configuration
+   */
+  public Map<String, String> defaults() {
+    return defaults != null ? Maps.newHashMap(defaults) : Collections.emptyMap();
+  }
+
+  /**
+   * Properties that should be used to override client configuration. {@code overrides} have the highest priority
+   * and should be applied after defaults and any client-provided configuration properties.
+   *
+   * @return properties that should be given higher precedence than any client provided input
+   */
+  public Map<String, String> overrides() {
+    return overrides != null ? Maps.newHashMap(overrides) : Collections.emptyMap();
+  }
+
+  /**
+   * Merge client-provided config with server side provided configuration to return a single
+   * properties map which will be used for instantiating and configuring the REST catalog.
+   *
+   * @param clientProperties - Client provided configuration
+   * @return Merged configuration, with precedence in the order overrides > client properties > defaults.
+   */
+  public Map<String, String> merge(Map<String, String> clientProperties) {
+    Preconditions.checkNotNull(clientProperties,
+        "Cannot merge client properties with server-provided properties. Invalid client configuration: null");
+    Map<String, String> merged = Maps.newHashMap(defaults);
+    merged.putAll(clientProperties);
+    merged.putAll(overrides);
+    return merged;
+  }

Review comment:
       Ok. That makes sense for me. This will at least unblock others from working in parallel on this.




-- 
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-unsubscribe@iceberg.apache.org

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



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


[GitHub] [iceberg] kbendick commented on a change in pull request #4184: CORE: REST Catalog - Response class for server provided configuration

Posted by GitBox <gi...@apache.org>.
kbendick commented on a change in pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184#discussion_r811521702



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/RESTCatalogConfigResponse.java
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.responses;
+
+import java.util.Collections;
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+
+/**
+ * Represents a response to requesting server-side provided configuration for the REST catalog.
+ * This allows client provided values to be overridden by the server or defaulted if not provided by the client.
+ * <p>
+ * This configuration should be fetched with a one time initial HTTP request during the REST catalog initialization.
+ * The connection used to fetch the configuration should then be disposed and a new http client should be
+ * created for use with the catalog.
+ * <p>
+ * Configuration from the server consists of two sets of key/value pairs.
+ * <ul>
+ *   <li> defaults - properties that should be used as default configuration </li>
+ *   <li> overrides - properties that should be used to override client configuration </li>
+ * </ul>
+ */
+public class RESTCatalogConfigResponse {
+
+  private Map<String, String> defaults;
+  private Map<String, String> overrides;
+
+  public RESTCatalogConfigResponse() {
+    // Required for Jackson deserialization
+  }
+
+  private RESTCatalogConfigResponse(Map<String, String> defaults, Map<String, String> overrides) {
+    this.defaults = defaults;
+    this.overrides = overrides;
+    validate();
+  }
+
+  RESTCatalogConfigResponse validate() {
+    return this;
+  }
+
+  /**
+   * Properties that should be used as default configuration. {@code defaults} have the lowest priority
+   * and should be applied before the client provided configuration.
+   *
+   * @return properties that should be used as default configuration
+   */
+  public Map<String, String> defaults() {
+    return defaults != null ? Maps.newHashMap(defaults) : Collections.emptyMap();
+  }
+
+  /**
+   * Properties that should be used to override client configuration. {@code overrides} have the highest priority
+   * and should be applied after defaults and any client-provided configuration properties.
+   *
+   * @return properties that should be given higher precedence than any client provided input
+   */
+  public Map<String, String> overrides() {
+    return overrides != null ? Maps.newHashMap(overrides) : Collections.emptyMap();
+  }
+
+  /**
+   * Merge client-provided config with server side provided configuration to return a single
+   * properties map which will be used for instantiating and configuring the REST catalog.
+   *
+   * @param clientProperties - Client provided configuration
+   * @return Merged configuration, with precedence in the order overrides > client properties > defaults.
+   */
+  public Map<String, String> merge(Map<String, String> clientProperties) {
+    Preconditions.checkNotNull(clientProperties,
+        "Cannot merge client properties with server-provided properties. Invalid client configuration: null");
+    Map<String, String> merged = Maps.newHashMap(defaults);
+    merged.putAll(clientProperties);
+    merged.putAll(overrides);
+    return merged;
+  }

Review comment:
       This function might be better placed outside of the response object.




-- 
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-unsubscribe@iceberg.apache.org

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



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


[GitHub] [iceberg] rdblue commented on a change in pull request #4184: CORE: REST Catalog - Response class for server provided configuration

Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184#discussion_r813380621



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/RESTCatalogConfigResponse.java
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.responses;
+
+import java.util.Collections;
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+
+/**
+ * Represents a response to requesting server-side provided configuration for the REST catalog.
+ * This allows client provided values to be overridden by the server or defaulted if not provided by the client.
+ * <p>
+ * This configuration should be fetched with a one time initial HTTP request during the REST catalog initialization.
+ * The connection used to fetch the configuration should then be disposed and a new http client should be
+ * created for use with the catalog.
+ * <p>
+ * Configuration from the server consists of two sets of key/value pairs.
+ * <ul>
+ *   <li> defaults - properties that should be used as default configuration </li>
+ *   <li> overrides - properties that should be used to override client configuration </li>
+ * </ul>
+ */
+public class RESTCatalogConfigResponse {
+
+  private Map<String, String> defaults;
+  private Map<String, String> overrides;
+
+  public RESTCatalogConfigResponse() {
+    // Required for Jackson deserialization
+  }
+
+  private RESTCatalogConfigResponse(Map<String, String> defaults, Map<String, String> overrides) {
+    this.defaults = defaults;
+    this.overrides = overrides;
+    validate();
+  }
+
+  RESTCatalogConfigResponse validate() {
+    return this;
+  }
+
+  /**
+   * Properties that should be used as default configuration. {@code defaults} have the lowest priority
+   * and should be applied before the client provided configuration.
+   *
+   * @return properties that should be used as default configuration
+   */
+  public Map<String, String> defaults() {
+    return defaults != null ? Maps.newHashMap(defaults) : Collections.emptyMap();
+  }
+
+  /**
+   * Properties that should be used to override client configuration. {@code overrides} have the highest priority
+   * and should be applied after defaults and any client-provided configuration properties.
+   *
+   * @return properties that should be given higher precedence than any client provided input
+   */
+  public Map<String, String> overrides() {
+    return overrides != null ? Maps.newHashMap(overrides) : Collections.emptyMap();
+  }
+
+  /**
+   * Merge client-provided config with server side provided configuration to return a single
+   * properties map which will be used for instantiating and configuring the REST catalog.
+   *
+   * @param clientProperties - Client provided configuration
+   * @return Merged configuration, with precedence in the order overrides, then client properties, and then defaults.
+   */
+  public Map<String, String> merge(Map<String, String> clientProperties) {
+    Preconditions.checkNotNull(clientProperties,
+        "Cannot merge client properties with server-provided properties. Invalid client configuration: null");
+    Map<String, String> merged = Maps.newHashMap(defaults);
+    merged.putAll(clientProperties);
+    merged.putAll(overrides);
+    return merged;
+  }
+
+  @Override
+  public String toString() {
+    return MoreObjects.toStringHelper(this)
+        .add("defaults", defaults)
+        .add("overrides", overrides)
+        .toString();
+  }
+
+  public static Builder builder() {
+    return new Builder();
+  }
+
+  public static class Builder {
+    private final Map<String, String> defaults;
+    private final Map<String, String> overrides;
+
+    private Builder() {
+      this.defaults = Maps.newHashMap();
+      this.overrides = Maps.newHashMap();

Review comment:
       You could use immutable builders like the other classes.




-- 
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-unsubscribe@iceberg.apache.org

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



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


[GitHub] [iceberg] kbendick commented on a change in pull request #4184: CORE: REST Catalog - Response class for server provided configuration

Posted by GitBox <gi...@apache.org>.
kbendick commented on a change in pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184#discussion_r811521702



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/RESTCatalogConfigResponse.java
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.responses;
+
+import java.util.Collections;
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+
+/**
+ * Represents a response to requesting server-side provided configuration for the REST catalog.
+ * This allows client provided values to be overridden by the server or defaulted if not provided by the client.
+ * <p>
+ * This configuration should be fetched with a one time initial HTTP request during the REST catalog initialization.
+ * The connection used to fetch the configuration should then be disposed and a new http client should be
+ * created for use with the catalog.
+ * <p>
+ * Configuration from the server consists of two sets of key/value pairs.
+ * <ul>
+ *   <li> defaults - properties that should be used as default configuration </li>
+ *   <li> overrides - properties that should be used to override client configuration </li>
+ * </ul>
+ */
+public class RESTCatalogConfigResponse {
+
+  private Map<String, String> defaults;
+  private Map<String, String> overrides;
+
+  public RESTCatalogConfigResponse() {
+    // Required for Jackson deserialization
+  }
+
+  private RESTCatalogConfigResponse(Map<String, String> defaults, Map<String, String> overrides) {
+    this.defaults = defaults;
+    this.overrides = overrides;
+    validate();
+  }
+
+  RESTCatalogConfigResponse validate() {
+    return this;
+  }
+
+  /**
+   * Properties that should be used as default configuration. {@code defaults} have the lowest priority
+   * and should be applied before the client provided configuration.
+   *
+   * @return properties that should be used as default configuration
+   */
+  public Map<String, String> defaults() {
+    return defaults != null ? Maps.newHashMap(defaults) : Collections.emptyMap();
+  }
+
+  /**
+   * Properties that should be used to override client configuration. {@code overrides} have the highest priority
+   * and should be applied after defaults and any client-provided configuration properties.
+   *
+   * @return properties that should be given higher precedence than any client provided input
+   */
+  public Map<String, String> overrides() {
+    return overrides != null ? Maps.newHashMap(overrides) : Collections.emptyMap();
+  }
+
+  /**
+   * Merge client-provided config with server side provided configuration to return a single
+   * properties map which will be used for instantiating and configuring the REST catalog.
+   *
+   * @param clientProperties - Client provided configuration
+   * @return Merged configuration, with precedence in the order overrides > client properties > defaults.
+   */
+  public Map<String, String> merge(Map<String, String> clientProperties) {
+    Preconditions.checkNotNull(clientProperties,
+        "Cannot merge client properties with server-provided properties. Invalid client configuration: null");
+    Map<String, String> merged = Maps.newHashMap(defaults);
+    merged.putAll(clientProperties);
+    merged.putAll(overrides);
+    return merged;
+  }

Review comment:
       This function might be better placed outside of the response object. I haven't included tests for it yet, in case we want to move it to some other utility class or elsewhere (as the request / response object should arguably be more like data classes).




-- 
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-unsubscribe@iceberg.apache.org

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



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


[GitHub] [iceberg] kbendick commented on a change in pull request #4184: CORE: REST Catalog - Response class for server provided configuration

Posted by GitBox <gi...@apache.org>.
kbendick commented on a change in pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184#discussion_r814256978



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/RESTCatalogConfigResponse.java
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.responses;
+
+import java.util.Collections;
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+
+/**
+ * Represents a response to requesting server-side provided configuration for the REST catalog.
+ * This allows client provided values to be overridden by the server or defaulted if not provided by the client.
+ * <p>
+ * This configuration should be fetched with a one time initial HTTP request during the REST catalog initialization.
+ * The connection used to fetch the configuration should then be disposed and a new http client should be
+ * created for use with the catalog.
+ * <p>
+ * Configuration from the server consists of two sets of key/value pairs.
+ * <ul>
+ *   <li> defaults - properties that should be used as default configuration </li>
+ *   <li> overrides - properties that should be used to override client configuration </li>
+ * </ul>
+ */
+public class RESTCatalogConfigResponse {
+
+  private Map<String, String> defaults;
+  private Map<String, String> overrides;
+
+  public RESTCatalogConfigResponse() {
+    // Required for Jackson deserialization
+  }
+
+  private RESTCatalogConfigResponse(Map<String, String> defaults, Map<String, String> overrides) {
+    this.defaults = defaults;
+    this.overrides = overrides;
+    validate();
+  }
+
+  RESTCatalogConfigResponse validate() {
+    return this;
+  }
+
+  /**
+   * Properties that should be used as default configuration. {@code defaults} have the lowest priority
+   * and should be applied before the client provided configuration.
+   *
+   * @return properties that should be used as default configuration
+   */
+  public Map<String, String> defaults() {
+    return defaults != null ? Maps.newHashMap(defaults) : Collections.emptyMap();
+  }
+
+  /**
+   * Properties that should be used to override client configuration. {@code overrides} have the highest priority
+   * and should be applied after defaults and any client-provided configuration properties.
+   *
+   * @return properties that should be given higher precedence than any client provided input
+   */
+  public Map<String, String> overrides() {
+    return overrides != null ? Maps.newHashMap(overrides) : Collections.emptyMap();
+  }
+
+  /**
+   * Merge client-provided config with server side provided configuration to return a single
+   * properties map which will be used for instantiating and configuring the REST catalog.
+   *
+   * @param clientProperties - Client provided configuration
+   * @return Merged configuration, with precedence in the order overrides, then client properties, and then defaults.
+   */
+  public Map<String, String> merge(Map<String, String> clientProperties) {
+    Preconditions.checkNotNull(clientProperties,
+        "Cannot merge client properties with server-provided properties. Invalid client configuration: null");
+    Map<String, String> merged = Maps.newHashMap(defaults);
+    merged.putAll(clientProperties);
+    merged.putAll(overrides);
+    return merged;
+  }
+
+  @Override
+  public String toString() {
+    return MoreObjects.toStringHelper(this)
+        .add("defaults", defaults)
+        .add("overrides", overrides)
+        .toString();
+  }
+
+  public static Builder builder() {
+    return new Builder();
+  }
+
+  public static class Builder {
+    private final Map<String, String> defaults;
+    private final Map<String, String> overrides;
+
+    private Builder() {
+      this.defaults = Maps.newHashMap();
+      this.overrides = Maps.newHashMap();
+    }
+
+    public Builder withDefault(String key, String value) {
+      Preconditions.checkNotNull(key, "Invalid config: null");
+      defaults.put(key, value);
+      return this;
+    }
+
+    public Builder withOverride(String key, String value) {
+      Preconditions.checkNotNull(key, "Invalid config: null");
+      overrides.put(key, value);
+      return this;
+    }
+
+    /**
+     * Adds the passed in map entries to the existing `defaults` of this Builder.
+     */
+    public Builder withDefaults(Map<String, String> defaultsToAdd) {
+      Preconditions.checkNotNull(defaultsToAdd, "Invalid configuration properties map: null");
+      Preconditions.checkArgument(!defaultsToAdd.containsKey(null), "Invalid config: null");
+      defaults.putAll(defaultsToAdd);
+      return this;
+    }
+
+    /**
+     * Adds the passed in map entires to the existing `overrides` of this Builder.
+     */
+    public Builder withOverrides(Map<String, String> overridesToAdd) {
+      Preconditions.checkNotNull(overridesToAdd, "Invalid configuration properties map: null");
+      Preconditions.checkArgument(!overridesToAdd.containsKey(null), "Invalid config: null");

Review comment:
       Updated to say `overrride` and `default` for each.




-- 
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-unsubscribe@iceberg.apache.org

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



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


[GitHub] [iceberg] rdblue commented on a change in pull request #4184: CORE: REST Catalog - Response class for server provided configuration

Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184#discussion_r813380797



##########
File path: core/src/test/java/org/apache/iceberg/rest/responses/TESTRESTCatalogConfigResponse.java
##########
@@ -0,0 +1,247 @@
+/*
+ * 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.responses;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import java.util.Map;
+import org.apache.iceberg.AssertHelpers;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+import org.apache.iceberg.rest.RequestResponseTestBase;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class TESTRESTCatalogConfigResponse extends RequestResponseTestBase<RESTCatalogConfigResponse> {

Review comment:
       Typo: TEST?




-- 
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-unsubscribe@iceberg.apache.org

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



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


[GitHub] [iceberg] rdblue commented on a change in pull request #4184: CORE: REST Catalog - Response class for server provided configuration

Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184#discussion_r814268405



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/RESTCatalogConfigResponse.java
##########
@@ -0,0 +1,153 @@
+/*
+ * 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.responses;
+
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+
+/**
+ * Represents a response to requesting server-side provided configuration for the REST catalog.
+ * This allows client provided values to be overridden by the server or defaulted if not provided by the client.
+ * <p>
+ * The catalog properties, with overrides and defaults applied, should be used to configure the catalog and for all
+ * subsequent requests after this initial config request.
+ * <p>
+ * Configuration from the server consists of two sets of key/value pairs.
+ * <ul>
+ *   <li> defaults - properties that should be used as default configuration </li>
+ *   <li> overrides - properties that should be used to override client configuration </li>
+ * </ul>
+ */
+public class RESTCatalogConfigResponse {
+
+  private Map<String, String> defaults;
+  private Map<String, String> overrides;
+
+  public RESTCatalogConfigResponse() {
+    // Required for Jackson deserialization
+  }
+
+  private RESTCatalogConfigResponse(Map<String, String> defaults, Map<String, String> overrides) {
+    this.defaults = defaults;
+    this.overrides = overrides;
+    validate();
+  }
+
+  RESTCatalogConfigResponse validate() {
+    return this;
+  }
+
+  /**
+   * Properties that should be used as default configuration. {@code defaults} have the lowest priority
+   * and should be applied before the client provided configuration.
+   *
+   * @return properties that should be used as default configuration
+   */
+  public Map<String, String> defaults() {
+    return defaults != null ? defaults : ImmutableMap.of();
+  }
+
+  /**
+   * Properties that should be used to override client configuration. {@code overrides} have the highest priority
+   * and should be applied after defaults and any client-provided configuration properties.
+   *
+   * @return properties that should be given higher precedence than any client provided input
+   */
+  public Map<String, String> overrides() {
+    return overrides != null ? overrides : ImmutableMap.of();
+  }
+
+  /**
+   * Merge client-provided config with server side provided configuration to return a single
+   * properties map which will be used for instantiating and configuring the REST catalog.
+   *
+   * @param clientProperties - Client provided configuration
+   * @return Merged configuration, with precedence in the order overrides, then client properties, and then defaults.
+   */
+  public Map<String, String> merge(Map<String, String> clientProperties) {
+    Preconditions.checkNotNull(clientProperties,
+        "Cannot merge client properties with server-provided properties. Invalid client configuration: null");
+    Map<String, String> merged = Maps.newHashMap(defaults);
+    merged.putAll(clientProperties);
+    merged.putAll(overrides);
+    return merged;

Review comment:
       Given your point below about using `null`, do you think it's a good idea to go through this list and prune out the keys with null values? Then you could return `ImmutableMap.copyOf(merged)`.




-- 
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-unsubscribe@iceberg.apache.org

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



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


[GitHub] [iceberg] kbendick commented on a change in pull request #4184: CORE: REST Catalog - Response class for server provided configuration

Posted by GitBox <gi...@apache.org>.
kbendick commented on a change in pull request #4184:
URL: https://github.com/apache/iceberg/pull/4184#discussion_r814262754



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/RESTCatalogConfigResponse.java
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.responses;
+
+import java.util.Collections;
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+
+/**
+ * Represents a response to requesting server-side provided configuration for the REST catalog.
+ * This allows client provided values to be overridden by the server or defaulted if not provided by the client.
+ * <p>
+ * This configuration should be fetched with a one time initial HTTP request during the REST catalog initialization.
+ * The connection used to fetch the configuration should then be disposed and a new http client should be
+ * created for use with the catalog.
+ * <p>
+ * Configuration from the server consists of two sets of key/value pairs.
+ * <ul>
+ *   <li> defaults - properties that should be used as default configuration </li>
+ *   <li> overrides - properties that should be used to override client configuration </li>
+ * </ul>
+ */
+public class RESTCatalogConfigResponse {
+
+  private Map<String, String> defaults;
+  private Map<String, String> overrides;
+
+  public RESTCatalogConfigResponse() {
+    // Required for Jackson deserialization
+  }
+
+  private RESTCatalogConfigResponse(Map<String, String> defaults, Map<String, String> overrides) {
+    this.defaults = defaults;
+    this.overrides = overrides;
+    validate();
+  }
+
+  RESTCatalogConfigResponse validate() {
+    return this;
+  }
+
+  /**
+   * Properties that should be used as default configuration. {@code defaults} have the lowest priority
+   * and should be applied before the client provided configuration.
+   *
+   * @return properties that should be used as default configuration
+   */
+  public Map<String, String> defaults() {
+    return defaults != null ? Maps.newHashMap(defaults) : Collections.emptyMap();
+  }
+
+  /**
+   * Properties that should be used to override client configuration. {@code overrides} have the highest priority
+   * and should be applied after defaults and any client-provided configuration properties.
+   *
+   * @return properties that should be given higher precedence than any client provided input
+   */
+  public Map<String, String> overrides() {
+    return overrides != null ? Maps.newHashMap(overrides) : Collections.emptyMap();
+  }
+
+  /**
+   * Merge client-provided config with server side provided configuration to return a single
+   * properties map which will be used for instantiating and configuring the REST catalog.
+   *
+   * @param clientProperties - Client provided configuration
+   * @return Merged configuration, with precedence in the order overrides, then client properties, and then defaults.
+   */
+  public Map<String, String> merge(Map<String, String> clientProperties) {
+    Preconditions.checkNotNull(clientProperties,
+        "Cannot merge client properties with server-provided properties. Invalid client configuration: null");
+    Map<String, String> merged = Maps.newHashMap(defaults);
+    merged.putAll(clientProperties);
+    merged.putAll(overrides);
+    return merged;
+  }
+
+  @Override
+  public String toString() {
+    return MoreObjects.toStringHelper(this)
+        .add("defaults", defaults)
+        .add("overrides", overrides)
+        .toString();
+  }
+
+  public static Builder builder() {
+    return new Builder();
+  }
+
+  public static class Builder {
+    private final Map<String, String> defaults;
+    private final Map<String, String> overrides;
+
+    private Builder() {
+      this.defaults = Maps.newHashMap();
+      this.overrides = Maps.newHashMap();

Review comment:
       Using immutable builders makes it so that a `null` value can't be set. Which people might want to do for `overrides` as one example to explicitly disable some configuration .
   
   For example, if an operator wanted to remove all client provided values for a given setting across all jobs for something temporarily, to maybe investigate too many connections to the catalog service or something. They could remove the clients configuration by placing `clients: null` into `overrides` and then setting `clients: 2` in their defaults. Somewhat of a contrived example, but at scale when operators and users are two separate groups, I think this could very much have a practical use case.




-- 
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-unsubscribe@iceberg.apache.org

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



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