mirror of
https://github.com/Icinga/icinga2.git
synced 2025-09-24 10:17:59 +02:00
Remove wait parameter, ttl is required, remove unnecessary checks
This commit is contained in:
parent
8bd829b4ae
commit
5442092218
@ -549,6 +549,10 @@ Dictionary::Ptr ApiActions::ExecuteCommand(const ConfigObject::Ptr& object,
|
|||||||
Dictionary::Ptr resolvedMacros;
|
Dictionary::Ptr resolvedMacros;
|
||||||
bool useResolvedMacros;
|
bool useResolvedMacros;
|
||||||
|
|
||||||
|
if (params->Contains("macros") && !params->Get("macros").IsObjectType<Dictionary>()) {
|
||||||
|
return ApiActions::CreateResult(400, "macros must be a dictionary");
|
||||||
|
}
|
||||||
|
|
||||||
if (params->Contains("macros")) {
|
if (params->Contains("macros")) {
|
||||||
resolvedMacros = HttpUtility::GetLastParameter(params, "macros");
|
resolvedMacros = HttpUtility::GetLastParameter(params, "macros");
|
||||||
useResolvedMacros = true;
|
useResolvedMacros = true;
|
||||||
@ -563,10 +567,6 @@ Dictionary::Ptr ApiActions::ExecuteCommand(const ConfigObject::Ptr& object,
|
|||||||
useResolvedMacros
|
useResolvedMacros
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Check if resolved_endpoint is not empty */
|
|
||||||
if (resolved_endpoint.IsEmpty())
|
|
||||||
return ApiActions::CreateResult(400, "Endpoint must not be empty.");
|
|
||||||
|
|
||||||
/* Check if endpoint exists */
|
/* Check if endpoint exists */
|
||||||
if (!Endpoint::GetByName(resolved_endpoint))
|
if (!Endpoint::GetByName(resolved_endpoint))
|
||||||
return ApiActions::CreateResult(404, "Can't find a valid endpoint for '" + resolved_endpoint + "'.");
|
return ApiActions::CreateResult(404, "Can't find a valid endpoint for '" + resolved_endpoint + "'.");
|
||||||
@ -615,22 +615,16 @@ Dictionary::Ptr ApiActions::ExecuteCommand(const ConfigObject::Ptr& object,
|
|||||||
} else if (command_type == "NotificationCommand") {
|
} else if (command_type == "NotificationCommand") {
|
||||||
if (!EventCommand::GetByName(resolved_command))
|
if (!EventCommand::GetByName(resolved_command))
|
||||||
return ApiActions::CreateResult(400, "Command '" + resolved_command + "' is not of type '" + command_type + "'.");
|
return ApiActions::CreateResult(400, "Command '" + resolved_command + "' is not of type '" + command_type + "'.");
|
||||||
} else
|
}
|
||||||
return ApiActions::CreateResult(400, "Invalid command_type '" + command_type + "'.");
|
|
||||||
|
|
||||||
/* Get TTL param */
|
/* Get TTL param */
|
||||||
double ttl = 0; /* FIXME default value? */
|
if (!params->Contains("ttl"))
|
||||||
if (params->Contains("ttl"))
|
return ApiActions::CreateResult(400, "ttl is required");
|
||||||
ttl = HttpUtility::GetLastParameter(params, "ttl");
|
|
||||||
|
|
||||||
|
double ttl = HttpUtility::GetLastParameter(params, "ttl");
|
||||||
if (ttl <= 0)
|
if (ttl <= 0)
|
||||||
return ApiActions::CreateResult(400, "ttl must be greater than 0");
|
return ApiActions::CreateResult(400, "ttl must be greater than 0");
|
||||||
|
|
||||||
/* Get wait param */
|
|
||||||
bool wait = false;
|
|
||||||
if (params->Contains("wait"))
|
|
||||||
wait = HttpUtility::GetLastParameter(params, "wait");
|
|
||||||
|
|
||||||
/* This generates a UUID */
|
/* This generates a UUID */
|
||||||
String uuid = Utility::NewUniqueID();
|
String uuid = Utility::NewUniqueID();
|
||||||
|
|
||||||
@ -695,8 +689,6 @@ Dictionary::Ptr ApiActions::ExecuteCommand(const ConfigObject::Ptr& object,
|
|||||||
|
|
||||||
listener->SyncSendMessage(Endpoint::GetByName(resolved_endpoint), execMessage);
|
listener->SyncSendMessage(Endpoint::GetByName(resolved_endpoint), execMessage);
|
||||||
|
|
||||||
/* TODO handle the wait */
|
|
||||||
|
|
||||||
Dictionary::Ptr result = new Dictionary();
|
Dictionary::Ptr result = new Dictionary();
|
||||||
result->Set(checkable->GetName(), uuid);
|
result->Set(checkable->GetName(), uuid);
|
||||||
return ApiActions::CreateResult(202, "Accepted", result);
|
return ApiActions::CreateResult(202, "Accepted", result);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user