aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/VpcEndpointService.java
blob: 97e1b88b25c13bc52c03e93023ae4eed2287b0d4 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.yahoo.vespa.hosted.controller.api.integration.dns;

import ai.vespa.http.DomainName;
import com.yahoo.config.provision.CloudAccount;
import com.yahoo.vespa.hosted.controller.api.identifiers.ClusterId;

import java.time.Instant;
import java.util.List;
import java.util.Optional;

import static java.util.Objects.requireNonNull;

/**
 * @author jonmv
 */
public interface VpcEndpointService {

    /** Create a TXT record with this name and token, and then complete the challenge. */
    record DnsChallenge(RecordName name, RecordData data, ClusterId clusterId, String serviceId,
                        Optional<CloudAccount> account, Instant createdAt, ChallengeState state) {

            public DnsChallenge {
                requireNonNull(name, "name must be non-null");
                requireNonNull(data, "data must be non-null");
                requireNonNull(clusterId, "clusterId must be non-null");
                requireNonNull(serviceId, "serviceId must be non-null");
                requireNonNull(account, "account must be non-null");
                requireNonNull(createdAt, "createdAt must be non-null");
                requireNonNull(state, "state must be non-null");
            }

            public DnsChallenge withState(ChallengeState state) {
                return new DnsChallenge(name, data, clusterId, serviceId, account, createdAt, state);
            }

    }

    enum ChallengeState { pending, ready, running, done }

    /** Sets the private DNS name for any VPC endpoint for the given cluster, potentially guarded by a challenge. */
    Optional<DnsChallenge> setPrivateDns(DomainName privateDnsName, ClusterId clusterId, Optional<CloudAccount> account, boolean isGenerated);

    /** Attempts to complete the challenge, and returns the updated challenge state. */
    ChallengeState process(DnsChallenge challenge);

    /** A connection made to an endpoint service. */
    record VpcEndpoint(String endpointId, String stateString, EndpointState stateValue) { }

    enum EndpointState { pending, open, failed, closed }

    /** Lists all endpoints connected to an endpoint service (owned by account) for the given cluster. */
    List<VpcEndpoint> getConnections(ClusterId cluster, Optional<CloudAccount> account);

}