diff --git a/src/iceberg/catalog/rest/meson.build b/src/iceberg/catalog/rest/meson.build index 0c32cb625..9d8a7d384 100644 --- a/src/iceberg/catalog/rest/meson.build +++ b/src/iceberg/catalog/rest/meson.build @@ -46,4 +46,4 @@ iceberg_rest_dep = declare_dependency( meson.override_dependency('iceberg-rest', iceberg_rest_dep) pkg.generate(iceberg_rest_lib) -install_headers(['rest_catalog.h'], subdir: 'iceberg/catalog/rest') +install_headers(['rest_catalog.h', 'types.h'], subdir: 'iceberg/catalog/rest') diff --git a/src/iceberg/catalog/rest/rest_catalog.cc b/src/iceberg/catalog/rest/rest_catalog.cc index a9b18b5f9..cd008e9b2 100644 --- a/src/iceberg/catalog/rest/rest_catalog.cc +++ b/src/iceberg/catalog/rest/rest_catalog.cc @@ -23,6 +23,8 @@ #include +#include "iceberg/catalog/rest/types.h" + namespace iceberg::catalog::rest { RestCatalog::RestCatalog(const std::string& base_url) : base_url_(std::move(base_url)) {} diff --git a/src/iceberg/catalog/rest/types.h b/src/iceberg/catalog/rest/types.h new file mode 100644 index 000000000..4c50ab268 --- /dev/null +++ b/src/iceberg/catalog/rest/types.h @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include +#include +#include +#include +#include + +#include "iceberg/catalog/rest/iceberg_rest_export.h" +#include "iceberg/table_identifier.h" +#include "iceberg/type_fwd.h" + +/// \file iceberg/catalog/rest/types.h +/// Request and response types for Iceberg REST Catalog API. + +namespace iceberg::rest { + +/// \brief Request to create a namespace. +struct ICEBERG_REST_EXPORT CreateNamespaceRequest { + Namespace namespace_; // required + std::unordered_map properties; +}; + +/// \brief Update or delete namespace properties request. +struct ICEBERG_REST_EXPORT UpdateNamespacePropertiesRequest { + std::vector removals; + std::unordered_map updates; +}; + +/// \brief Request to create a table. +struct ICEBERG_REST_EXPORT CreateTableRequest { + std::string name; // required + std::string location; + std::shared_ptr schema; // required + std::shared_ptr partition_spec; + std::shared_ptr write_order; + std::optional stage_create; + std::unordered_map properties; +}; + +/// \brief Request to register a table. +struct ICEBERG_REST_EXPORT RegisterTableRequest { + std::string name; // required + std::string metadata_location; // required + bool overwrite = false; +}; + +/// \brief Request to rename a table. +struct ICEBERG_REST_EXPORT RenameTableRequest { + TableIdentifier source; // required + TableIdentifier destination; // required +}; + +/// \brief An opaque token that allows clients to make use of pagination for list APIs. +using PageToken = std::string; + +/// \brief Result body for table create/load/register APIs. +struct ICEBERG_REST_EXPORT LoadTableResult { + std::optional metadata_location; + std::shared_ptr metadata; // required // required + std::unordered_map config; + // TODO(Li Feiyang): Add std::shared_ptr storage_credential; +}; + +/// \brief Alias of LoadTableResult used as the body of CreateTableResponse +using CreateTableResponse = LoadTableResult; + +/// \brief Alias of LoadTableResult used as the body of LoadTableResponse +using LoadTableResponse = LoadTableResult; + +/// \brief Response body for listing namespaces. +struct ICEBERG_REST_EXPORT ListNamespacesResponse { + PageToken next_page_token; + std::vector namespaces; +}; + +/// \brief Response body after creating a namespace. +struct ICEBERG_REST_EXPORT CreateNamespaceResponse { + Namespace namespace_; // required + std::unordered_map properties; +}; + +/// \brief Response body for loading namespace properties. +struct ICEBERG_REST_EXPORT GetNamespaceResponse { + Namespace namespace_; // required + std::unordered_map properties; +}; + +/// \brief Response body after updating namespace properties. +struct ICEBERG_REST_EXPORT UpdateNamespacePropertiesResponse { + std::vector updated; // required + std::vector removed; // required + std::vector missing; +}; + +/// \brief Response body for listing tables in a namespace. +struct ICEBERG_REST_EXPORT ListTablesResponse { + PageToken next_page_token; + std::vector identifiers; +}; + +} // namespace iceberg::rest