summaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/archive/MockArchiveService.java
blob: a2847439ce7af9c19e9a325052f05c3d0e34bf2b (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
// Copyright Yahoo. 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.yahoo.config.provision.TenantName;
import com.yahoo.config.provision.zone.ZoneId;
import com.yahoo.vespa.hosted.controller.tenant.ArchiveAccess;

import java.net.URI;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

/**
 * @author freva
 * @author andreer
 */
public class MockArchiveService implements ArchiveService {


    public Set<ArchiveBucket> archiveBuckets = new HashSet<>();
    public Map<TenantName, ArchiveAccess> authorizeAccessByTenantName = new HashMap<>();


    @Override
    public ArchiveBucket createArchiveBucketFor(ZoneId zoneId) {
        return new ArchiveBucket("bucketName", "keyArn");
    }

    @Override
    public void updatePolicies(ZoneId zoneId, Set<ArchiveBucket> buckets, Map<TenantName, ArchiveAccess> authorizeAccessByTenantName) {
        this.archiveBuckets = new HashSet<>(buckets);
        this.authorizeAccessByTenantName = new HashMap<>(authorizeAccessByTenantName);
    }

    @Override
    public boolean canAddTenantToBucket(ZoneId zoneId, ArchiveBucket bucket) {
        return bucket.tenants().size() < 5;
    }

    @Override
    public URI bucketURI(ZoneId zoneId, String bucketName, TenantName tenantName) {
        return URI.create(String.format("s3://%s/%s/", bucketName, tenantName.value()));
    }
}