Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Apache Paimon RESTClient

From Leeroopedia


Knowledge Sources
Domains REST API, HTTP Client, Interface
Last Updated 2026-02-08 00:00 GMT

Overview

RESTClient is a basic interface defining HTTP operations for communicating with the REST catalog server.

Description

RESTClient is a lightweight interface that defines the contract for HTTP communication with Apache Paimon's REST catalog. It provides method signatures for the three primary HTTP operations: GET, POST, and DELETE, each with support for authentication through RESTAuthFunction parameters.

The interface is designed with flexibility in mind, offering multiple overloaded versions of each operation to handle different use cases. GET operations support both simple path-based requests and requests with query parameters. POST operations can optionally specify a response type for deserialization, allowing for fire-and-forget requests when no response parsing is needed. DELETE operations similarly support both simple deletions and deletions with request bodies for additional parameters.

All methods are generic and parameterized with response types that extend RESTResponse, ensuring type safety while maintaining flexibility. The authentication function parameter is optional (can be null) but when provided, it generates the necessary HTTP headers for authenticated requests based on the request parameters.

Usage

Use RESTClient as the base interface for implementing HTTP clients that communicate with REST catalog servers. It's typically implemented by concrete HTTP client classes like HttpClient and serves as the foundation for all REST catalog communication.

Code Reference

Source Location

Signature

public interface RESTClient {

    <T extends RESTResponse> T get(
            String path, Class<T> responseType, RESTAuthFunction restAuthFunction);

    <T extends RESTResponse> T get(
            String path,
            Map<String, String> queryParams,
            Class<T> responseType,
            RESTAuthFunction restAuthFunction);

    <T extends RESTResponse> T post(
            String path, RESTRequest body, RESTAuthFunction restAuthFunction);

    <T extends RESTResponse> T post(
            String path,
            RESTRequest body,
            Class<T> responseType,
            RESTAuthFunction restAuthFunction);

    <T extends RESTResponse> T delete(String path, RESTAuthFunction restAuthFunction);

    <T extends RESTResponse> T delete(
            String path, RESTRequest body, RESTAuthFunction restAuthFunction);
}

Import

import org.apache.paimon.rest.RESTClient;

I/O Contract

Inputs

Name Type Required Description
path String Yes URL path for the request
queryParams Map<String, String> No Query parameters for GET requests
body RESTRequest No Request body for POST/DELETE operations
responseType Class<T> Yes/No Response class for deserialization (required for some overloads)
restAuthFunction RESTAuthFunction No Function to generate authentication headers

Outputs

Name Type Description
get() T extends RESTResponse Deserialized response object from GET request
post() T extends RESTResponse Deserialized response object from POST request (may be null)
delete() T extends RESTResponse Deserialized response object from DELETE request (may be null)

Usage Examples

import org.apache.paimon.rest.RESTClient;
import org.apache.paimon.rest.RESTRequest;
import org.apache.paimon.rest.RESTResponse;
import org.apache.paimon.rest.auth.RESTAuthFunction;

// Example implementation usage
public class CatalogService {
    private final RESTClient client;
    private final RESTAuthFunction authFunction;

    public CatalogService(RESTClient client, RESTAuthFunction authFunction) {
        this.client = client;
        this.authFunction = authFunction;
    }

    // Example 1: Simple GET request
    public ConfigResponse getConfig() {
        return client.get(
            "/v1/config",
            ConfigResponse.class,
            authFunction
        );
    }

    // Example 2: GET with query parameters
    public TableListResponse listTables(String namespace, int limit) {
        Map<String, String> params = new HashMap<>();
        params.put("namespace", namespace);
        params.put("limit", String.valueOf(limit));

        return client.get(
            "/v1/tables",
            params,
            TableListResponse.class,
            authFunction
        );
    }

    // Example 3: POST with response
    public CreateTableResponse createTable(CreateTableRequest request) {
        return client.post(
            "/v1/tables",
            request,
            CreateTableResponse.class,
            authFunction
        );
    }

    // Example 4: POST without response parsing
    public void refreshTable(String tableName) {
        RefreshRequest request = new RefreshRequest();
        client.post(
            "/v1/tables/" + tableName + "/refresh",
            request,
            authFunction  // No response type, returns null
        );
    }

    // Example 5: Simple DELETE
    public void dropTable(String tableName) {
        client.delete(
            "/v1/tables/" + tableName,
            authFunction
        );
    }

    // Example 6: DELETE with body
    public void dropTableWithOptions(String tableName, boolean purge) {
        DropRequest request = new DropRequest(purge);
        client.delete(
            "/v1/tables/" + tableName,
            request,
            authFunction
        );
    }
}

// Example custom implementation
public class CustomRESTClient implements RESTClient {
    @Override
    public <T extends RESTResponse> T get(
            String path, Class<T> responseType, RESTAuthFunction restAuthFunction) {
        // Custom implementation
        return null;
    }

    // Implement other methods...
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment