23#include <unordered_map>
26#include <nlohmann/json_fwd.hpp>
28#include "iceberg/catalog/rest/iceberg_rest_export.h"
30#include "iceberg/result.h"
36namespace iceberg::rest {
38template <
typename Model>
39Result<Model> FromJson(
const nlohmann::json& json);
41#define ICEBERG_DECLARE_JSON_SERDE(Model) \
42 ICEBERG_REST_EXPORT Result<Model> Model##FromJson(const nlohmann::json& json); \
45 ICEBERG_REST_EXPORT Result<Model> FromJson(const nlohmann::json& json); \
47 ICEBERG_REST_EXPORT nlohmann::json ToJson(const Model& model);
51ICEBERG_DECLARE_JSON_SERDE(CatalogConfig)
52ICEBERG_DECLARE_JSON_SERDE(ErrorResponse)
53ICEBERG_DECLARE_JSON_SERDE(ListNamespacesResponse)
54ICEBERG_DECLARE_JSON_SERDE(CreateNamespaceRequest)
55ICEBERG_DECLARE_JSON_SERDE(CreateNamespaceResponse)
56ICEBERG_DECLARE_JSON_SERDE(GetNamespaceResponse)
57ICEBERG_DECLARE_JSON_SERDE(UpdateNamespacePropertiesRequest)
58ICEBERG_DECLARE_JSON_SERDE(UpdateNamespacePropertiesResponse)
59ICEBERG_DECLARE_JSON_SERDE(ListTablesResponse)
60ICEBERG_DECLARE_JSON_SERDE(RegisterTableRequest)
61ICEBERG_DECLARE_JSON_SERDE(RenameTableRequest)
62ICEBERG_DECLARE_JSON_SERDE(OAuthTokenResponse)
64#undef ICEBERG_DECLARE_JSON_SERDE
68ICEBERG_REST_EXPORT Result<LoadTableResult> LoadTableResultFromJson(
69 const nlohmann::json& json);
71ICEBERG_REST_EXPORT Result<LoadTableResult> FromJson(
const nlohmann::json& json);
72ICEBERG_REST_EXPORT Result<nlohmann::json> ToJson(
const LoadTableResult& model);
74ICEBERG_REST_EXPORT Result<CreateTableRequest> CreateTableRequestFromJson(
75 const nlohmann::json& json);
77ICEBERG_REST_EXPORT Result<CreateTableRequest> FromJson(
const nlohmann::json& json);
78ICEBERG_REST_EXPORT Result<nlohmann::json> ToJson(
const CreateTableRequest& model);
80ICEBERG_REST_EXPORT Result<CommitTableRequest> CommitTableRequestFromJson(
81 const nlohmann::json& json);
83ICEBERG_REST_EXPORT Result<CommitTableRequest> FromJson(
const nlohmann::json& json);
84ICEBERG_REST_EXPORT Result<nlohmann::json> ToJson(
const CommitTableRequest& model);
86ICEBERG_REST_EXPORT Result<CommitTableResponse> CommitTableResponseFromJson(
87 const nlohmann::json& json);
89ICEBERG_REST_EXPORT Result<CommitTableResponse> FromJson(
const nlohmann::json& json);
90ICEBERG_REST_EXPORT Result<nlohmann::json> ToJson(
const CommitTableResponse& model);
92ICEBERG_REST_EXPORT Result<PlanTableScanResponse> PlanTableScanResponseFromJson(
93 const nlohmann::json& json,
94 const std::unordered_map<int32_t, std::shared_ptr<PartitionSpec>>&
95 partition_specs_by_id,
96 const Schema& schema);
97ICEBERG_REST_EXPORT Result<nlohmann::json> ToJson(
98 const PlanTableScanResponse& response,
99 const std::unordered_map<int32_t, std::shared_ptr<PartitionSpec>>&
100 partition_specs_by_id,
101 const Schema& schema);
103ICEBERG_REST_EXPORT Result<FetchPlanningResultResponse>
104FetchPlanningResultResponseFromJson(
105 const nlohmann::json& json,
106 const std::unordered_map<int32_t, std::shared_ptr<PartitionSpec>>&
107 partition_specs_by_id,
108 const Schema& schema);
109ICEBERG_REST_EXPORT Result<nlohmann::json> ToJson(
110 const FetchPlanningResultResponse& response,
111 const std::unordered_map<int32_t, std::shared_ptr<PartitionSpec>>&
112 partition_specs_by_id,
113 const Schema& schema);
115ICEBERG_REST_EXPORT Result<FetchScanTasksResponse> FetchScanTasksResponseFromJson(
116 const nlohmann::json& json,
117 const std::unordered_map<int32_t, std::shared_ptr<PartitionSpec>>&
118 partition_specs_by_id,
119 const Schema& schema);
120ICEBERG_REST_EXPORT Result<nlohmann::json> ToJson(
121 const FetchScanTasksResponse& response,
122 const std::unordered_map<int32_t, std::shared_ptr<PartitionSpec>>&
123 partition_specs_by_id,
124 const Schema& schema);
126ICEBERG_REST_EXPORT Result<PlanTableScanRequest> PlanTableScanRequestFromJson(
127 const nlohmann::json& json);
129ICEBERG_REST_EXPORT Result<PlanTableScanRequest> FromJson(
const nlohmann::json& json);
130ICEBERG_REST_EXPORT Result<nlohmann::json> ToJson(
const PlanTableScanRequest& request);
132ICEBERG_REST_EXPORT Result<FetchScanTasksRequest> FetchScanTasksRequestFromJson(
133 const nlohmann::json& json);
135ICEBERG_REST_EXPORT Result<FetchScanTasksRequest> FromJson(
const nlohmann::json& json);
136ICEBERG_REST_EXPORT nlohmann::json ToJson(
const FetchScanTasksRequest& request);
138ICEBERG_REST_EXPORT Result<nlohmann::json> ToJson(
140 const std::unordered_map<int32_t, std::shared_ptr<PartitionSpec>>&
141 partition_specs_by_id,
142 const Schema& schema);
144ICEBERG_REST_EXPORT Result<DataFile> DataFileFromJson(
145 const nlohmann::json& json,
146 const std::unordered_map<int32_t, std::shared_ptr<PartitionSpec>>&
147 partition_spec_by_id,
148 const Schema& schema);
150ICEBERG_REST_EXPORT Result<std::vector<std::shared_ptr<FileScanTask>>>
151FileScanTasksFromJson(
const nlohmann::json& json,
152 const std::vector<std::shared_ptr<DataFile>>& delete_files,
153 const std::unordered_map<int32_t, std::shared_ptr<PartitionSpec>>&
154 partition_spec_by_id,
155 const Schema& schema);