1 /*
2 * Copyright 2026 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.bremersee.keycloak.api;
18
19 import java.time.OffsetDateTime;
20 import org.immutables.value.Value;
21 import org.jspecify.annotations.Nullable;
22
23 /**
24 * The get user parameters.
25 *
26 * @author Christian Bremer
27 */
28 @Value.Style(
29 visibility = Value.Style.ImplementationVisibility.PACKAGE,
30 overshadowImplementation = true,
31 depluralize = true,
32 jdk9Collections = true,
33 get = {"get*", "is*"},
34 withUnaryOperator = "with*")
35 @Value.Immutable
36 public interface GetUsersParameters {
37
38 /**
39 * Boolean which defines whether brief representations are returned (default: false).
40 *
41 * @return the brief representation
42 */
43 @Nullable Boolean getBriefRepresentation();
44
45 /**
46 * Only return users created after (inclusive) the given date.
47 *
48 * @return the created after
49 */
50 @Nullable OffsetDateTime getCreatedAfter();
51
52 /**
53 * Gets created after as epoch second string.
54 *
55 * @return the created after as string
56 */
57 @Value.Auxiliary
58 @Nullable
59 default String getCreatedAfterAsString() {
60 return getCreatedAfter() != null ? String.valueOf(getCreatedAfter().toEpochSecond()) : null;
61 }
62
63 /**
64 * Only return users created before (inclusive) the given date.
65 *
66 * @return the created before
67 */
68 @Nullable OffsetDateTime getCreatedBefore();
69
70 /**
71 * Gets created before as epoch second string.
72 *
73 * @return the created before as string
74 */
75 @Value.Auxiliary
76 @Nullable
77 default String getCreatedBeforeAsString() {
78 return getCreatedBefore() != null ? String.valueOf(getCreatedBefore().toEpochSecond()) : null;
79 }
80
81 /**
82 * A String contained in email, or the complete email, if param "exact" is true.
83 *
84 * @return the email
85 */
86 @Nullable String getEmail();
87
88 /**
89 * Whether the email has been verified.
90 *
91 * @return the email verified
92 */
93 @Nullable Boolean getEmailVerified();
94
95 /**
96 * Boolean representing if user is enabled or not.
97 *
98 * @return the enabled
99 */
100 @Nullable Boolean getEnabled();
101
102 /**
103 * Boolean which defines whether the params "last", "firstName", "email" and "username" must match
104 * exactly.
105 *
106 * @return the exact
107 */
108 @Nullable Boolean getExact();
109
110 /**
111 * Gets pagination offset.
112 *
113 * @return the first
114 */
115 @Nullable Integer getFirst();
116
117 /**
118 * A String contained in firstName, or the complete firstName, if param "exact" is true.
119 *
120 * @return the first name
121 */
122 @Nullable String getFirstName();
123
124 /**
125 * The alias of an Identity Provider linked to the user.
126 *
127 * @return the idp alias
128 */
129 @Nullable String getIdpAlias();
130
131 /**
132 * The userId at an Identity Provider linked to the user.
133 *
134 * @return the idp user id
135 */
136 @Nullable String getIdpUserId();
137
138 /**
139 * A String contained in lastName, or the complete lastName, if param "exact" is true.
140 *
141 * @return the last name
142 */
143 @Nullable String getLastName();
144
145 /**
146 * Maximum results size (defaults to 100).
147 *
148 * @return the max
149 */
150 @Nullable Integer getMax();
151
152 /**
153 * A query to search for custom attributes, in the format 'key1:value2 key2:value2'.
154 *
155 * @return the query
156 */
157 @Nullable String getQuery();
158
159 /**
160 * A String contained in username, first or last name, or email. Default search behavior is
161 * prefix-based (e.g., foo or foo*). Use *foo* for infix search and "foo" for exact search.
162 *
163 * @return the search
164 */
165 @Nullable String getSearch();
166
167 /**
168 * A String contained in username, or the complete username, if param "exact" is true.
169 *
170 * @return the username
171 */
172 @Nullable String getUsername();
173
174 /**
175 * Default get user parameters.
176 *
177 * @return the get user parameters
178 */
179 static GetUsersParameters defaults() {
180 return GetUsersParameters.builder().build();
181 }
182
183 /**
184 * Creates new builder.
185 *
186 * @return the builder
187 */
188 static Builder builder() {
189 return new Builder();
190 }
191
192 /**
193 * The builder.
194 */
195 class Builder extends ImmutableGetUsersParameters.Builder {
196
197 }
198 }