use of com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse in project vespa by vespa-engine.
the class ApplicationApiHandler method recursiveRoot.
private HttpResponse recursiveRoot(HttpRequest request) {
Slime slime = new Slime();
Cursor tenantArray = slime.setArray();
for (Tenant tenant : controller.tenants().asList()) toSlime(tenantArray.addObject(), tenant, request, true);
return new SlimeJsonResponse(slime);
}
use of com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse in project vespa by vespa-engine.
the class ApplicationApiHandler method authenticatedUser.
private HttpResponse authenticatedUser(HttpRequest request) {
String userIdString = request.getProperty("userOverride");
if (userIdString == null)
userIdString = getUserId(request).map(UserId::id).orElseThrow(() -> new ForbiddenException("You must be authenticated or specify userOverride"));
UserId userId = new UserId(userIdString);
List<Tenant> tenants = controller.tenants().asList(userId);
Slime slime = new Slime();
Cursor response = slime.setObject();
response.setString("user", userId.id());
Cursor tenantsArray = response.setArray("tenants");
for (Tenant tenant : tenants) tenantInTenantsListToSlime(tenant, request.getUri(), tenantsArray.addObject());
response.setBool("tenantExists", tenants.stream().map(Tenant::getId).anyMatch(id -> id.isTenantFor(userId)));
return new SlimeJsonResponse(slime);
}
use of com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse in project vespa by vespa-engine.
the class ApplicationApiHandler method cookieFreshness.
private HttpResponse cookieFreshness(HttpRequest request) {
Slime slime = new Slime();
String passThruHeader = request.getHeader(SetBouncerPassthruHeaderFilter.BOUNCER_PASSTHRU_HEADER_FIELD);
slime.setObject().setBool("shouldRefreshCookie", !SetBouncerPassthruHeaderFilter.BOUNCER_PASSTHRU_COOKIE_OK.equals(passThruHeader));
return new SlimeJsonResponse(slime);
}
use of com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse in project vespa by vespa-engine.
the class ApplicationApiHandler method tenants.
private HttpResponse tenants(HttpRequest request) {
Slime slime = new Slime();
Cursor response = slime.setArray();
for (Tenant tenant : controller.tenants().asList()) tenantInTenantsListToSlime(tenant, request.getUri(), response.addObject());
return new SlimeJsonResponse(slime);
}
use of com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse in project vespa by vespa-engine.
the class ApplicationApiHandler method deployment.
private HttpResponse deployment(String tenantName, String applicationName, String instanceName, String environment, String region, HttpRequest request) {
ApplicationId id = ApplicationId.from(tenantName, applicationName, instanceName);
Application application = controller.applications().get(id).orElseThrow(() -> new NotExistsException(id + " not found"));
DeploymentId deploymentId = new DeploymentId(application.id(), ZoneId.from(environment, region));
Deployment deployment = application.deployments().get(deploymentId.zoneId());
if (deployment == null)
throw new NotExistsException(application + " is not deployed in " + deploymentId.zoneId());
Slime slime = new Slime();
toSlime(slime.setObject(), deploymentId, deployment, request);
return new SlimeJsonResponse(slime);
}
Aggregations