Search in sources :

Example 1 with ITUserRequest

use of com.redhat.cloud.notifications.recipients.itservice.pojo.request.ITUserRequest in project notifications-backend by RedHatInsights.

the class RbacRecipientUsersProvider method getUsers.

@CacheResult(cacheName = "rbac-recipient-users-provider-get-users")
public List<User> getUsers(String accountId, String orgId, boolean adminsOnly) {
    Timer.Sample getUsersTotalTimer = Timer.start(meterRegistry);
    List<User> users;
    List<ITUserResponse> usersPaging;
    List<ITUserResponse> usersTotal = new ArrayList<>();
    int firstResult = 0;
    do {
        ITUserRequest request = new ITUserRequest(accountId, orgId, useOrgId, adminsOnly, firstResult, maxResultsPerPage);
        usersPaging = retryOnItError(() -> itUserService.getUsers(request));
        usersTotal.addAll(usersPaging);
        firstResult += maxResultsPerPage;
    } while (usersPaging.size() == maxResultsPerPage);
    LOGGER.info("usersTotal: " + usersTotal);
    users = transformToUser(usersTotal);
    // Micrometer doesn't like when tags are null and throws a NPE.
    String accountIdTag = accountId == null ? "" : accountId;
    getUsersTotalTimer.stop(meterRegistry.timer("rbac.get-users.total", "accountId", accountIdTag, "users", String.valueOf(users.size())));
    rbacUsers.set(users.size());
    return users;
}
Also used : User(com.redhat.cloud.notifications.recipients.User) Timer(io.micrometer.core.instrument.Timer) ArrayList(java.util.ArrayList) ITUserRequest(com.redhat.cloud.notifications.recipients.itservice.pojo.request.ITUserRequest) ITUserResponse(com.redhat.cloud.notifications.recipients.itservice.pojo.response.ITUserResponse) CacheResult(io.quarkus.cache.CacheResult)

Aggregations

User (com.redhat.cloud.notifications.recipients.User)1 ITUserRequest (com.redhat.cloud.notifications.recipients.itservice.pojo.request.ITUserRequest)1 ITUserResponse (com.redhat.cloud.notifications.recipients.itservice.pojo.response.ITUserResponse)1 Timer (io.micrometer.core.instrument.Timer)1 CacheResult (io.quarkus.cache.CacheResult)1 ArrayList (java.util.ArrayList)1