aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/archive/VespaManagedArchiveBucket.java
blob: 3bcb41cbb683336a3652b310615e0526a1f5156f (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.archive;

import com.google.common.collect.Sets;
import com.yahoo.config.provision.TenantName;

import java.util.Objects;
import java.util.Set;

/**
 * Represents a cloud storage bucket (e.g. AWS S3 or Google Storage) used to store archive data - logs, heap/core dumps, etc.
 * that is managed by the Vespa controller.
 *
 * @author andreer
 */
public class VespaManagedArchiveBucket {
    private final String bucketName;
    private final String keyArn;
    private final Set<TenantName> tenants;

    public VespaManagedArchiveBucket(String bucketName, String keyArn) {
        this(bucketName, keyArn, Set.of());
    }

    private VespaManagedArchiveBucket(String bucketName, String keyArn, Set<TenantName> tenants) {
        this.bucketName = bucketName;
        this.keyArn = keyArn;
        this.tenants = Set.copyOf(tenants);
    }

    public String bucketName() {
        return bucketName;
    }

    public String keyArn() {
        return keyArn;
    }

    public Set<TenantName> tenants() {
        return tenants;
    }

    public VespaManagedArchiveBucket withTenant(TenantName tenant) {
        return withTenants(Set.of(tenant));
    }

    public VespaManagedArchiveBucket withTenants(Set<TenantName> tenants) {
        return new VespaManagedArchiveBucket(bucketName, keyArn, Sets.union(this.tenants, tenants));
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        VespaManagedArchiveBucket that = (VespaManagedArchiveBucket) o;
        return bucketName.equals(that.bucketName) && keyArn.equals(that.keyArn) && tenants.equals(that.tenants);
    }

    @Override
    public int hashCode() {
        return Objects.hash(bucketName, keyArn, tenants);
    }

    @Override
    public String toString() {
        return "ArchiveBucket{" +
                "bucketName='" + bucketName + '\'' +
                ", keyArn='" + keyArn + '\'' +
                ", tenants=" + tenants +
                '}';
    }
}