use of com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneList in project vespa by vespa-engine.
the class ConfigServerRestExecutorImpl method createDiscoveryResponse.
private ProxyResponse createDiscoveryResponse(ProxyRequest proxyRequest) {
ObjectMapper mapper = new ObjectMapper();
DiscoveryResponseStructure responseStructure = new DiscoveryResponseStructure();
String environmentName = proxyRequest.getEnvironment();
ZoneList zones = zoneRegistry.zones().all();
if (!environmentName.isEmpty())
zones = zones.in(Environment.from(environmentName));
for (ZoneId zoneId : zones.ids()) {
responseStructure.uris.add(proxyRequest.getScheme() + "://" + proxyRequest.getControllerPrefix() + zoneId.environment().name() + "/" + zoneId.region().value());
}
JsonNode node = mapper.valueToTree(responseStructure);
return new ProxyResponse(proxyRequest, node.toString(), 200, Optional.empty(), "application/json");
}
use of com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneList in project vespa by vespa-engine.
the class ZoneApiHandler method root.
private HttpResponse root(HttpRequest request) {
Slime slime = new Slime();
Cursor root = slime.setObject();
Cursor uris = root.setArray("uris");
ZoneList zoneList = zoneRegistry.zones().controllerManaged();
zoneList.ids().forEach(zoneId -> uris.addString(request.getUri().resolve("/zone/v2/").resolve(zoneId.environment().value() + "/").resolve(zoneId.region().value()).toString()));
Cursor zones = root.setArray("zones");
zoneList.ids().forEach(zoneId -> {
Cursor object = zones.addObject();
object.setString("environment", zoneId.environment().value());
object.setString("region", zoneId.region().value());
});
return new SlimeJsonResponse(slime);
}
Aggregations