mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-22 13:14:32 +02:00
Merge pull request #5497 from Icinga/fix/api-object-query-type-error
API: Fix requested attrs/joins/meta type errors in object query response
This commit is contained in:
commit
a43ae941b6
@ -123,9 +123,32 @@ bool ObjectQueryHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& re
|
|||||||
qd.Types.insert(type->GetName());
|
qd.Types.insert(type->GetName());
|
||||||
qd.Permission = "objects/query/" + type->GetName();
|
qd.Permission = "objects/query/" + type->GetName();
|
||||||
|
|
||||||
Array::Ptr uattrs = params->Get("attrs");
|
Array::Ptr uattrs, ujoins, umetas;
|
||||||
Array::Ptr ujoins = params->Get("joins");
|
|
||||||
Array::Ptr umetas = params->Get("meta");
|
try {
|
||||||
|
uattrs = params->Get("attrs");
|
||||||
|
} catch (const std::exception&) {
|
||||||
|
HttpUtility::SendJsonError(response, 400,
|
||||||
|
"Invalid type for 'attrs' attribute specified. Array type is required.", Empty);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
ujoins = params->Get("joins");
|
||||||
|
} catch (const std::exception&) {
|
||||||
|
HttpUtility::SendJsonError(response, 400,
|
||||||
|
"Invalid type for 'joins' attribute specified. Array type is required.", Empty);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
umetas = params->Get("meta");
|
||||||
|
} catch (const std::exception&) {
|
||||||
|
HttpUtility::SendJsonError(response, 400,
|
||||||
|
"Invalid type for 'meta' attribute specified. Array type is required.", Empty);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool allJoins = HttpUtility::GetLastParameter(params, "all_joins");
|
bool allJoins = HttpUtility::GetLastParameter(params, "all_joins");
|
||||||
|
|
||||||
params->Set("type", type->GetName());
|
params->Set("type", type->GetName());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user