Search in sources :

Example 1 with ListRolesRequest

use of com.amazonaws.services.identitymanagement.model.ListRolesRequest in project intellij-idea-plugin-connector-for-aws-lambda by satr.

the class RoleConnectorModel method populateRoleListAndMap.

private void populateRoleListAndMap(AmazonIdentityManagement identityManagementClient) {
    roleEntities = new ArrayList<>();
    roleEntityMap = new LinkedHashMap<>();
    try {
        ListRolesRequest listRolesRequest = new ListRolesRequest().withMaxItems(MAX_FETCHED_ROLE_COUNT);
        ListRolesResult listRolesResult = identityManagementClient.listRoles(listRolesRequest);
        List<Role> roles = listRolesResult.getRoles();
        for (Role role : roles) {
            addRoleToListAndMap(role);
        }
    } catch (AmazonIdentityManagementException e) {
        if ("AccessDenied".equals(e.getErrorCode())) {
        // "User has not access to a list of roles - skip the error.
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Role(com.amazonaws.services.identitymanagement.model.Role) ListRolesRequest(com.amazonaws.services.identitymanagement.model.ListRolesRequest) ListRolesResult(com.amazonaws.services.identitymanagement.model.ListRolesResult) AmazonIdentityManagementException(com.amazonaws.services.identitymanagement.model.AmazonIdentityManagementException) AmazonIdentityManagementException(com.amazonaws.services.identitymanagement.model.AmazonIdentityManagementException)

Aggregations

AmazonIdentityManagementException (com.amazonaws.services.identitymanagement.model.AmazonIdentityManagementException)1 ListRolesRequest (com.amazonaws.services.identitymanagement.model.ListRolesRequest)1 ListRolesResult (com.amazonaws.services.identitymanagement.model.ListRolesResult)1 Role (com.amazonaws.services.identitymanagement.model.Role)1