public class UsersResource extends Object
Modifier and Type | Field and Description |
---|---|
protected ClientConnection |
clientConnection |
protected javax.ws.rs.core.HttpHeaders |
headers |
protected RealmModel |
realm |
protected KeycloakSession |
session |
Constructor and Description |
---|
UsersResource(RealmModel realm,
AdminPermissionEvaluator auth,
AdminEventBuilder adminEvent) |
Modifier and Type | Method and Description |
---|---|
javax.ws.rs.core.Response |
createUser(UserRepresentation rep)
Create a new user
Username must be unique.
|
List<UserRepresentation> |
getUsers(String search,
String last,
String first,
String email,
String username,
Integer firstResult,
Integer maxResults,
Boolean briefRepresentation)
Get users
Returns a list of users, filtered according to query parameters
|
Integer |
getUsersCount(String search,
String last,
String first,
String email,
String username)
Returns the number of users that match the given criteria.
|
UserResource |
user(String id)
Get representation of the user
|
protected RealmModel realm
@Context protected ClientConnection clientConnection
@Context protected KeycloakSession session
@Context protected javax.ws.rs.core.HttpHeaders headers
public UsersResource(RealmModel realm, AdminPermissionEvaluator auth, AdminEventBuilder adminEvent)
@POST @Consumes(value="application/json") public javax.ws.rs.core.Response createUser(UserRepresentation rep)
rep
- @Path(value="{id}") public UserResource user(@PathParam(value="id") String id)
id
- User id@GET @Produces(value="application/json") public List<UserRepresentation> getUsers(@QueryParam(value="search") String search, @QueryParam(value="lastName") String last, @QueryParam(value="firstName") String first, @QueryParam(value="email") String email, @QueryParam(value="username") String username, @QueryParam(value="first") Integer firstResult, @QueryParam(value="max") Integer maxResults, @QueryParam(value="briefRepresentation") Boolean briefRepresentation)
search
- A String contained in username, first or last name, or emaillast
- first
- email
- username
- first
- Pagination offsetmaxResults
- Maximum results size (defaults to 100)@Path(value="count") @GET @Produces(value="application/json") public Integer getUsersCount(@QueryParam(value="search") String search, @QueryParam(value="lastName") String last, @QueryParam(value="firstName") String first, @QueryParam(value="email") String email, @QueryParam(value="username") String username)
null
. The number of all
users within that realm will be returned.
2. If search
is specified other criteria such as last
will
be ignored even though you set them. The search
string will be
matched against the first and last name, the username and the email of a
user.
3. If search
is unspecified but any of last
, first
,
email
or username
those criteria are matched against their
respective fields on a user entity. Combined with a logical and.
search
- arbitrary search string for all the fields belowlast
- last name filterfirst
- first name filteremail
- email filterusername
- username filterCopyright © 2020 JBoss by Red Hat. All rights reserved.