Skip to content

Commit fa9c60f

Browse files
committed
fix1
1 parent ad51137 commit fa9c60f

14 files changed

Lines changed: 84 additions & 103 deletions

src/iceberg/catalog/rest/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
# under the License.
1717

1818
set(ICEBERG_REST_SOURCES
19-
catalog.cc
20-
json_internal.cc
21-
config.cc
19+
rest_catalog.cc
20+
catalog_properties.cc
2221
http_client.cc
22+
json_internal.cc
2323
resource_paths.cc)
2424

2525
set(ICEBERG_REST_STATIC_BUILD_INTERFACE_LIBS)

src/iceberg/catalog/rest/config.cc renamed to src/iceberg/catalog/rest/catalog_properties.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
* under the License.
1818
*/
1919

20-
#include "iceberg/catalog/rest/config.h"
20+
#include "iceberg/catalog/rest/catalog_properties.h"
2121

2222
#include "iceberg/catalog/rest/constant.h"
2323

2424
namespace iceberg::rest {
2525

26-
std::unique_ptr<RestCatalogConfig> RestCatalogConfig::DefaultProperties() {
26+
std::unique_ptr<RestCatalogConfig> RestCatalogConfig::default_properties() {
2727
return std::make_unique<RestCatalogConfig>();
2828
}
2929

src/iceberg/catalog/rest/config.h renamed to src/iceberg/catalog/rest/catalog_properties.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "iceberg/catalog/rest/iceberg_rest_export.h"
3030
#include "iceberg/util/config.h"
3131

32-
/// \file iceberg/catalog/rest/config.h
32+
/// \file iceberg/catalog/rest/catalog_properties.h
3333
/// \brief RestCatalogConfig implementation for Iceberg REST API.
3434

3535
namespace iceberg::rest {
@@ -50,7 +50,7 @@ class ICEBERG_REST_EXPORT RestCatalogConfig : public ConfigBase<RestCatalogConfi
5050
inline static std::string_view kWarehouse{"warehouse"};
5151

5252
/// \brief Create a default RestCatalogConfig instance.
53-
static std::unique_ptr<RestCatalogConfig> DefaultProperties();
53+
static std::unique_ptr<RestCatalogConfig> default_properties();
5454

5555
/// \brief Create a RestCatalogConfig instance from a map of key-value pairs.
5656
static std::unique_ptr<RestCatalogConfig> FromMap(

src/iceberg/catalog/rest/error_handlers.h

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -54,27 +54,22 @@ class ICEBERG_REST_EXPORT DefaultErrorHandler : public ErrorHandler {
5454
return InvalidArgument("{}", error.message);
5555
}
5656
return BadRequest("Malformed request: {}", error.message);
57-
5857
case 401:
5958
return NotAuthorized("Not authorized: {}", error.message);
60-
6159
case 403:
6260
return Forbidden("Forbidden: {}", error.message);
63-
6461
case 405:
6562
case 406:
6663
break;
67-
6864
case 500:
69-
return ServiceFailure("Server error: {}: {}", error.type, error.message);
70-
65+
return InternalServerError("Server error: {}: {}", error.type, error.message);
7166
case 501:
7267
return NotSupported("{}", error.message);
73-
7468
case 503:
7569
return ServiceUnavailable("Service unavailable: {}", error.message);
7670
}
77-
return RESTError("Unable to process: {}", error.message);
71+
72+
return RestError("Unable to process: {}", error.message);
7873
}
7974
};
8075

@@ -88,15 +83,12 @@ class ICEBERG_REST_EXPORT NamespaceErrorHandler : public DefaultErrorHandler {
8883
return NamespaceNotEmpty("{}", error.message);
8984
}
9085
return BadRequest("Malformed request: {}", error.message);
91-
9286
case 404:
9387
return NoSuchNamespace("{}", error.message);
94-
9588
case 409:
9689
return AlreadyExists("{}", error.message);
97-
9890
case 422:
99-
return RESTError("Unable to process: {}", error.message);
91+
return RestError("Unable to process: {}", error.message);
10092
}
10193

10294
return DefaultErrorHandler::Accept(error);
@@ -111,7 +103,6 @@ class ICEBERG_REST_EXPORT DropNamespaceErrorHandler : public NamespaceErrorHandl
111103
return NamespaceNotEmpty("{}", error.message);
112104
}
113105

114-
// Delegate to parent handler
115106
return NamespaceErrorHandler::Accept(error);
116107
}
117108
};
@@ -126,7 +117,6 @@ class ICEBERG_REST_EXPORT TableErrorHandler : public DefaultErrorHandler {
126117
return NoSuchNamespace("{}", error.message);
127118
}
128119
return NoSuchTable("{}", error.message);
129-
130120
case 409:
131121
return AlreadyExists("{}", error.message);
132122
}
@@ -136,9 +126,6 @@ class ICEBERG_REST_EXPORT TableErrorHandler : public DefaultErrorHandler {
136126
};
137127

