27#include <unordered_map>
31#include "iceberg/catalog/rest/iceberg_rest_export.h"
32#include "iceberg/result.h"
33#include "iceberg/storage_credential.h"
36#include "iceberg/util/macros.h"
41namespace iceberg::rest {
51ICEBERG_REST_EXPORT std::string_view ToString(PlanStatus status);
52ICEBERG_REST_EXPORT Result<PlanStatus> PlanStatusFromString(std::string_view status_str);
56 std::unordered_map<std::string, std::string> defaults;
57 std::unordered_map<std::string, std::string> overrides;
58 std::vector<Endpoint> endpoints;
71 std::vector<std::string> stack;
75 if (message.empty() || type.empty()) {
76 return ValidationFailed(
"Invalid error response: missing required fields");
79 if (code < 400 || code > 600) {
80 return ValidationFailed(
81 "Invalid error response: code {} is out of range [400, 600]", code);
94 std::unordered_map<std::string, std::string> properties;
104 std::vector<std::string> removals;
105 std::unordered_map<std::string, std::string> updates;
109 for (
const auto& key : removals) {
110 if (updates.contains(key)) {
111 return ValidationFailed(
"Duplicate key to update and remove: {}", key);
123 std::string metadata_location;
124 bool overwrite =
false;
129 return ValidationFailed(
"Missing table name");
132 if (metadata_location.empty()) {
133 return ValidationFailed(
"Empty metadata location");
149 ICEBERG_RETURN_UNEXPECTED(source.Validate());
150 ICEBERG_RETURN_UNEXPECTED(destination.
Validate());
160 std::string location;
161 std::shared_ptr<Schema> schema;
162 std::shared_ptr<PartitionSpec> partition_spec;
163 std::shared_ptr<SortOrder> write_order;
164 bool stage_create =
false;
165 std::unordered_map<std::string, std::string> properties;
170 return ValidationFailed(
"Missing table name");
173 return ValidationFailed(
"Missing schema");
186 std::string metadata_location;
187 std::shared_ptr<TableMetadata> metadata;
188 std::unordered_map<std::string, std::string> config;
195 return ValidationFailed(
"Invalid metadata: null");
197 for (
const auto& credential : storage_credentials) {
198 ICEBERG_RETURN_UNEXPECTED(credential.Validate());
215 std::vector<Namespace> namespaces;
226 std::unordered_map<std::string, std::string> properties;
237 std::unordered_map<std::string, std::string> properties;
247 std::vector<std::string> updated;
248 std::vector<std::string> removed;
249 std::vector<std::string> missing;
260 std::vector<TableIdentifier> identifiers;
271 std::vector<std::shared_ptr<TableRequirement>> requirements;
272 std::vector<std::shared_ptr<TableUpdate>> updates;
282 std::string metadata_location;
283 std::shared_ptr<TableMetadata> metadata;
287 if (metadata_location.empty()) {
288 return ValidationFailed(
"Invalid metadata location: empty");
291 return ValidationFailed(
"Invalid metadata: null");
301 std::string access_token;
302 std::string token_type;
303 std::optional<int64_t> expires_in_secs;
304 std::string issued_token_type;
305 std::string refresh_token;
309 Status Validate()
const;
316 std::optional<int64_t> snapshot_id;
317 std::vector<std::string> select;
318 std::shared_ptr<Expression> filter;
319 bool case_sensitive =
true;
320 bool use_snapshot_schema =
false;
321 std::optional<int64_t> start_snapshot_id;
322 std::optional<int64_t> end_snapshot_id;
323 std::vector<std::string> stats_fields;
324 std::optional<int64_t> min_rows_requested;
326 Status Validate()
const;
334 std::optional<std::vector<std::string>> plan_tasks;
335 std::optional<std::vector<std::shared_ptr<FileScanTask>>> file_scan_tasks;
336 std::vector<std::shared_ptr<DataFile>> delete_files;
337 PlanStatus plan_status = PlanStatus::kCompleted;
339 std::optional<ErrorResponse> error;
342 Status Validate()
const;
350 std::optional<std::vector<std::string>> plan_tasks;
351 std::optional<std::vector<std::shared_ptr<FileScanTask>>> file_scan_tasks;
352 std::vector<std::shared_ptr<DataFile>> delete_files;
353 PlanStatus plan_status = PlanStatus::kCompleted;
354 std::optional<ErrorResponse> error;
357 Status Validate()
const;
364 std::string planTask;
366 Status Validate()
const;
373 std::optional<std::vector<std::string>> plan_tasks;
374 std::optional<std::vector<std::shared_ptr<FileScanTask>>> file_scan_tasks;
375 std::vector<std::shared_ptr<DataFile>> delete_files;
377 Status Validate()
const;
A namespace in a catalog.
Definition table_identifier.h:35
Identifies a table in iceberg catalog.
Definition table_identifier.h:46
Status Validate() const
Validates the TableIdentifier.
Definition table_identifier.h:55
Server-provided configuration for the catalog.
Definition types.h:55
Status Validate() const
Validates the CatalogConfig.
Definition types.h:61
Request to commit changes to a table.
Definition types.h:269
Status Validate() const
Validates the CommitTableRequest.
Definition types.h:275
Response from committing changes to a table.
Definition types.h:281
Status Validate() const
Validates the CommitTableResponse.
Definition types.h:286
Request to create a namespace.
Definition types.h:92
Status Validate() const
Validates the CreateNamespaceRequest.
Definition types.h:97
Response body after creating a namespace.
Definition types.h:224
Status Validate() const
Validates the CreateNamespaceResponse.
Definition types.h:229
Request to create a table.
Definition types.h:158
Status Validate() const
Validates the CreateTableRequest.
Definition types.h:168
JSON error payload returned in a response with further details on the error.
Definition types.h:67
Status Validate() const
Validates the ErrorResponse.
Definition types.h:74
Response from polling an asynchronous scan plan, including current status and available scan tasks.
Definition types.h:349
Request to fetch the scan tasks for a given plan task token.
Definition types.h:363
Response containing the file scan tasks for a given plan task token.
Definition types.h:372
Response body for loading namespace properties.
Definition types.h:235
Status Validate() const
Validates the GetNamespaceResponse.
Definition types.h:240
Response body for listing namespaces.
Definition types.h:213
Status Validate() const
Validates the ListNamespacesResponse.
Definition types.h:218
Response body for listing tables in a namespace.
Definition types.h:258
Status Validate() const
Validates the ListTablesResponse.
Definition types.h:263
Result body for table create/load/register APIs.
Definition types.h:185
Status Validate() const
Validates the LoadTableResult.
Definition types.h:193
std::vector< StorageCredential > storage_credentials
Vended storage credentials, one per URI prefix; empty if none.
Definition types.h:190
Response from an OAuth2 token endpoint.
Definition types.h:300
Request to initiate a server-side scan planning operation.
Definition types.h:315
Response from initiating a scan planning operation, including plan status and initial scan tasks.
Definition types.h:333
Request to register a table.
Definition types.h:121
Status Validate() const
Validates the RegisterTableRequest.
Definition types.h:127
Update or delete namespace properties request.
Definition types.h:103
Status Validate() const
Validates the UpdateNamespacePropertiesRequest.
Definition types.h:108
Response body after updating namespace properties.
Definition types.h:246
Status Validate() const
Validates the UpdateNamespacePropertiesResponse.
Definition types.h:252
std::string PageToken
An opaque token that allows clients to make use of pagination for list APIs.
Definition types.h:182
PlanStatus
Status of a REST server-side scan planning operation.
Definition types.h:44