|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +#pragma once |
| 21 | + |
| 22 | +#include <memory> |
| 23 | +#include <optional> |
| 24 | +#include <string> |
| 25 | +#include <unordered_map> |
| 26 | +#include <vector> |
| 27 | + |
| 28 | +#include "iceberg/catalog/rest/iceberg_rest_export.h" |
| 29 | +#include "iceberg/table_identifier.h" |
| 30 | +#include "iceberg/type_fwd.h" |
| 31 | + |
| 32 | +/// \file iceberg/catalog/rest/types.h |
| 33 | +/// Request and response types for Iceberg REST Catalog API. |
| 34 | + |
| 35 | +namespace iceberg::rest { |
| 36 | + |
| 37 | +/// \brief Request to create a namespace. |
| 38 | +struct ICEBERG_REST_EXPORT CreateNamespaceRequest { |
| 39 | + Namespace namespace_; // required |
| 40 | + std::unordered_map<std::string, std::string> properties; |
| 41 | +}; |
| 42 | + |
| 43 | +/// \brief Update or delete namespace properties request. |
| 44 | +struct ICEBERG_REST_EXPORT UpdateNamespacePropertiesRequest { |
| 45 | + std::vector<std::string> removals; |
| 46 | + std::unordered_map<std::string, std::string> updates; |
| 47 | +}; |
| 48 | + |
| 49 | +/// \brief Request to create a table. |
| 50 | +struct ICEBERG_REST_EXPORT CreateTableRequest { |
| 51 | + std::string name; // required |
| 52 | + std::string location; |
| 53 | + std::shared_ptr<Schema> schema; // required |
| 54 | + std::shared_ptr<PartitionSpec> partition_spec; |
| 55 | + std::shared_ptr<SortOrder> write_order; |
| 56 | + std::optional<bool> stage_create; |
| 57 | + std::unordered_map<std::string, std::string> properties; |
| 58 | +}; |
| 59 | + |
| 60 | +/// \brief Request to register a table. |
| 61 | +struct ICEBERG_REST_EXPORT RegisterTableRequest { |
| 62 | + std::string name; // required |
| 63 | + std::string metadata_location; // required |
| 64 | + bool overwrite = false; |
| 65 | +}; |
| 66 | + |
| 67 | +/// \brief Request to rename a table. |
| 68 | +struct ICEBERG_REST_EXPORT RenameTableRequest { |
| 69 | + TableIdentifier source; // required |
| 70 | + TableIdentifier destination; // required |
| 71 | +}; |
| 72 | + |
| 73 | +/// \brief An opaque token that allows clients to make use of pagination for list APIs. |
| 74 | +using PageToken = std::string; |
| 75 | + |
| 76 | +/// \brief Result body for table create/load/register APIs. |
| 77 | +struct ICEBERG_REST_EXPORT LoadTableResult { |
| 78 | + std::optional<std::string> metadata_location; |
| 79 | + std::shared_ptr<TableMetadata> metadata; // required // required |
| 80 | + std::unordered_map<std::string, std::string> config; |
| 81 | + // TODO(Li Feiyang): Add std::shared_ptr<StorageCredential> storage_credential; |
| 82 | +}; |
| 83 | + |
| 84 | +/// \brief Alias of LoadTableResult used as the body of CreateTableResponse |
| 85 | +using CreateTableResponse = LoadTableResult; |
| 86 | + |
| 87 | +/// \brief Alias of LoadTableResult used as the body of LoadTableResponse |
| 88 | +using LoadTableResponse = LoadTableResult; |
| 89 | + |
| 90 | +/// \brief Response body for listing namespaces. |
| 91 | +struct ICEBERG_REST_EXPORT ListNamespacesResponse { |
| 92 | + PageToken next_page_token; |
| 93 | + std::vector<Namespace> namespaces; |
| 94 | +}; |
| 95 | + |
| 96 | +/// \brief Response body after creating a namespace. |
| 97 | +struct ICEBERG_REST_EXPORT CreateNamespaceResponse { |
| 98 | + Namespace namespace_; // required |
| 99 | + std::unordered_map<std::string, std::string> properties; |
| 100 | +}; |
| 101 | + |
| 102 | +/// \brief Response body for loading namespace properties. |
| 103 | +struct ICEBERG_REST_EXPORT GetNamespaceResponse { |
| 104 | + Namespace namespace_; // required |
| 105 | + std::unordered_map<std::string, std::string> properties; |
| 106 | +}; |
| 107 | + |
| 108 | +/// \brief Response body after updating namespace properties. |
| 109 | +struct ICEBERG_REST_EXPORT UpdateNamespacePropertiesResponse { |
| 110 | + std::vector<std::string> updated; // required |
| 111 | + std::vector<std::string> removed; // required |
| 112 | + std::vector<std::string> missing; |
| 113 | +}; |
| 114 | + |
| 115 | +/// \brief Response body for listing tables in a namespace. |
| 116 | +struct ICEBERG_REST_EXPORT ListTablesResponse { |
| 117 | + PageToken next_page_token; |
| 118 | + std::vector<TableIdentifier> identifiers; |
| 119 | +}; |
| 120 | + |
| 121 | +} // namespace iceberg::rest |
0 commit comments