138128
/// \brief View-level error handler.
139-
///
140-
/// Handles view-specific errors including NoSuchView, NoSuchNamespace,
141-
/// and AlreadyExists scenarios.
142129
class ICEBERG_REST_EXPORT ViewErrorHandler : public DefaultErrorHandler {
143130
public:
144131
Status Accept(const ErrorModel& error) const override {
@@ -148,7 +135,6 @@ class ICEBERG_REST_EXPORT ViewErrorHandler : public DefaultErrorHandler {
148135
return NoSuchNamespace("{}", error.message);
149136
}
150137
return NoSuchView("{}", error.message);
151-
152138
case 409:
153139
return AlreadyExists("{}", error.message);
154140
}
@@ -164,10 +150,8 @@ class ICEBERG_REST_EXPORT TableCommitErrorHandler : public DefaultErrorHandler {
164150
switch (error.code) {
165151
case 404:
166152
return NoSuchTable("{}", error.message);
167-
168153
case 409:
169154
return CommitFailed("Commit failed: {}", error.message);
170-
171155
case 500:
172156
case 502:
173157
case 503:
@@ -186,10 +170,8 @@ class ICEBERG_REST_EXPORT ViewCommitErrorHandler : public DefaultErrorHandler {
186170
switch (error.code) {
187171
case 404:
188172
return NoSuchView("{}", error.message);
189-
190173
case 409:
191174
return CommitFailed("Commit failed: {}", error.message);
192-
193175
case 500:
194176
case 502:
195177
case 503:

src/iceberg/catalog/rest/http_client.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#include "cpr/body.h"
2525
#include "cpr/cprtypes.h"
26-
#include "iceberg/catalog/rest/config.h"
26+
#include "iceberg/catalog/rest/catalog_properties.h"
2727
#include "iceberg/catalog/rest/json_internal.h"
2828
#include "iceberg/json_internal.h"
2929
#include "iceberg/util/macros.h"

src/iceberg/catalog/rest/http_client.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include <cpr/cpr.h>
2828
#include <nlohmann/json.hpp>
2929

30-
#include "iceberg/catalog/rest/config.h"
30+
#include "iceberg/catalog/rest/catalog_properties.h"
3131
#include "iceberg/catalog/rest/error_handlers.h"
3232
#include "iceberg/catalog/rest/http_response.h"
3333
#include "iceberg/catalog/rest/iceberg_rest_export.h"

src/iceberg/catalog/rest/meson.build

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
# under the License.
1717

1818
iceberg_rest_sources = files(
19-
'catalog.cc',
20-
'config.cc',
19+
'catalog_properties.cc',
2120
'http_client.cc',
2221
'json_internal.cc',
2322
'resource_paths.cc',
23+
'rest_catalog.cc',
2424
)
2525
# cpr does not export symbols, so on Windows it must
2626
# be used as a static lib
@@ -54,16 +54,16 @@ pkg.generate(iceberg_rest_lib)
5454

5555
install_headers(
5656
[
57-
'catalog.h',
58-
'config.h',
57+
'rest_catalog.h',
58+
'catalog_properties.h',
5959
'constant.h',
6060
'http_client.h',
6161
'http_response.h',
6262
'json_internal.h',
6363
'iceberg_rest_export.h',
6464
'types.h',
6565
'resource_paths.h',
66-
'endpoint_util.h',
66+
'rest_util.h',
6767
'error_handlers.h',
6868
],
6969
subdir: 'iceberg/catalog/rest',

src/iceberg/catalog/rest/resource_paths.cc

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
#include <format>
2323

24-
#include "iceberg/catalog/rest/config.h"
25-
#include "iceberg/catalog/rest/endpoint_util.h"
24+
#include "iceberg/catalog/rest/catalog_properties.h"
25+
#include "iceberg/catalog/rest/rest_util.h"
2626
#include "iceberg/result.h"
2727

2828
namespace iceberg::rest {
@@ -50,84 +50,82 @@ ResourcePaths::ResourcePaths(std::string base_uri, std::string prefix)
5050
: base_uri_(std::move(base_uri)), prefix_(std::move(prefix)) {}
5151

5252
std::string ResourcePaths::BuildPath(std::string_view path) const {
53-
if (prefix_.empty()) {
54-
return std::format("{}/v1/{}", base_uri_, path);
55-
}
56-
return std::format("{}/v1/{}/{}", base_uri_, prefix_, path);
53+
return std::format("{}/v1/{}{}", base_uri_, (prefix_.empty() ? "" : (prefix_ + "/")),
54+
path);
5755
}
5856

59-
std::string ResourcePaths::V1Config() const {
57+
std::string ResourcePaths::Config() const {
6058
return std::format("{}/v1/config", base_uri_);
6159
}
6260

63-
std::string ResourcePaths::V1OAuth2Tokens() const {
61+
std::string ResourcePaths::OAuth2Tokens() const {
6462
return std::format("{}/v1/oauth/tokens", base_uri_);
6563
}
6664

67-
std::string ResourcePaths::V1Namespaces() const { return BuildPath("namespaces"); }
65+
std::string ResourcePaths::Namespaces() const { return BuildPath("namespaces"); }
6866

69-
std::string ResourcePaths::V1Namespace(const Namespace& ns) const {
67+
std::string ResourcePaths::Namespace_(const Namespace& ns) const {
7068
return BuildPath(std::format("namespaces/{}", EncodeNamespaceForUrl(ns)));
7169
}
7270

73-
std::string ResourcePaths::V1NamespaceProperties(const Namespace& ns) const {
71+
std::string ResourcePaths::NamespaceProperties(const Namespace& ns) const {
7472
return BuildPath(std::format("namespaces/{}/properties", EncodeNamespaceForUrl(ns)));
7573
}
7674

77-
std::string ResourcePaths::V1Tables(const Namespace& ns) const {
75+
std::string ResourcePaths::Tables(const Namespace& ns) const {
7876
return BuildPath(std::format("namespaces/{}/tables", EncodeNamespaceForUrl(ns)));
7977
}
8078

81-
std::string ResourcePaths::V1Table(const TableIdentifier& table) const {
82-
return BuildPath(std::format("namespaces/{}/tables/{}", EncodeNamespaceForUrl(table.ns),
83-
table.name));
79+
std::string ResourcePaths::Table(const TableIdentifier& ident) const {
80+
return BuildPath(std::format("namespaces/{}/tables/{}", EncodeNamespaceForUrl(ident.ns),
81+
ident.name));
8482
}
8583

86-
std::string ResourcePaths::V1RegisterTable(const Namespace& ns) const {
84+
std::string ResourcePaths::Register(const Namespace& ns) const {
8785
return BuildPath(std::format("namespaces/{}/register", EncodeNamespaceForUrl(ns)));
8886
}
8987

90-
std::string ResourcePaths::V1RenameTable() const { return BuildPath("tables/rename"); }
88+
std::string ResourcePaths::Rename() const { return BuildPath("tables/rename"); }
9189

92-
std::string ResourcePaths::V1TableMetrics(const TableIdentifier& table) const {
90+
std::string ResourcePaths::Metrics(const TableIdentifier& ident) const {
9391
return BuildPath(std::format("namespaces/{}/tables/{}/metrics",
94-
EncodeNamespaceForUrl(table.ns), table.name));
92+
EncodeNamespaceForUrl(ident.ns), ident.name));
9593
}
9694

97-
std::string ResourcePaths::V1TableCredentials(const TableIdentifier& table) const {
95+
std::string ResourcePaths::Credentials(const TableIdentifier& ident) const {
9896
return BuildPath(std::format("namespaces/{}/tables/{}/credentials",
99-
EncodeNamespaceForUrl(table.ns), table.name));
97+
EncodeNamespaceForUrl(ident.ns), ident.name));
10098
}
10199

102-
std::string ResourcePaths::V1TableScanPlan(const TableIdentifier& table) const {
100+
std::string ResourcePaths::ScanPlan(const TableIdentifier& ident) const {
103101
return BuildPath(std::format("namespaces/{}/tables/{}/plan",
104-
EncodeNamespaceForUrl(table.ns), table.name));
102+
EncodeNamespaceForUrl(ident.ns), ident.name));
105103
}
106104

107-
std::string ResourcePaths::V1TableScanPlanResult(const TableIdentifier& table,
108-
const std::string& plan_id) const {
105+
std::string ResourcePaths::ScanPlanResult(const TableIdentifier& ident,
106+
const std::string& plan_id) const {
109107
return BuildPath(std::format("namespaces/{}/tables/{}/plan/{}",
110-
EncodeNamespaceForUrl(table.ns), table.name, plan_id));
108+
EncodeNamespaceForUrl(ident.ns), ident.name, plan_id));
111109
}
112110

113-
std::string ResourcePaths::V1TableTasks(const TableIdentifier& table) const {
111+
std::string ResourcePaths::Tasks(const TableIdentifier& ident) const {
114112
return BuildPath(std::format("namespaces/{}/tables/{}/tasks",
115-
EncodeNamespaceForUrl(table.ns), table.name));
113+
EncodeNamespaceForUrl(ident.ns), ident.name));
116114
}
117115

118-
std::string ResourcePaths::V1TransactionCommit() const {
116+
std::string ResourcePaths::CommitTransaction() const {
119117
return BuildPath("transactions/commit");
120118
}
121119

122-
std::string ResourcePaths::V1Views(const Namespace& ns) const {
120+
std::string ResourcePaths::Views(const Namespace& ns) const {
123121
return BuildPath(std::format("namespaces/{}/views", EncodeNamespaceForUrl(ns)));
124122
}
125123

126-
std::string ResourcePaths::V1View(const TableIdentifier& view) const {
124+
std::string ResourcePaths::View(const TableIdentifier& ident) const {
127125
return BuildPath(
128-
std::format("namespaces/{}/views/{}", EncodeNamespaceForUrl(view.ns), view.name));
126+
std::format("namespaces/{}/views/{}", EncodeNamespaceForUrl(ident.ns), ident.name));
129127
}
130128

131-
std::string ResourcePaths::V1RenameView() const { return BuildPath("views/rename"); }
129+
std::string ResourcePaths::RenameView() const { return BuildPath("views/rename"); }
132130

133131
} // namespace iceberg::rest

0 commit comments

Comments
 (0)