use of com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse in project vespa by vespa-engine.
the class ZoneApiHandler method environment.
private HttpResponse environment(HttpRequest request, Environment environment) {
List<ZoneId> zones = zoneRegistry.zones().all().in(environment).ids();
Slime slime = new Slime();
Cursor root = slime.setArray();
zones.forEach(zone -> {
Cursor object = root.addObject();
object.setString("name", zone.region().value());
object.setString("url", request.getUri().resolve("/zone/v2/environment/").resolve(environment.value() + "/").resolve("region/").resolve(zone.region().value()).toString());
});
return new SlimeJsonResponse(slime);
}
use of com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse in project vespa by vespa-engine.
the class ZoneApiHandler method defaultRegion.
private HttpResponse defaultRegion(HttpRequest request, Environment environment) {
RegionName region = zoneRegistry.getDefaultRegion(environment).orElseThrow(() -> new IllegalArgumentException("No default region for environment: " + environment));
Slime slime = new Slime();
Cursor root = slime.setObject();
root.setString("name", region.value());
root.setString("url", request.getUri().resolve("/zone/v2/environment/").resolve(environment.value() + "/").resolve("region/").resolve(region.value()).toString());
return new SlimeJsonResponse(slime);
}
use of com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse 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