Skip to content

Commit 27474b9

Browse files
committed
fix review
1 parent 3b22745 commit 27474b9

File tree

4 files changed

+49
-107
lines changed

4 files changed

+49
-107
lines changed

src/iceberg/catalog/rest/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ iceberg_rest_dep = declare_dependency(
4646
meson.override_dependency('iceberg-rest', iceberg_rest_dep)
4747
pkg.generate(iceberg_rest_lib)
4848

49-
install_headers(['rest_catalog.h'], subdir: 'iceberg/catalog/rest')
49+
install_headers(['rest_catalog.h', 'types.h'], subdir: 'iceberg/catalog/rest')

src/iceberg/catalog/rest/request_types.h

Lines changed: 0 additions & 88 deletions
This file was deleted.

src/iceberg/catalog/rest/rest_catalog.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
#include <cpr/cpr.h>
2525

26+
#include "iceberg/catalog/rest/types.h"
27+
2628
namespace iceberg::catalog::rest {
2729

2830
RestCatalog::RestCatalog(const std::string& base_url) : base_url_(std::move(base_url)) {}

src/iceberg/catalog/rest/response_types.h renamed to src/iceberg/catalog/rest/types.h

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,68 @@
1919

2020
#pragma once
2121

22+
#include <memory>
2223
#include <optional>
2324
#include <string>
2425
#include <unordered_map>
2526
#include <vector>
2627

2728
#include "iceberg/catalog/rest/iceberg_rest_export.h"
2829
#include "iceberg/table_identifier.h"
29-
#include "iceberg/table_metadata.h"
30+
#include "iceberg/type_fwd.h"
3031

31-
/// \file iceberg/catalog/rest/response_types.h
32-
/// Defines all response body structures for the Iceberg REST Catalog API,
33-
/// representing the JSON results returned by /v1 endpoints (excluding HTTP headers like
34-
/// ETag).
32+
/// \file iceberg/catalog/rest/types.h
33+
/// Request and response types for Iceberg REST Catalog API.
3534

3635
namespace iceberg::rest {
3736

37+
// Request Types
38+
39+
/// \brief Request to create a namespace.
40+
struct ICEBERG_REST_EXPORT CreateNamespaceRequest {
41+
Namespace namespace_; // required
42+
std::unordered_map<std::string, std::string> properties;
43+
};
44+
45+
/// \brief Update or delete namespace properties request.
46+
struct ICEBERG_REST_EXPORT UpdateNamespacePropertiesRequest {
47+
std::vector<std::string> removals;
48+
std::unordered_map<std::string, std::string> updates;
49+
};
50+
51+
/// \brief Request to create a table.
52+
struct ICEBERG_REST_EXPORT CreateTableRequest {
53+
std::string name; // required
54+
std::string location;
55+
std::shared_ptr<Schema> schema; // required
56+
std::shared_ptr<PartitionSpec> partition_spec;
57+
std::shared_ptr<SortOrder> write_order;
58+
std::optional<bool> stage_create;
59+
std::unordered_map<std::string, std::string> properties;
60+
};
61+
62+
/// \brief Request to register a table.
63+
struct ICEBERG_REST_EXPORT RegisterTableRequest {
64+
std::string name; // required
65+
std::string metadata_location; // required
66+
bool overwrite = false;
67+
};
68+
69+
/// \brief Request to rename a table.
70+
struct ICEBERG_REST_EXPORT RenameTableRequest {
71+
TableIdentifier source; // required
72+
TableIdentifier destination; // required
73+
};
74+
3875
/// \brief An opaque token that allows clients to make use of pagination for list APIs.
3976
using PageToken = std::string;
4077

4178
/// \brief Result body for table create/load/register APIs.
42-
/// \details Matches **components/schemas/LoadTableResult** in the REST spec.
4379
struct ICEBERG_REST_EXPORT LoadTableResult {
4480
std::optional<std::string> metadata_location;
45-
TableMetadata metadata; // required
81+
std::shared_ptr<TableMetadata> metadata; // required // required
4682
std::unordered_map<std::string, std::string> config;
47-
// TODO(Li Feiyang): Add std::vector<StorageCredential> storage_credentials;
83+
// TODO(Li Feiyang): Add std::shared_ptr<StorageCredential> storage_credential;
4884
};
4985

5086
/// \brief Alias of LoadTableResult used as the body of CreateTableResponse
@@ -53,42 +89,34 @@ using CreateTableResponse = LoadTableResult;
5389
/// \brief Alias of LoadTableResult used as the body of LoadTableResponse
5490
using LoadTableResponse = LoadTableResult;
5591

56-
/// \brief Alias of LoadTableResult used as the body of RegisterTableResponse
57-
using RegisterTableResponse = LoadTableResult;
58-
5992
/// \brief Response body for listing namespaces.
60-
/// Contains all namespaces and an optional pagination token.
6193
struct ICEBERG_REST_EXPORT ListNamespacesResponse {
62-
std::optional<PageToken> next_page_token;
94+
PageToken next_page_token;
6395
std::vector<Namespace> namespaces;
6496
};
6597

6698
/// \brief Response body after creating a namespace.
67-
/// \details Contains the created namespace and its resolved properties.
6899
struct ICEBERG_REST_EXPORT CreateNamespaceResponse {
69100
Namespace namespace_; // required
70101
std::unordered_map<std::string, std::string> properties;
71102
};
72103

73104
/// \brief Response body for loading namespace properties.
74-
/// \details Contains stored properties, may be null if unsupported by the server.
75105
struct ICEBERG_REST_EXPORT GetNamespaceResponse {
76106
Namespace namespace_; // required
77107
std::unordered_map<std::string, std::string> properties;
78108
};
79109

80110
/// \brief Response body after updating namespace properties.
81-
/// \details Lists keys that were updated, removed, or missing.
82111
struct ICEBERG_REST_EXPORT UpdateNamespacePropertiesResponse {
83112
std::vector<std::string> updated; // required
84113
std::vector<std::string> removed; // required
85114
std::vector<std::string> missing;
86115
};
87116

88117
/// \brief Response body for listing tables in a namespace.
89-
/// \details Contains all table identifiers and an optional pagination token.
90118
struct ICEBERG_REST_EXPORT ListTablesResponse {
91-
std::optional<PageToken> next_page_token;
119+
PageToken next_page_token;
92120
std::vector<TableIdentifier> identifiers;
93121
};
94122

0 commit comments

Comments
 (0)