use of com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse in project vespa by vespa-engine.
the class ApplicationApiHandler method applications.
private HttpResponse applications(String tenantName, HttpRequest request) {
TenantName tenant = TenantName.from(tenantName);
Slime slime = new Slime();
Cursor array = slime.setArray();
for (Application application : controller.applications().asList(tenant)) toSlime(application, array.addObject(), request);
return new SlimeJsonResponse(slime);
}
use of com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse in project vespa by vespa-engine.
the class DeploymentApiHandler method root.
private HttpResponse root(HttpRequest request) {
Slime slime = new Slime();
Cursor root = slime.setObject();
Cursor platformArray = root.setArray("versions");
for (VespaVersion version : controller.versionStatus().versions()) {
Cursor versionObject = platformArray.addObject();
versionObject.setString("version", version.versionNumber().toString());
versionObject.setString("confidence", version.confidence().name());
versionObject.setString("commit", version.releaseCommit());
versionObject.setLong("date", version.committedAt().toEpochMilli());
versionObject.setBool("controllerVersion", version.isSelfVersion());
versionObject.setBool("systemVersion", version.isCurrentSystemVersion());
Cursor configServerArray = versionObject.setArray("configServers");
for (String configServerHostnames : version.configServerHostnames()) {
Cursor configServerObject = configServerArray.addObject();
configServerObject.setString("hostname", configServerHostnames);
}
Cursor failingArray = versionObject.setArray("failingApplications");
for (ApplicationId id : version.statistics().failing()) {
controller.applications().get(id).ifPresent(application -> {
firstFailingOn(version.versionNumber(), application).ifPresent(firstFailing -> {
Cursor applicationObject = failingArray.addObject();
toSlime(applicationObject, application, request);
applicationObject.setString("failing", firstFailing.type().jobName());
});
});
}
Cursor productionArray = versionObject.setArray("productionApplications");
for (ApplicationId id : version.statistics().production()) {
controller.applications().get(id).ifPresent(application -> {
int successes = productionSuccessesFor(version.versionNumber(), application);
// Just upgraded to a newer version.
if (successes == 0)
return;
Cursor applicationObject = productionArray.addObject();
toSlime(applicationObject, application, request);
applicationObject.setLong("productionJobs", productionJobsFor(application));
applicationObject.setLong("productionSuccesses", productionSuccessesFor(version.versionNumber(), application));
});
}
Cursor runningArray = versionObject.setArray("deployingApplications");
for (ApplicationId id : version.statistics().deploying()) {
controller.applications().get(id).ifPresent(application -> {
lastDeployingTo(version.versionNumber(), application).ifPresent(lastDeploying -> {
Cursor applicationObject = runningArray.addObject();
toSlime(applicationObject, application, request);
applicationObject.setString("running", lastDeploying.type().jobName());
});
});
}
}
return new SlimeJsonResponse(slime);
}
use of com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse in project vespa by vespa-engine.
the class ScrewdriverApiHandler method trigger.
private HttpResponse trigger(HttpRequest request, String tenantName, String applicationName) {
JobType jobType = Optional.of(asString(request.getData())).filter(s -> !s.isEmpty()).map(JobType::fromJobName).orElse(JobType.component);
ApplicationId applicationId = ApplicationId.from(tenantName, applicationName, "default");
controller.applications().lockOrThrow(applicationId, application -> {
// Since this is a manual operation we likely want it to trigger as soon as possible so we add it at to the
// front of the queue
application = controller.applications().deploymentTrigger().trigger(new DeploymentTrigger.Triggering(application, jobType, true, "Triggered from screwdriver/v1"), Collections.emptySet(), true);
controller.applications().store(application);
});
Slime slime = new Slime();
Cursor cursor = slime.setObject();
cursor.setString("message", "Triggered " + jobType.jobName() + " for " + applicationId);
return new SlimeJsonResponse(slime);
}
use of com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse in project vespa by vespa-engine.
the class ScrewdriverApiHandler method vespaVersion.
private HttpResponse vespaVersion() {
VespaVersion version = controller.versionStatus().version(controller.systemVersion());
if (version == null)
return ErrorResponse.notFoundError("Information about the current system version is not available at this time");
Slime slime = new Slime();
Cursor cursor = slime.setObject();
cursor.setString("version", version.versionNumber().toString());
cursor.setString("sha", version.releaseCommit());
cursor.setLong("date", version.committedAt().toEpochMilli());
return new SlimeJsonResponse(slime);
}
use of com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse in project vespa by vespa-engine.
the class ScrewdriverApiHandler method buildJobs.
private HttpResponse buildJobs(List<BuildJob> buildJobs) {
Slime slime = new Slime();
Cursor buildJobArray = slime.setArray();
for (BuildJob buildJob : buildJobs) {
Cursor buildJobObject = buildJobArray.addObject();
buildJobObject.setLong("projectId", buildJob.projectId());
buildJobObject.setString("jobName", buildJob.jobName());
}
return new SlimeJsonResponse(slime);
}
Aggregations