2222#include < memory>
2323#include < string>
2424
25- #include < cpr/cpr.h>
26-
2725#include " iceberg/catalog.h"
2826#include " iceberg/catalog/rest/config.h"
2927#include " iceberg/catalog/rest/http_client_interal.h"
3028#include " iceberg/catalog/rest/iceberg_rest_export.h"
31- #include " iceberg/catalog/rest/types .h"
29+ #include " iceberg/catalog/rest/resource_paths .h"
3230#include " iceberg/result.h"
3331
3432// / \file iceberg/catalog/rest/catalog.h
@@ -40,126 +38,73 @@ class ICEBERG_REST_EXPORT RestCatalog : public Catalog {
4038 public:
4139 RestCatalog (const RestCatalog&) = delete ;
4240 RestCatalog& operator =(const RestCatalog&) = delete ;
43- RestCatalog (RestCatalog&&) = default ;
44- RestCatalog& operator =(RestCatalog&&) = default ;
41+ RestCatalog (RestCatalog&&) = delete ;
42+ RestCatalog& operator =(RestCatalog&&) = delete ;
4543
4644 // / \brief Create a RestCatalog instance
4745 // /
4846 // / \param config the configuration for the RestCatalog
49- // / \return a RestCatalog instance
50- static Result<RestCatalog> Make (RestCatalogConfig config);
47+ // / \return a unique_ptr to RestCatalog instance
48+ static Result<std::unique_ptr< RestCatalog>> Make (const RestCatalogConfig& config);
5149
52- // / \brief Return the name for this catalog
5350 std::string_view name () const override ;
5451
55- // / \brief List child namespaces from the given namespace.
5652 Result<std::vector<Namespace>> ListNamespaces (const Namespace& ns) const override ;
5753
58- // / \brief Create a namespace with associated properties.
5954 Status CreateNamespace (
6055 const Namespace& ns,
6156 const std::unordered_map<std::string, std::string>& properties) override ;
6257
63- // / \brief Get metadata properties for a namespace.
6458 Result<std::unordered_map<std::string, std::string>> GetNamespaceProperties (
6559 const Namespace& ns) const override ;
6660
67- // / \brief Drop a namespace.
6861 Status DropNamespace (const Namespace& ns) override ;
6962
70- // / \brief Check whether the namespace exists.
7163 Result<bool > NamespaceExists (const Namespace& ns) const override ;
7264
73- // / \brief Update a namespace's properties by applying additions and removals.
7465 Status UpdateNamespaceProperties (
7566 const Namespace& ns, const std::unordered_map<std::string, std::string>& updates,
7667 const std::unordered_set<std::string>& removals) override ;
7768
78- // / \brief Return all the identifiers under this namespace
7969 Result<std::vector<TableIdentifier>> ListTables (const Namespace& ns) const override ;
8070
81- // / \brief Create a table
8271 Result<std::unique_ptr<Table>> CreateTable (
8372 const TableIdentifier& identifier, const Schema& schema, const PartitionSpec& spec,
8473 const std::string& location,
8574 const std::unordered_map<std::string, std::string>& properties) override ;
8675
87- // / \brief Update a table
88- // /
89- // / \param identifier a table identifier
90- // / \param requirements a list of table requirements
91- // / \param updates a list of table updates
92- // / \return a Table instance or ErrorKind::kAlreadyExists if the table already exists
9376 Result<std::unique_ptr<Table>> UpdateTable (
9477 const TableIdentifier& identifier,
9578 const std::vector<std::unique_ptr<TableRequirement>>& requirements,
9679 const std::vector<std::unique_ptr<TableUpdate>>& updates) override ;
9780
98- // / \brief Start a transaction to create a table
99- // /
100- // / \param identifier a table identifier
101- // / \param schema a schema
102- // / \param spec a partition spec
103- // / \param location a location for the table; leave empty if unspecified
104- // / \param properties a string map of table properties
105- // / \return a Transaction to create the table or ErrorKind::kAlreadyExists if the
106- // / table already exists
10781 Result<std::shared_ptr<Transaction>> StageCreateTable (
10882 const TableIdentifier& identifier, const Schema& schema, const PartitionSpec& spec,
10983 const std::string& location,
11084 const std::unordered_map<std::string, std::string>& properties) override ;
11185
112- // / \brief Check whether table exists
113- // /
114- // / \param identifier a table identifier
115- // / \return Result<bool> indicating table exists or not.
116- // / - On success, the table existence was successfully checked (actual
117- // / existence may be inferred elsewhere).
118- // / - On failure, contains error information.
11986 Result<bool > TableExists (const TableIdentifier& identifier) const override ;
12087
121- // / \brief Drop a table; optionally delete data and metadata files
122- // /
123- // / If purge is set to true the implementation should delete all data and metadata
124- // / files.
125- // /
126- // / \param identifier a table identifier
127- // / \param purge if true, delete all data and metadata files in the table
128- // / \return Status indicating the outcome of the operation.
129- // / - On success, the table was dropped (or did not exist).
130- // / - On failure, contains error information.
88+ Status RenameTable (const TableIdentifier& from, const TableIdentifier& to) override ;
89+
13190 Status DropTable (const TableIdentifier& identifier, bool purge) override ;
13291
133- // / \brief Load a table
134- // /
135- // / \param identifier a table identifier
136- // / \return instance of Table implementation referred to by identifier or
137- // / ErrorKind::kNoSuchTable if the table does not exist
13892 Result<std::unique_ptr<Table>> LoadTable (const TableIdentifier& identifier) override ;
13993
140- // / \brief Register a table with the catalog if it does not exist
141- // /
142- // / \param identifier a table identifier
143- // / \param metadata_file_location the location of a metadata file
144- // / \return a Table instance or ErrorKind::kAlreadyExists if the table already exists
14594 Result<std::shared_ptr<Table>> RegisterTable (
14695 const TableIdentifier& identifier,
14796 const std::string& metadata_file_location) override ;
14897
149- // / \brief A builder used to create valid tables or start create/replace transactions
150- // /
151- // / \param identifier a table identifier
152- // / \param schema a schema
153- // / \return the builder to create a table or start a create/replace transaction
15498 std::unique_ptr<RestCatalog::TableBuilder> BuildTable (
15599 const TableIdentifier& identifier, const Schema& schema) const override ;
156100
157101 private:
158- RestCatalog (std::shared_ptr <RestCatalogConfig> config,
159- std::unique_ptr<HttpClient> client);
102+ RestCatalog (std::unique_ptr <RestCatalogConfig> config,
103+ std::unique_ptr<HttpClient> client, ResourcePaths paths );
160104
161- std::shared_ptr <RestCatalogConfig> config_;
105+ std::unique_ptr <RestCatalogConfig> config_;
162106 std::unique_ptr<HttpClient> client_;
107+ ResourcePaths paths_;
163108};
164109
165110} // namespace iceberg::rest
0 commit comments