blob: b9ee837cfe4638f8261b028d3743a715357a5429 [file] [log] [blame] [edit]
#pragma once
#include "absl/strings/string_view.h"
#include "grpcpp/security/auth_context.h"
#include "grpcpp/server_context.h"
#include "grpcpp/support/status.h"
#include "grpcpp/support/sync_stream.h"
#include "proxy.h"
#include "proxy_config.pb.h"
#include "redfish_plugin.h"
#include "voyager/voyager_telemetry.grpc.pb.h"
#include "voyager/voyager_telemetry.pb.h"
namespace milotic {
class ProxyVoyagerImpl : public third_party_voyager::MachineTelemetry::Service {
public:
explicit ProxyVoyagerImpl(
Proxy &proxy, const milotic_grpc_proxy::VoyagerTelemetryOptions &options)
: proxy_(proxy) {}
grpc::Status Subscribe(
grpc::ServerContext *context, const third_party_voyager::Request *request,
grpc::ServerWriter<third_party_voyager::Update> *writer) override;
grpc::Status Get(grpc::ServerContext *context,
const third_party_voyager::Request *request,
third_party_voyager::Update *response) override {
return DispatchRequest(RedfishPlugin::RequestVerb::kGet, request, response,
*context->auth_context());
}
grpc::Status Post(grpc::ServerContext *context,
const third_party_voyager::SetRequest *request,
third_party_voyager::Update *response) override {
return DispatchRequest(RedfishPlugin::RequestVerb::kPost, request, response,
*context->auth_context());
}
grpc::Status Patch(grpc::ServerContext *context,
const third_party_voyager::SetRequest *request,
third_party_voyager::Update *response) override {
return DispatchRequest(RedfishPlugin::RequestVerb::kPatch, request,
response, *context->auth_context());
}
grpc::Status Put(grpc::ServerContext *context,
const third_party_voyager::SetRequest *request,
third_party_voyager::Update *response) override {
return DispatchRequest(RedfishPlugin::RequestVerb::kPut, request, response,
*context->auth_context());
}
grpc::Status Delete(grpc::ServerContext *context,
const third_party_voyager::SetRequest *request,
third_party_voyager::Update *response) override {
return DispatchRequest(RedfishPlugin::RequestVerb::kDelete, request,
response, *context->auth_context());
}
ProxyVoyagerImpl(const ProxyVoyagerImpl &) = delete;
ProxyVoyagerImpl &operator=(const ProxyVoyagerImpl &) = delete;
private:
grpc::Status DispatchRequest(RedfishPlugin::RequestVerb verb,
const third_party_voyager::Request *request,
third_party_voyager::Update *response,
const grpc::AuthContext &auth_context);
grpc::Status DispatchRequest(RedfishPlugin::RequestVerb verb,
const third_party_voyager::SetRequest *request,
third_party_voyager::Update *response,
const grpc::AuthContext &auth_context);
Proxy &proxy_;
};
static constexpr absl::string_view kExportIntervalHeaderKey =
"vbmc:ExportInterval";
} // namespace milotic