dimas-b commented on a change in pull request #3561: URL: https://github.com/apache/iceberg/pull/3561#discussion_r767853990
########## File path: core/src/main/java/org/apache/iceberg/rest/http/IcebergHttpResponse.java ########## @@ -0,0 +1,111 @@ +/* + * 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.http; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * All responses for the first version of the Iceberg REST API will be JSON objects, a top-level envelope object with two fields, + * `error` and `data`, which are themselves JSON objects. + * + * data: represents the JSON encoded response for a successful path or for a valid / expected failure. JSON representation of various response types + * error: a standardized obect on error, containing the error code, message, type, and additional metadata (an optional JSON object of metadata) as defined below. + * + * All responses for the REST catalog should be wrapped this way, vs using primitives. For example, for a ListTableResponse, listing tables under a namespace "accounting", + * we'd get a JSON object back like the following: + * + * { "data": { "identifiers": [ "accounting.tax", "accounting.currency_conversions"] }, "error", {} } + * + * If the namesapce `accounting` didn't request, the response from that call would have a body like the following, + * where the `code` 40401 is a two-part identifier: + * - HTTP response code: 404 + * - Two digit internal application defined error code for further detail: 01 - Namespace not found. + * + * { "data": {}, "error": { "message": "Failed to list tables. The Namespace 'accounting' does not exist", "type": "NamespaceNotFoundException", "code": 40401 } + * + * We could also embed the HTTP response code plainly by itself, without internally documented codes, as a separate field. I have found having a documented list of internal + * error codes to be very helpful previously, but am open to discussion on this. Review comment: Excluding this class from the spec and using only OpenAPI yaml SGTM :+1: Re: `type` values, I personally tend to think that if the field itself is part of the spec, the spec would have to define how to interpret it. I am not sure keeping it "opaque" is going to be that much useful from the spec's perspective. Is this spec intended to define just a common part of the protocol between a Catalog impl. on the Iceberg side and the HTTP server that offers the REST API? Are the client and server parts supposed to be interoperable or are they assumed to work knowing the exact nature and version of the other side? -- 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-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org