blob: 347d772b1482be7c09e7e2e803d306629bb26cee (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.hosted.cd.commons;
import ai.vespa.hosted.cd.Deployment;
import ai.vespa.hosted.cd.Endpoint;
import java.net.URI;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.stream.Collectors;
/**
* A remote deployment of a Vespa application, reachable over HTTP. Contains {@link HttpEndpoint}s.
*
* @author jonmv
*/
public class HttpDeployment implements Deployment {
private final Map<String, Endpoint> endpoints;
/** Creates a representation of the given deployment endpoints, using the authenticator for data plane access. */
public HttpDeployment(Map<String, URI> endpoints, EndpointAuthenticator authenticator) {
this.endpoints = endpoints.entrySet().stream()
.collect(Collectors.toUnmodifiableMap(entry -> entry.getKey(),
entry -> new HttpEndpoint(entry.getValue(), authenticator)));
}
@Override
public Endpoint endpoint(String id) {
if ( ! endpoints.containsKey(id))
throw new NoSuchElementException("No cluster with id '" + id + "'");
return endpoints.get(id);
}
}
|