use of com.yahoo.slime.Cursor in project vespa by vespa-engine.
the class ApplicationApiHandler method properties.
private HttpResponse properties() {
Slime slime = new Slime();
Cursor response = slime.setObject();
Cursor array = response.setArray("properties");
for (Map.Entry<PropertyId, Property> entry : controller.fetchPropertyList().entrySet()) {
Cursor propertyObject = array.addObject();
propertyObject.setString("propertyid", entry.getKey().id());
propertyObject.setString("property", entry.getValue().id());
}
return new SlimeJsonResponse(slime);
}
use of com.yahoo.slime.Cursor in project vespa by vespa-engine.
the class ApplicationApiHandler method tenantInTenantsListToSlime.
// A tenant has different content when in a list ... antipattern, but not solvable before application/v5
private void tenantInTenantsListToSlime(Tenant tenant, URI requestURI, Cursor object) {
object.setString("tenant", tenant.getId().id());
Cursor metaData = object.setObject("metaData");
metaData.setString("type", tenant.tenantType().name());
tenant.getAthensDomain().ifPresent(a -> metaData.setString("athensDomain", a.getName()));
tenant.getProperty().ifPresent(p -> metaData.setString("property", p.id()));
object.setString("url", withPath("/application/v4/tenant/" + tenant.getId().id(), requestURI).toString());
}
use of com.yahoo.slime.Cursor 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.slime.Cursor in project vespa by vespa-engine.
the class ApplicationApiHandler method toSlime.
public static void toSlime(DeploymentCost deploymentCost, Cursor object) {
object.setLong("tco", (long) deploymentCost.getTco());
object.setLong("waste", (long) deploymentCost.getWaste());
object.setDouble("utilization", deploymentCost.getUtilization());
Cursor clustersObject = object.setObject("cluster");
for (Map.Entry<String, ClusterCost> clusterEntry : deploymentCost.getCluster().entrySet()) toSlime(clusterEntry.getValue(), clustersObject.setObject(clusterEntry.getKey()));
}
use of com.yahoo.slime.Cursor in project vespa by vespa-engine.
the class JobsResponse method render.
@Override
public void render(OutputStream stream) throws IOException {
Slime slime = new Slime();
Cursor root = slime.setObject();
Cursor jobArray = root.setArray("jobs");
for (String jobName : jobControl.jobs()) jobArray.addObject().setString("name", jobName);
Cursor inactiveArray = root.setArray("inactive");
for (String jobName : jobControl.inactiveJobs()) inactiveArray.addString(jobName);
new JsonFormat(true).encode(stream, slime);
}
Aggregations