MCPcopy Create free account
hub / github.com/Icinga/icinga2 / HandleRequest

Method HandleRequest

lib/remote/objectqueryhandler.cpp:95–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95bool ObjectQueryHandler::HandleRequest(
96 const WaitGroup::Ptr&,
97 const HttpApiRequest& request,
98 HttpApiResponse& response,
99 boost::asio::yield_context& yc
100)
101{
102 namespace http = boost::beast::http;
103
104 auto url = request.Url();
105 auto user = request.User();
106 auto params = request.Params();
107
108 if (url->GetPath().size() < 3 || url->GetPath().size() > 4)
109 return false;
110
111 if (request.method() != http::verb::get)
112 return false;
113
114 Type::Ptr type = FilterUtility::TypeFromPluralName(url->GetPath()[2]);
115
116 if (!type) {
117 HttpUtility::SendJsonError(response, params, 400, "Invalid type specified.");
118 return true;
119 }
120
121 QueryDescription qd;
122 qd.Types.insert(type->GetName());
123 qd.Permission = "objects/query/" + type->GetName();
124
125 Array::Ptr uattrs, ujoins, umetas;
126
127 try {
128 uattrs = params->Get("attrs");
129 } catch (const std::exception&) {
130 HttpUtility::SendJsonError(response, params, 400,
131 "Invalid type for 'attrs' attribute specified. Array type is required.");
132 return true;
133 }
134
135 try {
136 ujoins = params->Get("joins");
137 } catch (const std::exception&) {
138 HttpUtility::SendJsonError(response, params, 400,
139 "Invalid type for 'joins' attribute specified. Array type is required.");
140 return true;
141 }
142
143 try {
144 umetas = params->Get("meta");
145 } catch (const std::exception&) {
146 HttpUtility::SendJsonError(response, params, 400,
147 "Invalid type for 'meta' attribute specified. Array type is required.");
148 return true;
149 }
150
151 bool includeUsedBy = false;
152 bool includeLocation = false;

Callers

nothing calls this directly

Calls 15

ParamsMethod · 0.80
SubStrMethod · 0.80
FindFirstOfMethod · 0.80
findMethod · 0.80
GetSourceLocationMethod · 0.80
NavigateFieldMethod · 0.80
StringClass · 0.50
UrlMethod · 0.45
UserMethod · 0.45
sizeMethod · 0.45
GetPathMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected