56 lines
1.5 KiB
Java
Raw Normal View History

2023-08-13 01:12:29 +01:00
package stirling.software.SPDF.model;
2023-08-13 10:53:00 +01:00
public enum Role {
2023-08-13 01:12:29 +01:00
2023-08-13 10:53:00 +01:00
// Unlimited access
ADMIN("ROLE_ADMIN", Integer.MAX_VALUE, Integer.MAX_VALUE),
// Unlimited access
USER("ROLE_USER", Integer.MAX_VALUE, Integer.MAX_VALUE),
// 40 API calls Per Day, 40 web calls
LIMITED_API_USER("ROLE_LIMITED_API_USER", 40, 40),
// 20 API calls Per Day, 20 web calls
EXTRA_LIMITED_API_USER("ROLE_EXTRA_LIMITED_API_USER", 20, 20),
// 0 API calls per day and 20 web calls
2023-12-24 17:12:32 +00:00
WEB_ONLY_USER("ROLE_WEB_ONLY_USER", 0, 20),
2023-12-27 22:56:51 +00:00
INTERNAL_API_USER("STIRLING-PDF-BACKEND-API-USER", Integer.MAX_VALUE, Integer.MAX_VALUE),
2023-08-13 10:53:00 +01:00
2023-12-27 22:56:51 +00:00
DEMO_USER("ROLE_DEMO_USER", 100, 100);
2023-08-13 10:53:00 +01:00
private final String roleId;
private final int apiCallsPerDay;
private final int webCallsPerDay;
Role(String roleId, int apiCallsPerDay, int webCallsPerDay) {
this.roleId = roleId;
this.apiCallsPerDay = apiCallsPerDay;
this.webCallsPerDay = webCallsPerDay;
}
public String getRoleId() {
return roleId;
}
public int getApiCallsPerDay() {
return apiCallsPerDay;
}
public int getWebCallsPerDay() {
return webCallsPerDay;
}
2023-08-13 01:12:29 +01:00
2023-08-13 22:46:18 +01:00
public static Role fromString(String roleId) {
for (Role role : Role.values()) {
if (role.getRoleId().equalsIgnoreCase(roleId)) {
return role;
}
}
throw new IllegalArgumentException("No Role defined for id: " + roleId);
}
2023-08-13 01:12:29 +01:00
}