| #ifndef THIRD_PARTY_MILOTIC_INTERNAL_CC_PROXY_SSH_ACTIONS_PLUGIN_H_ |
| #define THIRD_PARTY_MILOTIC_INTERNAL_CC_PROXY_SSH_ACTIONS_PLUGIN_H_ |
| |
| #include <memory> |
| #include <string> |
| |
| #include "absl/container/flat_hash_map.h" |
| #include "absl/status/status.h" |
| #include "absl/status/statusor.h" |
| #include "absl/strings/string_view.h" |
| #include "absl/time/time.h" |
| #include "proxy_config.pb.h" |
| #include "redfish_plugin.h" |
| #include "request_response.h" |
| #include "ssh_client.h" |
| namespace milotic { |
| |
| class SshActionsPlugin : public RedfishPlugin { |
| public: |
| SshActionsPlugin(const milotic_grpc_proxy::Plugin::SshActions& config); |
| |
| SshActionsPlugin(const SshActionsPlugin&) = delete; |
| SshActionsPlugin& operator=(const SshActionsPlugin&) = delete; |
| |
| RequestAction PreprocessRequest(RedfishPlugin::RequestVerb verb, |
| ProxyRequest& request) override; |
| |
| absl::StatusOr<ProxyResponse> HandleRequest( |
| RedfishPlugin::RequestVerb verb, |
| std::unique_ptr<ProxyRequest> request) override; |
| |
| absl::Status Subscribe(std::unique_ptr<ProxyRequest> /*request*/, |
| EventHandler* /*handler*/) override { |
| return absl::UnknownError("Function should never be called"); |
| } |
| |
| absl::Status Initialize(Proxy* proxy) override; |
| |
| private: |
| struct Action { |
| std::string command; |
| absl::Duration timeout; |
| int args_count; |
| }; |
| |
| absl::string_view GetResourceId(absl::string_view url); |
| |
| static absl::StatusOr<std::string> GetCommand( |
| const Action& action, std::unique_ptr<ProxyRequest> request); |
| |
| absl::flat_hash_map<std::string, Action> actions_; |
| SshClient::CommandOptions common_command_options_; |
| SshClient* ssh_client_; |
| Proxy* proxy_; |
| }; |
| |
| } // namespace milotic |
| |
| #endif // THIRD_PARTY_MILOTIC_INTERNAL_CC_PROXY_SSH_ACTIONS_PLUGIN_H_ |