danielcweeks commented on code in PR #10929: URL: https://github.com/apache/iceberg/pull/10929#discussion_r1757201978
########## core/src/main/java/org/apache/iceberg/rest/Endpoint.java: ########## @@ -0,0 +1,146 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.iceberg.rest; + +import java.util.List; +import java.util.Objects; +import java.util.Set; +import org.apache.hc.core5.http.Method; +import org.apache.iceberg.relocated.com.google.common.base.Joiner; +import org.apache.iceberg.relocated.com.google.common.base.Preconditions; +import org.apache.iceberg.relocated.com.google.common.base.Splitter; +import org.apache.iceberg.relocated.com.google.common.base.Strings; + +/** + * Holds an endpoint definition that consists of the HTTP method (GET, POST, DELETE, ...) and the + * resource path as defined in the Iceberg OpenAPI REST specification without parameter + * substitution, such as <b>/v1/{prefix}/namespaces/{namespace}</b>. + */ +public class Endpoint { + + // namespace endpoints + public static final Endpoint V1_LIST_NAMESPACES = + Endpoint.create("GET", ResourcePaths.V1_NAMESPACES); + public static final Endpoint V1_LOAD_NAMESPACE = + Endpoint.create("GET", ResourcePaths.V1_NAMESPACE); + public static final Endpoint V1_CREATE_NAMESPACE = + Endpoint.create("POST", ResourcePaths.V1_NAMESPACES); + public static final Endpoint V1_UPDATE_NAMESPACE = + Endpoint.create("POST", ResourcePaths.V1_NAMESPACE_PROPERTIES); + public static final Endpoint V1_DELETE_NAMESPACE = + Endpoint.create("DELETE", ResourcePaths.V1_NAMESPACE); + public static final Endpoint V1_COMMIT_TRANSACTION = + Endpoint.create("POST", ResourcePaths.V1_TRANSACTIONS_COMMIT); + + // table endpoints + public static final Endpoint V1_LIST_TABLES = Endpoint.create("GET", ResourcePaths.V1_TABLES); + public static final Endpoint V1_LOAD_TABLE = Endpoint.create("GET", ResourcePaths.V1_TABLE); + public static final Endpoint V1_CREATE_TABLE = Endpoint.create("POST", ResourcePaths.V1_TABLES); + public static final Endpoint V1_UPDATE_TABLE = Endpoint.create("POST", ResourcePaths.V1_TABLE); + public static final Endpoint V1_DELETE_TABLE = Endpoint.create("DELETE", ResourcePaths.V1_TABLE); + public static final Endpoint V1_RENAME_TABLE = + Endpoint.create("POST", ResourcePaths.V1_TABLE_RENAME); + public static final Endpoint V1_REGISTER_TABLE = + Endpoint.create("POST", ResourcePaths.V1_TABLE_REGISTER); + public static final Endpoint V1_REPORT_METRICS = + Endpoint.create("POST", ResourcePaths.V1_TABLE_METRICS); + + // view endpoints + public static final Endpoint V1_LIST_VIEWS = Endpoint.create("GET", ResourcePaths.V1_VIEWS); + public static final Endpoint V1_LOAD_VIEW = Endpoint.create("GET", ResourcePaths.V1_VIEW); + public static final Endpoint V1_CREATE_VIEW = Endpoint.create("POST", ResourcePaths.V1_VIEWS); + public static final Endpoint V1_UPDATE_VIEW = Endpoint.create("POST", ResourcePaths.V1_VIEW); + public static final Endpoint V1_DELETE_VIEW = Endpoint.create("DELETE", ResourcePaths.V1_VIEW); + public static final Endpoint V1_RENAME_VIEW = + Endpoint.create("POST", ResourcePaths.V1_VIEW_RENAME); + + private static final Splitter ENDPOINT_SPLITTER = Splitter.on(" "); + private static final Joiner ENDPOINT_JOINER = Joiner.on(" "); + private final String httpMethod; + private final String path; + + private Endpoint(String httpMethod, String path) { + Preconditions.checkArgument( + !Strings.isNullOrEmpty(httpMethod), "Invalid HTTP method: null or empty"); + Preconditions.checkArgument(!Strings.isNullOrEmpty(path), "Invalid path: null or empty"); + this.httpMethod = Method.normalizedValueOf(httpMethod).toString(); Review Comment: nit: All `Method.normalizedValueOf` is doing is a `toUpperCase` so probably not worth adding the http5 dependency. We already do the null check, so this really isn't doing anything meaningful as opposed to just `httpMethod.toUppercase(...)` -- 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