Class UsersResource
java.lang.Object
org.keycloak.services.resources.admin.UsersResource
Base resource for managing users
- Version:
- $Revision: 1 $
- Author:
- Bill Burke
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final ClientConnectionprotected final jakarta.ws.rs.core.HttpHeadersprotected final RealmModelprotected final KeycloakSession
- 
Constructor SummaryConstructorsConstructorDescriptionUsersResource(KeycloakSession session, AdminPermissionEvaluator auth, AdminEventBuilder adminEvent) 
- 
Method SummaryModifier and TypeMethodDescriptionjakarta.ws.rs.core.ResponseCreate a new user Username must be unique.getUsers(String search, String last, String first, String email, String username, Boolean emailVerified, String idpAlias, String idpUserId, Integer firstResult, Integer maxResults, Boolean enabled, Boolean briefRepresentation, Boolean exact, String searchQuery) Get users Returns a stream of users, filtered according to query parameters.getUsersCount(String search, String last, String first, String email, Boolean emailVerified, String username, Boolean enabled, String searchQuery) Returns the number of users that match the given criteria.Get representation of the userGet representation of the user
- 
Field Details- 
realm
- 
clientConnection
- 
session
- 
headersprotected final jakarta.ws.rs.core.HttpHeaders headers
 
- 
- 
Constructor Details- 
UsersResourcepublic UsersResource(KeycloakSession session, AdminPermissionEvaluator auth, AdminEventBuilder adminEvent) 
 
- 
- 
Method Details- 
createUser@POST @Consumes("application/json") public jakarta.ws.rs.core.Response createUser(UserRepresentation rep) Create a new user Username must be unique.- Parameters:
- rep-
- Returns:
 
- 
userGet representation of the user- Parameters:
- id- User id
- Returns:
 
- 
getUsers@GET @Produces("application/json") public Stream<UserRepresentation> getUsers(@QueryParam("search") String search, @QueryParam("lastName") String last, @QueryParam("firstName") String first, @QueryParam("email") String email, @QueryParam("username") String username, @QueryParam("emailVerified") Boolean emailVerified, @QueryParam("idpAlias") String idpAlias, @QueryParam("idpUserId") String idpUserId, @QueryParam("first") Integer firstResult, @QueryParam("max") Integer maxResults, @QueryParam("enabled") Boolean enabled, @QueryParam("briefRepresentation") Boolean briefRepresentation, @QueryParam("exact") Boolean exact, @QueryParam("q") String searchQuery) Get users Returns a stream of users, filtered according to query parameters.- Parameters:
- search- A String contained in username, first or last name, or email. Default search behavior is prefix-based (e.g.,- fooor- foo*). Use- *foo*for infix search and- "foo"for exact search.
- last- A String contained in lastName, or the complete lastName, if param "exact" is true
- first- A String contained in firstName, or the complete firstName, if param "exact" is true
- email- A String contained in email, or the complete email, if param "exact" is true
- username- A String contained in username, or the complete username, if param "exact" is true
- emailVerified- whether the email has been verified
- idpAlias- The alias of an Identity Provider linked to the user
- idpUserId- The userId at an Identity Provider linked to the user
- firstResult- Pagination offset
- maxResults- Maximum results size (defaults to 100)
- enabled- Boolean representing if user is enabled or not
- briefRepresentation- Boolean which defines whether brief representations are returned (default: false)
- exact- Boolean which defines whether the params "last", "first", "email" and "username" must match exactly
- searchQuery- A query to search for custom attributes, in the format 'key1:value2 key2:value2'
- Returns:
- a non-null Streamof users
 
- 
getUsersCount@Path("count") @GET @Produces("application/json") public Integer getUsersCount(@QueryParam("search") String search, @QueryParam("lastName") String last, @QueryParam("firstName") String first, @QueryParam("email") String email, @QueryParam("emailVerified") Boolean emailVerified, @QueryParam("username") String username, @QueryParam("enabled") Boolean enabled, @QueryParam("q") String searchQuery) Returns the number of users that match the given criteria. It can be called in three different ways. 1. Don't specify any criteria and passnull. The number of all users within that realm will be returned.2. If searchis specified other criteria such aslastwill be ignored even though you set them. Thesearchstring will be matched against the first and last name, the username and the email of a user.3. If searchis unspecified but any oflast,first,emailorusernamethose criteria are matched against their respective fields on a user entity. Combined with a logical and.- Parameters:
- search- arbitrary search string for all the fields below. Default search behavior is prefix-based (e.g.,- fooor- foo*). Use- *foo*for infix search and- "foo"for exact search.
- last- last name filter
- first- first name filter
- email- email filter
- username- username filter
- enabled- Boolean representing if user is enabled or not
- Returns:
- the number of users that match the given criteria
 
- 
userProfileGet representation of the user- Parameters:
- id- User id
- Returns:
 
 
-