@Override
public AggregateCounterResource retrieve(String name, Date from, Date to, Resolution resolution) {
Assert.notNull(resolution, "Resolution must not be null");
DateTime fromParam = from == null ? null : new DateTime(from.getTime());
DateTime toParam = to == null ? null : new DateTime(to.getTime());
String url = links.getLink(AGGREGATE_COUNTER_RELATION).expand(name).getHref();
HashMap<String, Object> uriVariables = new HashMap<>();
uriVariables.put("resolution", resolution.toString());
uriVariables.put("from", fromParam);
uriVariables.put("to", toParam);
URI uri = UriComponentsBuilder.fromUriString(url + "?resolution={resolution}&from={from}&to={to}")
.build(resolution.toString(), fromParam, toParam);
return restTemplate.getForObject(uri, AggregateCounterResource.class);
}