Search in sources :

Example 1 with ProxyException

use of com.yahoo.vespa.hosted.controller.proxy.ProxyException in project vespa by vespa-engine.

the class ZoneApiHandler method proxy.

private HttpResponse proxy(HttpRequest request) {
    Path path = new Path(request.getUri().getPath());
    if (!path.matches("/zone/v2/{environment}/{region}/{*}")) {
        return notFound(path);
    }
    ZoneId zoneId = ZoneId.from(path.get("environment"), path.get("region"));
    if (!zoneRegistry.hasZone(zoneId)) {
        throw new IllegalArgumentException("No such zone: " + zoneId.value());
    }
    try {
        return proxy.handle(new ProxyRequest(request, "/zone/v2/"));
    } catch (ProxyException | IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : Path(com.yahoo.vespa.hosted.controller.restapi.Path) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) ProxyException(com.yahoo.vespa.hosted.controller.proxy.ProxyException) IOException(java.io.IOException) ProxyRequest(com.yahoo.vespa.hosted.controller.proxy.ProxyRequest)

Aggregations

ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)1 ProxyException (com.yahoo.vespa.hosted.controller.proxy.ProxyException)1 ProxyRequest (com.yahoo.vespa.hosted.controller.proxy.ProxyRequest)1 Path (com.yahoo.vespa.hosted.controller.restapi.Path)1 IOException (java.io.IOException)1