aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/PlanRegistry.java
blob: c0bd0dd29cd0c93d578053a0cdfbd3bd40a5b8bc (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
// 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.billing;

import java.util.List;
import java.util.Optional;

/**
 * Registry of all current plans we have support for
 *
 * @author ogronnesby
 */
public interface PlanRegistry {

    /** Get the default plan */
    Plan defaultPlan();

    /** Get a plan given a plan ID */
    Optional<Plan> plan(PlanId planId);

    /** Get a set of all plans */
    List<Plan> all();

    default Plan require(String planId) {
        return plan(planId).orElseThrow();
    }

    /** Get a plan give a plan ID */
    default Optional<Plan> plan(String planId) {
        if (planId == null || planId.isBlank())
            return Optional.empty();
        return plan(PlanId.from(planId));
    }

}