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/23 01:20:51 UTC

[GitHub] [iceberg] kbendick opened a new pull request #4201: CORE - Initial basic API for the REST HTTP Client

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


   Adds an initial REST Client API that has `get`, `head`, `post`, `delete`, and `put`.
   These take in an error handler, which handles route specific exceptions using a `Consumer<ErrorResponse>`.
   
   The error response handlers will be coming in another PR.
   
   I also added an `ErrorResponseParser` with basic validation of parsing to / from JSON for an `ErrorResponse`. More tests are to come, but this will unblock others from working concurrently on the test infrastructure for the REST catalog.
   
   cc @rdblue 


-- 
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] happyprg commented on a change in pull request #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/test/java/org/apache/iceberg/rest/responses/TestErrorResponseParser.java
##########
@@ -0,0 +1,54 @@
+/*
+ * 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 org.junit.Assert;
+import org.junit.Test;
+
+public class TestErrorResponseParser {
+
+  @Test
+  public void testErrorResponseToJson() {
+    String message = "The given namespace does not exist";
+    String type = "NoSuchNamespaceException";
+    Integer code = 404;
+    String json = String.format("{\"message\":\"%s\",\"type\":\"%s\",\"code\":%d}", message, type, code);
+    ErrorResponse response = ErrorResponse.builder().withMessage(message).withType(type).responseCode(code).build();
+    Assert.assertEquals("Should be able to serialize an error response as json",
+        ErrorResponseParser.toJson(response), json);
+  }
+
+  @Test
+  public void testErrorResponseFromJson() {
+    String message = "The given namespace does not exist";
+    String type = "NoSuchNamespaceException";
+    Integer code = 404;
+    String json = String.format("{\"message\":\"%s\",\"type\":\"%s\",\"code\":%d}", message, type, code);
+
+    ErrorResponse expected = ErrorResponse.builder().withMessage(message).withType(type).responseCode(code).build();
+    assertEquals(expected, ErrorResponseParser.fromJson(json));
+  }
+
+  public void assertEquals(ErrorResponse expected, ErrorResponse actual) {
+    Assert.assertEquals("Message should be equal", expected.message(), actual.message());
+    Assert.assertEquals("Typ should be equal", expected.type(), actual.type());

Review comment:
       ```suggestion
       Assert.assertEquals("Type should be equal", expected.type(), actual.type());
   ```




-- 
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 #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponseParser.java
##########
@@ -0,0 +1,91 @@
+/*
+ * 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.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonNode;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.UncheckedIOException;
+import org.apache.iceberg.util.JsonUtil;
+
+public class ErrorResponseParser {
+
+  private ErrorResponseParser() {
+  }
+
+  private static final String MESSAGE = "message";
+  private static final String TYPE = "type";
+  private static final String CODE = "code";
+
+  public static String toJson(ErrorResponse errorResponse) {
+    return toJson(errorResponse, false);
+  }
+
+  public static String toJson(ErrorResponse errorResponse, boolean pretty) {
+    try {
+      StringWriter writer = new StringWriter();
+      JsonGenerator generator = JsonUtil.factory().createGenerator(writer);
+      if (pretty) {
+        generator.useDefaultPrettyPrinter();
+      }
+      toJson(errorResponse, generator);
+      generator.flush();
+      return writer.toString();
+    } catch (IOException e) {
+      throw new UncheckedIOException(String.format("Failed to write error response json for: %s", errorResponse), e);
+    }
+  }
+
+  public static void toJson(ErrorResponse errorResponse, JsonGenerator generator) throws IOException {
+    generator.writeStartObject();
+    generator.writeStringField(MESSAGE, errorResponse.message());

Review comment:
       Added it back in.




-- 
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 #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponseParser.java
##########
@@ -0,0 +1,91 @@
+/*
+ * 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.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonNode;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.UncheckedIOException;
+import org.apache.iceberg.util.JsonUtil;
+
+public class ErrorResponseParser {
+
+  private ErrorResponseParser() {
+  }
+
+  private static final String MESSAGE = "message";
+  private static final String TYPE = "type";
+  private static final String CODE = "code";
+
+  public static String toJson(ErrorResponse errorResponse) {
+    return toJson(errorResponse, false);
+  }
+
+  public static String toJson(ErrorResponse errorResponse, boolean pretty) {
+    try {
+      StringWriter writer = new StringWriter();
+      JsonGenerator generator = JsonUtil.factory().createGenerator(writer);
+      if (pretty) {
+        generator.useDefaultPrettyPrinter();
+      }
+      toJson(errorResponse, generator);
+      generator.flush();
+      return writer.toString();
+    } catch (IOException e) {
+      throw new UncheckedIOException(String.format("Failed to write error response json for: %s", errorResponse), e);
+    }
+  }
+
+  public static void toJson(ErrorResponse errorResponse, JsonGenerator generator) throws IOException {
+    generator.writeStartObject();
+    generator.writeStringField(MESSAGE, errorResponse.message());
+    generator.writeStringField(TYPE, errorResponse.type());
+    generator.writeNumberField(CODE, errorResponse.code());
+    generator.writeEndObject();
+  }
+
+  /**
+   * Read ErrorResponse from a JSON string.
+   *
+   * @param json a JSON string of an ErrorResponse
+   * @return an ErrorResponse object
+   */
+  public static ErrorResponse fromJson(String json) {
+    try {
+      JsonNode node = JsonUtil.mapper().readValue(json, JsonNode.class);
+      return fromJson(node);
+    } catch (IOException e) {
+      throw new UncheckedIOException("Failed to read JSON string: " + json, e);
+    }
+  }
+
+  public static ErrorResponse fromJson(JsonNode jsonNode) {
+    String message = JsonUtil.getStringOrNull("message", jsonNode);

Review comment:
       Added validation that it's not null, is an object, and has the "error" field.




-- 
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 #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponseParser.java
##########
@@ -85,8 +85,9 @@ public static ErrorResponse fromJson(String json) {
   }
 
   public static ErrorResponse fromJson(JsonNode jsonNode) {
-    Preconditions.checkArgument(jsonNode != null && jsonNode.isObject() && jsonNode.has(ERROR),
-        "Cannot parse missing field: error");
+    Preconditions.checkArgument(jsonNode != null && jsonNode.isObject(),
+        "Cannot parse %s from non-object value", ERROR);

Review comment:
       Nit: we would normally include the problem object for debugging.




-- 
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 #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponseParser.java
##########
@@ -0,0 +1,91 @@
+/*
+ * 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.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonNode;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.UncheckedIOException;
+import org.apache.iceberg.util.JsonUtil;
+
+public class ErrorResponseParser {
+
+  private ErrorResponseParser() {
+  }
+
+  private static final String MESSAGE = "message";
+  private static final String TYPE = "type";
+  private static final String CODE = "code";
+
+  public static String toJson(ErrorResponse errorResponse) {
+    return toJson(errorResponse, false);
+  }
+
+  public static String toJson(ErrorResponse errorResponse, boolean pretty) {
+    try {
+      StringWriter writer = new StringWriter();
+      JsonGenerator generator = JsonUtil.factory().createGenerator(writer);
+      if (pretty) {
+        generator.useDefaultPrettyPrinter();
+      }
+      toJson(errorResponse, generator);
+      generator.flush();
+      return writer.toString();
+    } catch (IOException e) {
+      throw new UncheckedIOException(String.format("Failed to write error response json for: %s", errorResponse), e);
+    }
+  }
+
+  public static void toJson(ErrorResponse errorResponse, JsonGenerator generator) throws IOException {
+    generator.writeStartObject();
+    generator.writeStringField(MESSAGE, errorResponse.message());
+    generator.writeStringField(TYPE, errorResponse.type());
+    generator.writeNumberField(CODE, errorResponse.code());
+    generator.writeEndObject();
+  }
+
+  /**
+   * Read ErrorResponse from a JSON string.
+   *
+   * @param json a JSON string of an ErrorResponse
+   * @return an ErrorResponse object
+   */
+  public static ErrorResponse fromJson(String json) {
+    try {
+      JsonNode node = JsonUtil.mapper().readValue(json, JsonNode.class);
+      return fromJson(node);

Review comment:
       oooo good catch. 




-- 
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 #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponseParser.java
##########
@@ -85,8 +85,9 @@ public static ErrorResponse fromJson(String json) {
   }
 
   public static ErrorResponse fromJson(JsonNode jsonNode) {
-    Preconditions.checkArgument(jsonNode != null && jsonNode.isObject() && jsonNode.has(ERROR),
-        "Cannot parse missing field: error");
+    Preconditions.checkArgument(jsonNode != null && jsonNode.isObject(),
+        "Cannot parse %s from non-object value", ERROR);

Review comment:
       Updated to log the object instead of just `ERROR`. Was a copy-pasta mistake. Good catch!




-- 
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 pull request #4201: CORE - Initial basic API for the REST HTTP Client

Posted by GitBox <gi...@apache.org>.
rdblue commented on pull request #4201:
URL: https://github.com/apache/iceberg/pull/4201#issuecomment-1048924112


   Thanks, @kbendick! I just merged this.
   
   Good to have this in to unblock building tests and the HTTP implementation in parallel. Thank you!


-- 
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] hililiwei commented on a change in pull request #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/RESTClient.java
##########
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.rest;
+
+import java.io.Closeable;
+import java.util.function.Consumer;
+import org.apache.iceberg.rest.responses.ErrorResponse;
+
+/**
+ * Interface for a basic HTTP Client for interfacing with the REST catalog.
+ */
+public interface RESTClient extends Closeable {
+  <T> T delete(String path, Class<T> responseType, Consumer<ErrorResponse> errorHandler);
+  <T> T put(String path, Object body, Consumer<ErrorResponse> errorHandler);
+  <T> T post(String path, Object body, Class<T> responseType, Consumer<ErrorResponse> errorHandler);
+  <T> T get(String path, Class<T> responseType, Consumer<ErrorResponse> errorHandler);
+  <T> T head(String path, Consumer<ErrorResponse> errorHandler);

Review comment:
       Do we need to add more Javadoc to explain?

##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponse.java
##########
@@ -0,0 +1,104 @@
+/*
+ * 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 org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+
+/**
+ * Standard response body for all API errors
+ */
+public class ErrorResponse {
+
+  private String message;
+  private String type;
+  private Integer code;
+
+  public ErrorResponse() {
+    // Needed for Jackson deserialization
+  }
+
+  private ErrorResponse(String message, String type, int code) {
+    this.message = message;
+    this.type = type;
+    this.code = code;
+    validate();

Review comment:
       validate first?




-- 
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 #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponse.java
##########
@@ -0,0 +1,99 @@
+/*
+ * 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 org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+
+/**
+ * Standard response body for all API errors
+ */
+public class ErrorResponse {
+
+  private String message;
+  private String type;
+  private int code;
+
+  private ErrorResponse(String message, String type, int code) {
+    this.message = message;
+    this.type = type;
+    this.code = code;
+    validate();
+  }
+
+  ErrorResponse validate() {
+    return this;
+  }
+
+  public String message() {
+    return message;
+  }
+
+  public String type() {
+    return type;
+  }
+
+  public Integer code() {
+    return code;
+  }
+

Review comment:
       Nit: unnecessary newline.




-- 
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 #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponseParser.java
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonNode;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.UncheckedIOException;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.util.JsonUtil;
+
+public class ErrorResponseParser {
+
+  private ErrorResponseParser() {
+  }
+
+  private static final String ERROR = "error";
+  private static final String MESSAGE = "message";
+  private static final String TYPE = "type";
+  private static final String CODE = "code";
+
+  public static String toJson(ErrorResponse errorResponse) {
+    return toJson(errorResponse, false);
+  }
+
+  public static String toJson(ErrorResponse errorResponse, boolean pretty) {
+    try {
+      StringWriter writer = new StringWriter();
+      JsonGenerator generator = JsonUtil.factory().createGenerator(writer);
+      if (pretty) {
+        generator.useDefaultPrettyPrinter();
+      }
+      toJson(errorResponse, generator);
+      generator.flush();
+      return writer.toString();
+    } catch (IOException e) {
+      throw new UncheckedIOException(String.format("Failed to write error response json for: %s", errorResponse), e);
+    }
+  }
+
+  public static void toJson(ErrorResponse errorResponse, JsonGenerator generator) throws IOException {
+    generator.writeStartObject();
+
+    generator.writeObjectFieldStart(ERROR);
+
+    generator.writeStringField(MESSAGE, errorResponse.message());
+    generator.writeStringField(TYPE, errorResponse.type());
+    generator.writeNumberField(CODE, errorResponse.code());
+
+    generator.writeEndObject();
+
+    generator.writeEndObject();
+  }
+
+  /**
+   * Read ErrorResponse from a JSON string.
+   *
+   * @param json a JSON string of an ErrorResponse
+   * @return an ErrorResponse object
+   */
+  public static ErrorResponse fromJson(String json) {
+    try {
+      return fromJson(JsonUtil.mapper().readValue(json, JsonNode.class));
+    } catch (IOException e) {
+      throw new UncheckedIOException("Failed to read JSON string: " + json, e);
+    }
+  }
+
+  public static ErrorResponse fromJson(JsonNode jsonNode) {
+    Preconditions.checkArgument(jsonNode != null && jsonNode.isObject() && jsonNode.has(ERROR),
+        "Cannot parse missing field: error");

Review comment:
       Updted to two checks.

##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponse.java
##########
@@ -0,0 +1,99 @@
+/*
+ * 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 org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+
+/**
+ * Standard response body for all API errors
+ */
+public class ErrorResponse {
+
+  private String message;
+  private String type;
+  private int code;
+
+  private ErrorResponse(String message, String type, int code) {
+    this.message = message;
+    this.type = type;
+    this.code = code;
+    validate();
+  }
+
+  ErrorResponse validate() {
+    return this;
+  }
+
+  public String message() {
+    return message;
+  }
+
+  public String type() {
+    return type;
+  }
+
+  public Integer code() {
+    return code;
+  }
+

Review comment:
       Removed




-- 
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 #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/RESTClient.java
##########
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.rest;
+
+import java.io.Closeable;
+import java.util.function.Consumer;
+import org.apache.iceberg.rest.responses.ErrorResponse;
+
+/**
+ * Interface for a basic HTTP Client for interfacing with the REST catalog.
+ */
+public interface RESTClient extends Closeable {
+  <T> T delete(String path, Class<T> responseType, Consumer<ErrorResponse> errorHandler);
+  <T> T put(String path, Object body, Consumer<ErrorResponse> errorHandler);

Review comment:
       Removed as this is currently just to unblock other work.




-- 
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 #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/RESTClient.java
##########
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.rest;
+
+import java.io.Closeable;
+import java.util.function.Consumer;
+import org.apache.iceberg.rest.responses.ErrorResponse;
+
+/**
+ * Interface for a basic HTTP Client for interfacing with the REST catalog.
+ */
+public interface RESTClient extends Closeable {
+  <T> T delete(String path, Class<T> responseType, Consumer<ErrorResponse> errorHandler);
+  <T> T put(String path, Object body, Consumer<ErrorResponse> errorHandler);

Review comment:
       I don't think the spec uses PUT, so we can remove it right?




-- 
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 #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponse.java
##########
@@ -0,0 +1,104 @@
+/*
+ * 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 org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+
+/**
+ * Standard response body for all API errors
+ */
+public class ErrorResponse {
+
+  private String message;
+  private String type;
+  private Integer code;
+
+  public ErrorResponse() {
+    // Needed for Jackson deserialization
+  }
+
+  private ErrorResponse(String message, String type, int code) {
+    this.message = message;
+    this.type = type;
+    this.code = code;
+    validate();
+  }
+
+  ErrorResponse validate() {
+    Preconditions.checkArgument(code != null, "Invalid response, missing field: code");

Review comment:
       If we don't use Jackson serialization, do we need a validate method? I would assume not. If this is for consistency with the other objects, I'd just leave this blank.




-- 
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 #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponse.java
##########
@@ -0,0 +1,104 @@
+/*
+ * 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 org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+
+/**
+ * Standard response body for all API errors
+ */
+public class ErrorResponse {
+
+  private String message;
+  private String type;
+  private Integer code;

Review comment:
       This can be `int` if we don't use Jackson.




-- 
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 #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponse.java
##########
@@ -0,0 +1,104 @@
+/*
+ * 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 org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+
+/**
+ * Standard response body for all API errors
+ */
+public class ErrorResponse {
+
+  private String message;
+  private String type;
+  private Integer code;

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 #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponse.java
##########
@@ -0,0 +1,104 @@
+/*
+ * 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 org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+
+/**
+ * Standard response body for all API errors
+ */
+public class ErrorResponse {
+
+  private String message;
+  private String type;
+  private Integer code;
+
+  public ErrorResponse() {
+    // Needed for Jackson deserialization
+  }
+
+  private ErrorResponse(String message, String type, int code) {
+    this.message = message;
+    this.type = type;
+    this.code = code;
+    validate();
+  }
+
+  ErrorResponse validate() {
+    Preconditions.checkArgument(code != null, "Invalid response, missing field: code");

Review comment:
       Yeah this is mostly for consistency with the other objects of type `response`.
   
   I just have it returning `this` (which a few classes do as well).




-- 
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] happyprg commented on a change in pull request #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponseParser.java
##########
@@ -0,0 +1,91 @@
+/*
+ * 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.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonNode;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.UncheckedIOException;
+import org.apache.iceberg.util.JsonUtil;
+
+public class ErrorResponseParser {
+
+  private ErrorResponseParser() {
+  }
+
+  private static final String MESSAGE = "message";
+  private static final String TYPE = "type";
+  private static final String CODE = "code";
+
+  public static String toJson(ErrorResponse errorResponse) {
+    return toJson(errorResponse, false);
+  }
+
+  public static String toJson(ErrorResponse errorResponse, boolean pretty) {
+    try {
+      StringWriter writer = new StringWriter();
+      JsonGenerator generator = JsonUtil.factory().createGenerator(writer);
+      if (pretty) {
+        generator.useDefaultPrettyPrinter();
+      }
+      toJson(errorResponse, generator);
+      generator.flush();
+      return writer.toString();
+    } catch (IOException e) {
+      throw new UncheckedIOException(String.format("Failed to write error response json for: %s", errorResponse), e);
+    }
+  }
+
+  public static void toJson(ErrorResponse errorResponse, JsonGenerator generator) throws IOException {
+    generator.writeStartObject();
+    generator.writeStringField(MESSAGE, errorResponse.message());
+    generator.writeStringField(TYPE, errorResponse.type());
+    generator.writeNumberField(CODE, errorResponse.code());
+    generator.writeEndObject();
+  }
+
+  /**
+   * Read ErrorResponse from a JSON string.
+   *
+   * @param json a JSON string of an ErrorResponse
+   * @return an ErrorResponse object
+   */
+  public static ErrorResponse fromJson(String json) {
+    try {
+      JsonNode node = JsonUtil.mapper().readValue(json, JsonNode.class);
+      return fromJson(node);

Review comment:
       ```suggestion
         return fromJson(JsonUtil.mapper().readValue(json, JsonNode.class));
   ```




-- 
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 #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponseParser.java
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonNode;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.UncheckedIOException;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.util.JsonUtil;
+
+public class ErrorResponseParser {
+
+  private ErrorResponseParser() {
+  }
+
+  private static final String ERROR = "error";
+  private static final String MESSAGE = "message";
+  private static final String TYPE = "type";
+  private static final String CODE = "code";
+
+  public static String toJson(ErrorResponse errorResponse) {
+    return toJson(errorResponse, false);
+  }
+
+  public static String toJson(ErrorResponse errorResponse, boolean pretty) {
+    try {
+      StringWriter writer = new StringWriter();
+      JsonGenerator generator = JsonUtil.factory().createGenerator(writer);
+      if (pretty) {
+        generator.useDefaultPrettyPrinter();
+      }
+      toJson(errorResponse, generator);
+      generator.flush();
+      return writer.toString();
+    } catch (IOException e) {
+      throw new UncheckedIOException(String.format("Failed to write error response json for: %s", errorResponse), e);
+    }
+  }
+
+  public static void toJson(ErrorResponse errorResponse, JsonGenerator generator) throws IOException {
+    generator.writeStartObject();
+
+    generator.writeObjectFieldStart(ERROR);
+
+    generator.writeStringField(MESSAGE, errorResponse.message());
+    generator.writeStringField(TYPE, errorResponse.type());
+    generator.writeNumberField(CODE, errorResponse.code());
+
+    generator.writeEndObject();
+
+    generator.writeEndObject();
+  }
+
+  /**
+   * Read ErrorResponse from a JSON string.
+   *
+   * @param json a JSON string of an ErrorResponse
+   * @return an ErrorResponse object
+   */
+  public static ErrorResponse fromJson(String json) {
+    try {
+      return fromJson(JsonUtil.mapper().readValue(json, JsonNode.class));
+    } catch (IOException e) {
+      throw new UncheckedIOException("Failed to read JSON string: " + json, e);
+    }
+  }
+
+  public static ErrorResponse fromJson(JsonNode jsonNode) {
+    Preconditions.checkArgument(jsonNode != null && jsonNode.isObject() && jsonNode.has(ERROR),
+        "Cannot parse missing field: error");

Review comment:
       This mixes two different errors. The first is that the JSON node has the wrong type and can't be the error response. The second is that it doesn't have an "error" field.




-- 
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 #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponseParser.java
##########
@@ -0,0 +1,91 @@
+/*
+ * 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.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonNode;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.UncheckedIOException;
+import org.apache.iceberg.util.JsonUtil;
+
+public class ErrorResponseParser {
+
+  private ErrorResponseParser() {
+  }
+
+  private static final String MESSAGE = "message";
+  private static final String TYPE = "type";
+  private static final String CODE = "code";
+
+  public static String toJson(ErrorResponse errorResponse) {
+    return toJson(errorResponse, false);
+  }
+
+  public static String toJson(ErrorResponse errorResponse, boolean pretty) {
+    try {
+      StringWriter writer = new StringWriter();
+      JsonGenerator generator = JsonUtil.factory().createGenerator(writer);
+      if (pretty) {
+        generator.useDefaultPrettyPrinter();
+      }
+      toJson(errorResponse, generator);
+      generator.flush();
+      return writer.toString();
+    } catch (IOException e) {
+      throw new UncheckedIOException(String.format("Failed to write error response json for: %s", errorResponse), e);
+    }
+  }
+
+  public static void toJson(ErrorResponse errorResponse, JsonGenerator generator) throws IOException {
+    generator.writeStartObject();
+    generator.writeStringField(MESSAGE, errorResponse.message());
+    generator.writeStringField(TYPE, errorResponse.type());
+    generator.writeNumberField(CODE, errorResponse.code());
+    generator.writeEndObject();
+  }
+
+  /**
+   * Read ErrorResponse from a JSON string.
+   *
+   * @param json a JSON string of an ErrorResponse
+   * @return an ErrorResponse object
+   */
+  public static ErrorResponse fromJson(String json) {
+    try {
+      JsonNode node = JsonUtil.mapper().readValue(json, JsonNode.class);
+      return fromJson(node);
+    } catch (IOException e) {
+      throw new UncheckedIOException("Failed to read JSON string: " + json, e);
+    }
+  }
+
+  public static ErrorResponse fromJson(JsonNode jsonNode) {
+    String message = JsonUtil.getStringOrNull("message", jsonNode);

Review comment:
       I think this needs to validate that `jsonNode` is an object node, similar to checks in other parsers.




-- 
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 #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/test/java/org/apache/iceberg/rest/responses/TestErrorResponseParser.java
##########
@@ -0,0 +1,54 @@
+/*
+ * 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 org.junit.Assert;
+import org.junit.Test;
+
+public class TestErrorResponseParser {
+
+  @Test
+  public void testErrorResponseToJson() {
+    String message = "The given namespace does not exist";
+    String type = "NoSuchNamespaceException";
+    Integer code = 404;
+    String json = String.format("{\"message\":\"%s\",\"type\":\"%s\",\"code\":%d}", message, type, code);
+    ErrorResponse response = ErrorResponse.builder().withMessage(message).withType(type).responseCode(code).build();
+    Assert.assertEquals("Should be able to serialize an error response as json",
+        ErrorResponseParser.toJson(response), json);
+  }
+
+  @Test
+  public void testErrorResponseFromJson() {
+    String message = "The given namespace does not exist";
+    String type = "NoSuchNamespaceException";
+    Integer code = 404;
+    String json = String.format("{\"message\":\"%s\",\"type\":\"%s\",\"code\":%d}", message, type, code);
+
+    ErrorResponse expected = ErrorResponse.builder().withMessage(message).withType(type).responseCode(code).build();
+    assertEquals(expected, ErrorResponseParser.fromJson(json));
+  }
+
+  public void assertEquals(ErrorResponse expected, ErrorResponse actual) {
+    Assert.assertEquals("Message should be equal", expected.message(), actual.message());
+    Assert.assertEquals("Typ should be equal", expected.type(), actual.type());

Review comment:
       Good catch!




-- 
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 #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponse.java
##########
@@ -0,0 +1,104 @@
+/*
+ * 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 org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+
+/**
+ * Standard response body for all API errors
+ */
+public class ErrorResponse {
+
+  private String message;
+  private String type;
+  private Integer code;
+
+  public ErrorResponse() {
+    // Needed for Jackson deserialization

Review comment:
       Yeah it just needs to be registered on the ObjectMapper.




-- 
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 #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponse.java
##########
@@ -0,0 +1,104 @@
+/*
+ * 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 org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+
+/**
+ * Standard response body for all API errors
+ */
+public class ErrorResponse {
+
+  private String message;
+  private String type;
+  private Integer code;
+
+  public ErrorResponse() {
+    // Needed for Jackson deserialization

Review comment:
       Removed.




-- 
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 #4201: CORE - Initial basic API for the REST HTTP Client

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


   


-- 
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 #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponse.java
##########
@@ -0,0 +1,104 @@
+/*
+ * 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 org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+
+/**
+ * Standard response body for all API errors
+ */
+public class ErrorResponse {
+
+  private String message;
+  private String type;
+  private Integer code;
+
+  public ErrorResponse() {
+    // Needed for Jackson deserialization
+  }
+
+  private ErrorResponse(String message, String type, int code) {
+    this.message = message;
+    this.type = type;
+    this.code = code;
+    validate();

Review comment:
       @rdblue is correct.




-- 
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 #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponseParser.java
##########
@@ -0,0 +1,91 @@
+/*
+ * 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.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonNode;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.UncheckedIOException;
+import org.apache.iceberg.util.JsonUtil;
+
+public class ErrorResponseParser {
+
+  private ErrorResponseParser() {
+  }
+
+  private static final String MESSAGE = "message";
+  private static final String TYPE = "type";
+  private static final String CODE = "code";
+
+  public static String toJson(ErrorResponse errorResponse) {
+    return toJson(errorResponse, false);
+  }
+
+  public static String toJson(ErrorResponse errorResponse, boolean pretty) {
+    try {
+      StringWriter writer = new StringWriter();
+      JsonGenerator generator = JsonUtil.factory().createGenerator(writer);
+      if (pretty) {
+        generator.useDefaultPrettyPrinter();
+      }
+      toJson(errorResponse, generator);
+      generator.flush();
+      return writer.toString();
+    } catch (IOException e) {
+      throw new UncheckedIOException(String.format("Failed to write error response json for: %s", errorResponse), e);
+    }
+  }
+
+  public static void toJson(ErrorResponse errorResponse, JsonGenerator generator) throws IOException {
+    generator.writeStartObject();
+    generator.writeStringField(MESSAGE, errorResponse.message());

Review comment:
       Why does this omit the `error` level?




-- 
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 #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponse.java
##########
@@ -0,0 +1,104 @@
+/*
+ * 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 org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+
+/**
+ * Standard response body for all API errors
+ */
+public class ErrorResponse {
+
+  private String message;
+  private String type;
+  private Integer code;
+
+  public ErrorResponse() {
+    // Needed for Jackson deserialization
+  }
+
+  private ErrorResponse(String message, String type, int code) {
+    this.message = message;
+    this.type = type;
+    this.code = code;
+    validate();

Review comment:
       No, `validate` is checking the state of the object so the assignments need to happen first.




-- 
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 #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/RESTClient.java
##########
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.rest;
+
+import java.io.Closeable;
+import java.util.function.Consumer;
+import org.apache.iceberg.rest.responses.ErrorResponse;
+
+/**
+ * Interface for a basic HTTP Client for interfacing with the REST catalog.
+ */
+public interface RESTClient extends Closeable {
+  <T> T delete(String path, Class<T> responseType, Consumer<ErrorResponse> errorHandler);
+  <T> T put(String path, Object body, Consumer<ErrorResponse> errorHandler);
+  <T> T post(String path, Object body, Class<T> responseType, Consumer<ErrorResponse> errorHandler);
+  <T> T get(String path, Class<T> responseType, Consumer<ErrorResponse> errorHandler);
+  <T> T head(String path, Consumer<ErrorResponse> errorHandler);

Review comment:
       This is to unblock other commits, so I think we're okay moving forward with this simple API for now. I agree we will want to add some Javadoc eventually.




-- 
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 #4201: CORE - Initial basic API for the REST HTTP Client

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



##########
File path: core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponse.java
##########
@@ -0,0 +1,104 @@
+/*
+ * 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 org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+
+/**
+ * Standard response body for all API errors
+ */
+public class ErrorResponse {
+
+  private String message;
+  private String type;
+  private Integer code;
+
+  public ErrorResponse() {
+    // Needed for Jackson deserialization

Review comment:
       If there is a specific parser for this, then we don't need Jackson serialization right?




-- 
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