Search in sources :

Example 1 with ApiUsageStateMailMessage

use of org.thingsboard.server.common.data.ApiUsageStateMailMessage in project thingsboard by thingsboard.

the class DefaultTbApiUsageStateService method createStateMailMessage.

private ApiUsageStateMailMessage createStateMailMessage(TenantApiUsageState state, ApiFeature apiFeature, ApiUsageStateValue stateValue) {
    StateChecker checker = getStateChecker(stateValue);
    for (ApiUsageRecordKey apiUsageRecordKey : ApiUsageRecordKey.getKeys(apiFeature)) {
        long threshold = state.getProfileThreshold(apiUsageRecordKey);
        long warnThreshold = state.getProfileWarnThreshold(apiUsageRecordKey);
        long value = state.get(apiUsageRecordKey);
        if (checker.check(threshold, warnThreshold, value)) {
            return new ApiUsageStateMailMessage(apiUsageRecordKey, threshold, value);
        }
    }
    return null;
}
Also used : ApiUsageStateMailMessage(org.thingsboard.server.common.data.ApiUsageStateMailMessage) ApiUsageRecordKey(org.thingsboard.server.common.data.ApiUsageRecordKey)

Aggregations

ApiUsageRecordKey (org.thingsboard.server.common.data.ApiUsageRecordKey)1 ApiUsageStateMailMessage (org.thingsboard.server.common.data.ApiUsageStateMailMessage)1