@Override
public MetricServiceData getMetrics(MetricQuery query) throws RestClientException {
URI url = metricBaseUrl.resolve("api/metric/").resolve(project + "/");
URIBuilder uriBuilder = new URIBuilder(url);
if (query != null) {
for (String filter : query.filters) {
int firstEquals = filter.indexOf('=');
if (firstEquals == -1) {
uriBuilder.addParameter("has." + filter, "");
} else {
String key = filter.substring(0, firstEquals);
String value = filter.substring(firstEquals + 1);
uriBuilder.addParameter("filter." + key, value);
}
}
for (String projection : query.projections) {
int firstEquals = projection.indexOf('=');
if (firstEquals == -1) {
uriBuilder.addParameter("select." + projection, "");
} else {
throw new IllegalArgumentException();
}
}
if (query.flatten) {
uriBuilder.addParameter("flatten", "true");
}
}
try {
url = uriBuilder.build();
} catch (URISyntaxException e) {
throw new IllegalArgumentException("Error building URI", e);
}
HttpGet request = new HttpGet(url);