|
12 | 12 |
|
13 | 13 | #include "absl/container/flat_hash_map.h" |
14 | 14 | #include "absl/container/node_hash_map.h" |
| 15 | +#include "kafka/protocol/types.h" |
| 16 | +#include "pandaproxy/schema_registry/types.h" |
15 | 17 | #include "security/acl_store.h" |
16 | 18 | #include "serde/read_header.h" |
17 | 19 | #include "serde/rw/rw.h" |
@@ -707,6 +709,36 @@ void acl_binding_filter::testing_serde_full_read_v2( |
707 | 709 | *this = acl_binding_filter{res._pattern, res._acl}; |
708 | 710 | } |
709 | 711 |
|
| 712 | +template<typename T> |
| 713 | +resource_type get_resource_type() { |
| 714 | + if constexpr (std::is_same_v<T, model::topic>) { |
| 715 | + return resource_type::topic; |
| 716 | + } else if constexpr (std::is_same_v<T, kafka::group_id>) { |
| 717 | + return resource_type::group; |
| 718 | + } else if constexpr (std::is_same_v<T, acl_cluster_name>) { |
| 719 | + return resource_type::cluster; |
| 720 | + } else if constexpr (std::is_same_v<T, kafka::transactional_id>) { |
| 721 | + return resource_type::transactional_id; |
| 722 | + } else if constexpr ( |
| 723 | + std::is_same_v<T, pandaproxy::schema_registry::context_subject>) { |
| 724 | + return resource_type::sr_subject; |
| 725 | + } else if constexpr ( |
| 726 | + std::is_same_v<T, pandaproxy::schema_registry::registry_resource>) { |
| 727 | + return resource_type::sr_registry; |
| 728 | + } else { |
| 729 | + static_assert(base::unsupported_type<T>::value, "Unsupported type"); |
| 730 | + } |
| 731 | +} |
| 732 | + |
| 733 | +template resource_type get_resource_type<model::topic>(); |
| 734 | +template resource_type get_resource_type<kafka::group_id>(); |
| 735 | +template resource_type get_resource_type<acl_cluster_name>(); |
| 736 | +template resource_type get_resource_type<kafka::transactional_id>(); |
| 737 | +template resource_type |
| 738 | +get_resource_type<pandaproxy::schema_registry::context_subject>(); |
| 739 | +template resource_type |
| 740 | +get_resource_type<pandaproxy::schema_registry::registry_resource>(); |
| 741 | + |
710 | 742 | template<typename T> |
711 | 743 | const std::vector<acl_operation>& get_allowed_operations() { |
712 | 744 | static const std::vector<acl_operation> topic_resource_ops{ |
|
0 commit comments