1
#pragma once
2

            
3
#include <memory>
4
#include <string>
5
#include <variant>
6

            
7
#include "envoy/matcher/matcher.h"
8

            
9
#include "source/common/protobuf/utility.h"
10
#include "source/extensions/filters/common/expr/evaluator.h"
11
#include "source/extensions/matching/http/cel_input/cel_input.h"
12

            
13
#include "absl/types/variant.h"
14
#include "xds/type/matcher/v3/cel.pb.h"
15

            
16
namespace Envoy {
17
namespace Extensions {
18
namespace Matching {
19
namespace InputMatchers {
20
namespace CelMatcher {
21

            
22
using ::Envoy::Matcher::DataInputGetResult;
23
using ::Envoy::Matcher::InputMatcher;
24
using ::Envoy::Matcher::InputMatcherFactoryCb;
25

            
26
using CelMatcher = ::xds::type::matcher::v3::CelMatcher;
27
using BaseActivationPtr = std::unique_ptr<google::api::expr::runtime::BaseActivation>;
28
using CelMatcherSharedPtr = std::shared_ptr<::xds::type::matcher::v3::CelMatcher>;
29

            
30
class CelInputMatcher : public InputMatcher, public Logger::Loggable<Logger::Id::matcher> {
31
public:
32
  CelInputMatcher(CelMatcherSharedPtr cel_matcher,
33
                  Filters::Common::Expr::BuilderInstanceSharedConstPtr builder);
34

            
35
  Matcher::MatchResult match(const DataInputGetResult& input) override;
36

            
37
  // TODO(tyxia) Formalize the validation approach. Use fixed string for now.
38
114
  bool supportsDataInputType(absl::string_view data_type) const override {
39
114
    return data_type == "cel_data_input";
40
114
  }
41

            
42
private:
43
  const Filters::Common::Expr::CompiledExpression compiled_expr_;
44
};
45

            
46
} // namespace CelMatcher
47
} // namespace InputMatchers
48
} // namespace Matching
49
} // namespace Extensions
50
} // namespace Envoy