1
#pragma once
2

            
3
#include "envoy/admin/v3/clusters.pb.h"
4
#include "envoy/buffer/buffer.h"
5
#include "envoy/http/codes.h"
6
#include "envoy/http/header_map.h"
7
#include "envoy/server/admin.h"
8
#include "envoy/server/instance.h"
9

            
10
#include "source/server/admin/handler_ctx.h"
11

            
12
#include "absl/strings/string_view.h"
13
#include "re2/re2.h"
14

            
15
namespace Envoy {
16
namespace Server {
17

            
18
/**
19
 * A utility to set admin health status from a specified host and health flag.
20
 *
21
 * @param healthFlag    The specific health status to be checked.
22
 * @param host          The target host.
23
 * @param health_status A proto reference representing the admin health status.
24
 */
25
void setHealthFlag(Upstream::Host::HealthFlag flag, const Upstream::Host& host,
26
                   envoy::admin::v3::HostHealthStatus& health_status);
27

            
28
class ClustersHandler : public HandlerContextBase {
29

            
30
public:
31
  ClustersHandler(Server::Instance& server);
32

            
33
  Http::Code handlerClusters(Http::ResponseHeaderMap& response_headers, Buffer::Instance& response,
34
                             AdminStream&);
35

            
36
private:
37
  void addOutlierInfo(const std::string& cluster_name,
38
                      const Upstream::Outlier::Detector* outlier_detector,
39
                      Buffer::Instance& response);
40
  bool shouldIncludeCluster(const std::string& cluster_name,
41
                            const absl::optional<const re2::RE2>& filter);
42
  void writeClustersAsJson(const absl::optional<const re2::RE2>& filter,
43
                           Buffer::Instance& response);
44
  void writeClustersAsText(const absl::optional<const re2::RE2>& filter,
45
                           Buffer::Instance& response);
46
};
47

            
48
} // namespace Server
49
} // namespace Envoy