|
21 | 21 |
|
22 | 22 | #include <format> |
23 | 23 |
|
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" |
26 | 26 | #include "iceberg/result.h" |
27 | 27 |
|
28 | 28 | namespace iceberg::rest { |
@@ -50,84 +50,82 @@ ResourcePaths::ResourcePaths(std::string base_uri, std::string prefix) |
50 | 50 | : base_uri_(std::move(base_uri)), prefix_(std::move(prefix)) {} |
51 | 51 |
|
52 | 52 | 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); |
57 | 55 | } |
58 | 56 |
|
59 | | -std::string ResourcePaths::V1Config() const { |
| 57 | +std::string ResourcePaths::Config() const { |
60 | 58 | return std::format("{}/v1/config", base_uri_); |
61 | 59 | } |
62 | 60 |
|
63 | | -std::string ResourcePaths::V1OAuth2Tokens() const { |
| 61 | +std::string ResourcePaths::OAuth2Tokens() const { |
64 | 62 | return std::format("{}/v1/oauth/tokens", base_uri_); |
65 | 63 | } |
66 | 64 |
|
67 | | -std::string ResourcePaths::V1Namespaces() const { return BuildPath("namespaces"); } |
| 65 | +std::string ResourcePaths::Namespaces() const { return BuildPath("namespaces"); } |
68 | 66 |
|
69 | | -std::string ResourcePaths::V1Namespace(const Namespace& ns) const { |
| 67 | +std::string ResourcePaths::Namespace_(const Namespace& ns) const { |
70 | 68 | return BuildPath(std::format("namespaces/{}", EncodeNamespaceForUrl(ns))); |
71 | 69 | } |
72 | 70 |
|
73 | | -std::string ResourcePaths::V1NamespaceProperties(const Namespace& ns) const { |
| 71 | +std::string ResourcePaths::NamespaceProperties(const Namespace& ns) const { |
74 | 72 | return BuildPath(std::format("namespaces/{}/properties", EncodeNamespaceForUrl(ns))); |
75 | 73 | } |
76 | 74 |
|
77 | | -std::string ResourcePaths::V1Tables(const Namespace& ns) const { |
| 75 | +std::string ResourcePaths::Tables(const Namespace& ns) const { |
78 | 76 | return BuildPath(std::format("namespaces/{}/tables", EncodeNamespaceForUrl(ns))); |
79 | 77 | } |
80 | 78 |
|
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)); |
84 | 82 | } |
85 | 83 |
|
86 | | -std::string ResourcePaths::V1RegisterTable(const Namespace& ns) const { |
| 84 | +std::string ResourcePaths::Register(const Namespace& ns) const { |
87 | 85 | return BuildPath(std::format("namespaces/{}/register", EncodeNamespaceForUrl(ns))); |
88 | 86 | } |
89 | 87 |
|
90 | | -std::string ResourcePaths::V1RenameTable() const { return BuildPath("tables/rename"); } |
| 88 | +std::string ResourcePaths::Rename() const { return BuildPath("tables/rename"); } |
91 | 89 |
|
92 | | -std::string ResourcePaths::V1TableMetrics(const TableIdentifier& table) const { |
| 90 | +std::string ResourcePaths::Metrics(const TableIdentifier& ident) const { |
93 | 91 | return BuildPath(std::format("namespaces/{}/tables/{}/metrics", |
94 | | - EncodeNamespaceForUrl(table.ns), table.name)); |
| 92 | + EncodeNamespaceForUrl(ident.ns), ident.name)); |
95 | 93 | } |
96 | 94 |
|
97 | | -std::string ResourcePaths::V1TableCredentials(const TableIdentifier& table) const { |
| 95 | +std::string ResourcePaths::Credentials(const TableIdentifier& ident) const { |
98 | 96 | return BuildPath(std::format("namespaces/{}/tables/{}/credentials", |
99 | | - EncodeNamespaceForUrl(table.ns), table.name)); |
| 97 | + EncodeNamespaceForUrl(ident.ns), ident.name)); |
100 | 98 | } |
101 | 99 |
|
102 | | -std::string ResourcePaths::V1TableScanPlan(const TableIdentifier& table) const { |
| 100 | +std::string ResourcePaths::ScanPlan(const TableIdentifier& ident) const { |
103 | 101 | return BuildPath(std::format("namespaces/{}/tables/{}/plan", |
104 | | - EncodeNamespaceForUrl(table.ns), table.name)); |
| 102 | + EncodeNamespaceForUrl(ident.ns), ident.name)); |
105 | 103 | } |
106 | 104 |
|
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 { |
109 | 107 | return BuildPath(std::format("namespaces/{}/tables/{}/plan/{}", |
110 | | - EncodeNamespaceForUrl(table.ns), table.name, plan_id)); |
| 108 | + EncodeNamespaceForUrl(ident.ns), ident.name, plan_id)); |
111 | 109 | } |
112 | 110 |
|
113 | | -std::string ResourcePaths::V1TableTasks(const TableIdentifier& table) const { |
| 111 | +std::string ResourcePaths::Tasks(const TableIdentifier& ident) const { |
114 | 112 | return BuildPath(std::format("namespaces/{}/tables/{}/tasks", |
115 | | - EncodeNamespaceForUrl(table.ns), table.name)); |
| 113 | + EncodeNamespaceForUrl(ident.ns), ident.name)); |
116 | 114 | } |
117 | 115 |
|
118 | | -std::string ResourcePaths::V1TransactionCommit() const { |
| 116 | +std::string ResourcePaths::CommitTransaction() const { |
119 | 117 | return BuildPath("transactions/commit"); |
120 | 118 | } |
121 | 119 |
|
122 | | -std::string ResourcePaths::V1Views(const Namespace& ns) const { |
| 120 | +std::string ResourcePaths::Views(const Namespace& ns) const { |
123 | 121 | return BuildPath(std::format("namespaces/{}/views", EncodeNamespaceForUrl(ns))); |
124 | 122 | } |
125 | 123 |
|
126 | | -std::string ResourcePaths::V1View(const TableIdentifier& view) const { |
| 124 | +std::string ResourcePaths::View(const TableIdentifier& ident) const { |
127 | 125 | return BuildPath( |
128 | | - std::format("namespaces/{}/views/{}", EncodeNamespaceForUrl(view.ns), view.name)); |
| 126 | + std::format("namespaces/{}/views/{}", EncodeNamespaceForUrl(ident.ns), ident.name)); |
129 | 127 | } |
130 | 128 |
|
131 | | -std::string ResourcePaths::V1RenameView() const { return BuildPath("views/rename"); } |
| 129 | +std::string ResourcePaths::RenameView() const { return BuildPath("views/rename"); } |
132 | 130 |
|
133 | 131 | } // namespace iceberg::rest |
0 commit comments