aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/permits/CloudAccessControl.java
blob: 039736902c1560fe0e303ec44287ba761f2210bc (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
package com.yahoo.vespa.hosted.controller.permits;

import com.google.inject.Inject;
import com.yahoo.vespa.hosted.controller.Application;
import com.yahoo.vespa.hosted.controller.api.integration.organization.Marketplace;
import com.yahoo.vespa.hosted.controller.tenant.CloudTenant;
import com.yahoo.vespa.hosted.controller.tenant.Tenant;

import javax.ws.rs.NotSupportedException;
import java.security.Principal;
import java.util.Collections;
import java.util.List;

/**
 * @author jonmv
 * @author tokle
 */
public class CloudAccessControl implements AccessControl {

    private final Marketplace marketplace;

    @Inject
    public CloudAccessControl(Marketplace marketplace) {
        this.marketplace = marketplace;
    }

    @Override
    public CloudTenant createTenant(TenantPermit permit, List<Tenant> existing) {
        CloudTenantPermit cloudPermit = (CloudTenantPermit) permit;

        // Do things ...

        return new CloudTenant(cloudPermit.tenant(), marketplace.resolveCustomer(cloudPermit.getRegistrationToken()));
    }

    @Override
    public Tenant updateTenant(TenantPermit tenantPermit, List<Tenant> existing, List<Application> applications) {
        throw new NotSupportedException("Update is not supported here, as it would entail changing the tenant name.");
    }

    @Override
    public void deleteTenant(TenantPermit permit, Tenant tenant) {

        // Probably delete customer subscription?

    }

    @Override
    public void createApplication(ApplicationPermit permit) {

        // No-op?

    }

    @Override
    public void deleteApplication(ApplicationPermit permit) {

        // No-op?

    }

    @Override
    public List<Tenant> accessibleTenants(List<Tenant> tenants, Principal user) {
        return Collections.emptyList();
    }

}