From dc215361961f4b19e10f38130bc87b58e96c0d11 Mon Sep 17 00:00:00 2001 From: Mattia Codato Date: Fri, 10 Jul 2020 16:51:13 +0200 Subject: [PATCH] Uniform command_type strings --- lib/icinga/apiactions.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/icinga/apiactions.cpp b/lib/icinga/apiactions.cpp index f8a026b2f..bbc32b32b 100644 --- a/lib/icinga/apiactions.cpp +++ b/lib/icinga/apiactions.cpp @@ -558,12 +558,12 @@ Dictionary::Ptr ApiActions::ExecuteCommand(const ConfigObject::Ptr& object, BOOST_THROW_EXCEPTION(std::invalid_argument("No ApiListener instance configured.")); /* Get command_type */ - String command_type = "EventCommand"; + String command_type = "event_command"; if (params->Contains("command_type")) command_type = HttpUtility::GetLastParameter(params, "command_type"); /* Validate command_type */ - if (command_type != "EventCommand" && command_type != "CheckCommand" && command_type != "NotificationCommand") + if (command_type != "event_command" && command_type != "check_command" && command_type != "notification_command") return ApiActions::CreateResult(400, "Invalid command_type '" + command_type + "'."); Checkable::Ptr checkable = dynamic_pointer_cast(object); @@ -619,11 +619,11 @@ Dictionary::Ptr ApiActions::ExecuteCommand(const ConfigObject::Ptr& object, /* Get command */ String command; if (!params->Contains("command")) { - if (command_type == "CheckCommand" ) { + if (command_type == "check_command" ) { command = "$check_command$"; - } else if (command_type == "EventCommand") { + } else if (command_type == "event_command") { command = "$event_command$"; - } else if (command_type == "NotificationCommand") { + } else if (command_type == "notification_command") { command = "$notification_command$"; } } else { @@ -646,19 +646,19 @@ Dictionary::Ptr ApiActions::ExecuteCommand(const ConfigObject::Ptr& object, MacroResolver::OverrideMacros = nullptr; }); - if (command_type == "CheckCommand") { + if (command_type == "check_command") { CheckCommand::Ptr cmd = GetSingleObjectByNameUsingPermissions(CheckCommand::GetTypeName(), resolved_command, ActionsHandler::AuthenticatedApiUser); if (!cmd) return ApiActions::CreateResult(404, "Can't find a valid " + command_type + " for '" + resolved_command + "'."); else cmd->Execute(checkable, cr, execMacros, false); - } else if (command_type == "EventCommand") { + } else if (command_type == "event_command") { EventCommand::Ptr cmd = GetSingleObjectByNameUsingPermissions(EventCommand::GetTypeName(), resolved_command, ActionsHandler::AuthenticatedApiUser); if (!cmd) return ApiActions::CreateResult(404, "Can't find a valid " + command_type + " for '" + resolved_command + "'."); else cmd->Execute(checkable, execMacros, false); - } else if (command_type == "NotificationCommand") { + } else if (command_type == "notification_command") { NotificationCommand::Ptr cmd = GetSingleObjectByNameUsingPermissions(NotificationCommand::GetTypeName(), resolved_command, ActionsHandler::AuthenticatedApiUser); if (!cmd) return ApiActions::CreateResult(404, "Can't find a valid " + command_type + " for '" + resolved_command + "'.");