Search in sources :

Example 11 with SlimeJsonResponse

use of com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse in project vespa by vespa-engine.

the class ApplicationApiHandler method getGlobalRotationOverride.

private HttpResponse getGlobalRotationOverride(String tenantName, String applicationName, String instanceName, String environment, String region) {
    DeploymentId deploymentId = new DeploymentId(ApplicationId.from(tenantName, applicationName, instanceName), ZoneId.from(environment, region));
    Slime slime = new Slime();
    Cursor c1 = slime.setObject().setArray("globalrotationoverride");
    try {
        Map<String, EndpointStatus> rotations = controller.applications().getGlobalRotationStatus(deploymentId);
        for (String rotation : rotations.keySet()) {
            EndpointStatus currentStatus = rotations.get(rotation);
            c1.addString(rotation);
            Cursor c2 = c1.addObject();
            c2.setString("status", currentStatus.getStatus().name());
            c2.setString("reason", currentStatus.getReason() == null ? "" : currentStatus.getReason());
            c2.setString("agent", currentStatus.getAgent() == null ? "" : currentStatus.getAgent());
            c2.setLong("timestamp", currentStatus.getEpoch());
        }
    } catch (IOException e) {
        return ErrorResponse.internalServerError("Unable to get rotation status: " + e.getMessage());
    }
    return new SlimeJsonResponse(slime);
}
Also used : EndpointStatus(com.yahoo.vespa.hosted.controller.api.application.v4.model.EndpointStatus) DeploymentId(com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId) SlimeJsonResponse(com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse) IOException(java.io.IOException) Slime(com.yahoo.slime.Slime) Cursor(com.yahoo.slime.Cursor)

Example 12 with SlimeJsonResponse

use of com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse in project vespa by vespa-engine.

the class ApplicationApiHandler method athenzDomains.

private HttpResponse athenzDomains(HttpRequest request) {
    Slime slime = new Slime();
    Cursor response = slime.setObject();
    Cursor array = response.setArray("data");
    for (AthenzDomain athenzDomain : controller.getDomainList(request.getProperty("prefix"))) {
        array.addString(athenzDomain.getName());
    }
    return new SlimeJsonResponse(slime);
}
Also used : SlimeJsonResponse(com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse) AthenzDomain(com.yahoo.vespa.athenz.api.AthenzDomain) Slime(com.yahoo.slime.Slime) Cursor(com.yahoo.slime.Cursor)

Example 13 with SlimeJsonResponse

use of com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse in project vespa by vespa-engine.

the class ApplicationApiHandler method tenant.

private HttpResponse tenant(Tenant tenant, HttpRequest request, boolean listApplications) {
    Slime slime = new Slime();
    toSlime(slime.setObject(), tenant, request, listApplications);
    return new SlimeJsonResponse(slime);
}
Also used : SlimeJsonResponse(com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse) Slime(com.yahoo.slime.Slime)

Example 14 with SlimeJsonResponse

use of com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse 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);
}
Also used : SlimeJsonResponse(com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse) Slime(com.yahoo.slime.Slime) Cursor(com.yahoo.slime.Cursor) Map(java.util.Map) Property(com.yahoo.vespa.hosted.controller.api.identifiers.Property) PropertyId(com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId)

Example 15 with SlimeJsonResponse

use of com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse in project vespa by vespa-engine.

the class ApplicationApiHandler method application.

private HttpResponse application(String tenantName, String applicationName, HttpRequest request) {
    ApplicationId applicationId = ApplicationId.from(tenantName, applicationName, "default");
    Application application = controller.applications().get(applicationId).orElseThrow(() -> new NotExistsException(applicationId + " not found"));
    Slime slime = new Slime();
    toSlime(slime.setObject(), application, request);
    return new SlimeJsonResponse(slime);
}
Also used : SlimeJsonResponse(com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse) NotExistsException(com.yahoo.vespa.hosted.controller.NotExistsException) ApplicationId(com.yahoo.config.provision.ApplicationId) Slime(com.yahoo.slime.Slime) Application(com.yahoo.vespa.hosted.controller.Application)

Aggregations

SlimeJsonResponse (com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse)23 Slime (com.yahoo.slime.Slime)22 Cursor (com.yahoo.slime.Cursor)17 ApplicationId (com.yahoo.config.provision.ApplicationId)7 Application (com.yahoo.vespa.hosted.controller.Application)7 NotExistsException (com.yahoo.vespa.hosted.controller.NotExistsException)4 Tenant (com.yahoo.vespa.hosted.controller.api.Tenant)3 DeploymentId (com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId)3 ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)3 Environment (com.yahoo.config.provision.Environment)2 RegionName (com.yahoo.config.provision.RegionName)2 TenantName (com.yahoo.config.provision.TenantName)2 Inspector (com.yahoo.slime.Inspector)2 AthenzDomain (com.yahoo.vespa.athenz.api.AthenzDomain)2 ActivateResult (com.yahoo.vespa.hosted.controller.api.ActivateResult)2 DeployOptions (com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions)2 EndpointStatus (com.yahoo.vespa.hosted.controller.api.application.v4.model.EndpointStatus)2 ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)2 Deployment (com.yahoo.vespa.hosted.controller.application.Deployment)2 VespaVersion (com.yahoo.vespa.hosted.controller.versions.VespaVersion)2