aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/identityprovider/api/IdentityType.java
blob: 25070500ba54c0f6abb8acc286c58664e35eba2d (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.athenz.identityprovider.api;

import java.util.Arrays;

/**
 * Represents the types of identities that the configserver can provide.
 *
 * @author bjorncs
 */
public enum IdentityType {TENANT("tenant"), NODE("node");
    private final String id;

    IdentityType(String id) { this.id = id; }

    public String id() { return id; }

    public static IdentityType fromId(String id) {
        return Arrays.stream(values())
                .filter(v -> v.id.equals(id))
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException("Invalid id: " + id));
    }
}