blob: 5aceb5a2a47ce367b8c9448f647b4dc62ce8a7e9 [file]
#ifndef PRODUCTION_BORG_MGMT_NODE_PROXY_SAFEPOWER_SAFEPOWER_AGENT_ACTION_VALIDATION_H_
#define PRODUCTION_BORG_MGMT_NODE_PROXY_SAFEPOWER_SAFEPOWER_AGENT_ACTION_VALIDATION_H_
#include <cstdint>
#include <limits>
#include "safepower_agent.pb.h"
#include "safepower_agent_config.pb.h"
#include "absl/status/status.h"
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
namespace safepower_agent {
// ~31 years of 1-second reboots; ensures `current_boot_count + max_boots`
// fits comfortably in a 32-bit signed `int` (`int32_t`) without overflow.
inline constexpr int kMaxBootCount = 1'000'000'000;
static_assert(kMaxBootCount > 0 &&
static_cast<int64_t>(kMaxBootCount) + kMaxBootCount <=
std::numeric_limits<int32_t>::max());
absl::Status ValidateRequest(
const safepower_agent_proto::StartActionRequest& request,
absl::string_view node_entity_tag,
const safepower_agent_proto::SystemState& initial_system_state,
absl::Time start_time,
const safepower_agent_config::ConditionValidationOptions& options =
safepower_agent_config::ConditionValidationOptions::default_instance());
} // namespace safepower_agent
#endif // PRODUCTION_BORG_MGMT_NODE_PROXY_SAFEPOWER_SAFEPOWER_AGENT_ACTION_VALIDATION_H_