Search in sources :

Example 6 with ApplicationView

use of com.yahoo.vespa.serviceview.bindings.ApplicationView in project vespa by vespa-engine.

the class ApplicationApiHandler method services.

private HttpResponse services(String tenantName, String applicationName, String instanceName, String environment, String region, HttpRequest request) {
    ApplicationView applicationView = controller.getApplicationView(tenantName, applicationName, instanceName, environment, region);
    ServiceApiResponse response = new ServiceApiResponse(ZoneId.from(environment, region), new ApplicationId.Builder().tenant(tenantName).applicationName(applicationName).instanceName(instanceName).build(), controller.zoneRegistry().getConfigServerUris(ZoneId.from(environment, region)), request.getUri());
    response.setResponse(applicationView);
    return response;
}
Also used : ApplicationView(com.yahoo.vespa.serviceview.bindings.ApplicationView) ApplicationId(com.yahoo.config.provision.ApplicationId)

Example 7 with ApplicationView

use of com.yahoo.vespa.serviceview.bindings.ApplicationView in project vespa by vespa-engine.

the class ServiceApiResponseTest method testServiceViewResponseWithURLs.

@Test
public void testServiceViewResponseWithURLs() throws URISyntaxException, IOException {
    ServiceApiResponse response = new ServiceApiResponse(ZoneId.from(Environment.prod, RegionName.from("us-west-1")), ApplicationId.from("tenant2", "application2", "default"), Collections.singletonList(new URI("http://cfg1.test/")), new URI("http://cfg1.test/serviceview/v1/tenant/tenant2/application/application2/environment/prod/region/us-west-1/instance/default/service/searchnode-9dujk1pa0vufxrj6n4yvmi8uc/state/v1"));
    ApplicationView applicationView = new ApplicationView();
    ClusterView clusterView = new ClusterView();
    clusterView.type = "container";
    clusterView.name = "cluster1";
    clusterView.url = "http://cfg1.test/serviceview/v1/tenant/tenant2/application/application2/environment/prod/region/us-west-1/instance/default/service/searchnode-9dujk1pa0vufxrj6n4yvmi8uc/state/v1/health";
    ServiceView serviceView = new ServiceView();
    serviceView.url = null;
    serviceView.serviceType = "container";
    serviceView.serviceName = "service1";
    serviceView.configId = "configId1";
    serviceView.host = "host1";
    serviceView.legacyStatusPages = "legacyPages";
    clusterView.services = Collections.singletonList(serviceView);
    applicationView.clusters = Collections.singletonList(clusterView);
    response.setResponse(applicationView);
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    response.render(stream);
    Slime responseSlime = SlimeUtils.jsonToSlime(stream.toByteArray());
    Slime expectedSlime = SlimeUtils.jsonToSlime(IOUtils.readFile(new File(responseFiles + "service-api-response-with-urls.json")).getBytes(StandardCharsets.UTF_8));
    assertEquals("service-api-response.json", new String(SlimeUtils.toJsonBytes(expectedSlime), StandardCharsets.UTF_8), new String(SlimeUtils.toJsonBytes(responseSlime), StandardCharsets.UTF_8));
}
Also used : ClusterView(com.yahoo.vespa.serviceview.bindings.ClusterView) ServiceView(com.yahoo.vespa.serviceview.bindings.ServiceView) ApplicationView(com.yahoo.vespa.serviceview.bindings.ApplicationView) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Slime(com.yahoo.slime.Slime) URI(java.net.URI) File(java.io.File) Test(org.junit.Test)

Aggregations

ApplicationView (com.yahoo.vespa.serviceview.bindings.ApplicationView)7 ClusterView (com.yahoo.vespa.serviceview.bindings.ClusterView)4 ServiceView (com.yahoo.vespa.serviceview.bindings.ServiceView)4 Test (org.junit.Test)4 Slime (com.yahoo.slime.Slime)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 File (java.io.File)2 URI (java.net.URI)2 ApplicationId (com.yahoo.config.provision.ApplicationId)1 HostService (com.yahoo.vespa.serviceview.bindings.HostService)1 ArrayList (java.util.ArrayList)1