Added default non-endpoint methods - #51327
Conversation
fixes: keycloak#50221 Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
There was a problem hiding this comment.
Pull request overview
Adds typed convenience methods to Admin API v2 while preserving access to raw JAX-RS responses.
Changes:
- Introduces
TypedResponse<T>with typed deserialization and resource cleanup. - Adds typed create and upsert convenience methods.
- Covers wrapper behavior and endpoint integration.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
rest/admin-v2/api/src/main/java/org/keycloak/admin/api/TypedResponse.java |
Adds the typed response wrapper. |
rest/admin-v2/api/src/main/java/org/keycloak/admin/api/client/ClientsApi.java |
Adds typed client creation. |
rest/admin-v2/api/src/main/java/org/keycloak/admin/api/client/ClientApi.java |
Adds typed client upsert. |
rest/admin-v2/api/src/test/java/org/keycloak/admin/api/TypedResponseTest.java |
Tests wrapper behavior. |
rest/admin-v2/tests/src/test/java/org/keycloak/tests/admin/client/v2/ClientApiV2Test.java |
Tests typed methods end to end. |
|
@michalvavrik This is mostly for convenience if the API is consumed through the Java Admin Client, i.e. RestEasy proxy. That's the main motivation for this. |
However, it doesn't give you any advantage, you don't get value directly, you still need to get entity and you still get entity of requested type (as |
|
@michalvavrik The advantage is that the response has a typed entity - you don't need to cast the type. |
// shared part
ClientsApi clientsApi = getClientsApi(manageClientsAdminClient);
// without this PR
OIDCClientRepresentation oidcClientRepresentation = clientsApi.createClient(baseRep).readEntity(OIDCClientRepresentation.class);
// with this pr
BaseClientRepresentation baseClientRepresentation = clientsApi.create(baseRep).readEntity();Anyway, I don't mind and I did approve. I just consider all these arguments weak, that is all. |
|
Quarkus REST has it better solved, they have |
vmuzikar
left a comment
There was a problem hiding this comment.
this PR introduces new methods
createthat does same thing ascreateClientwhich I think doesn't add on clarity, users will need to check actual implementation to understand (PR contains no javadoc either)
@michalvavrik Actually, this is a good point I missed in my reviews. The new methods should have the same name, the only difference in the signature should be the return type. @edewit Could you please fix this?
Sure but casting from
Right, that's what Steve meant by "Resteasy classic compatibility". |
impossible
Feels like I opened too long discussion, but nothing forces us to use this wrapper, we could create similar interface (delegate pattern) as Quarkus REST has. So we would need no new methods. Anyway. I am OK now. Thanks for the patience. |
vmuzikar
left a comment
There was a problem hiding this comment.
impossible
Right, it won't compile because of type ambiguity. :D Sorry, for the noise, never mind.
| }) | ||
| Response createClient(@Valid BaseClientRepresentation client); | ||
|
|
||
| default TypedResponse<BaseClientRepresentation> create(BaseClientRepresentation client) { |
There was a problem hiding this comment.
Instead of just BaseClientRepresentation, can you update the methods to use something that extends that:
<T extends BaseClientRepresentation> TypedResponse<T> create(T client)
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
* Added default non-endpoint methods fixes: keycloak#50221 Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * changed types Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> --------- Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
* Added default non-endpoint methods fixes: keycloak#50221 Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * changed types Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> --------- Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> Signed-off-by: alehhu <159355663+alehhu@users.noreply.github.com>
fixes: #50221
Signed-off-by: Erik Jan de Wit erikjan.dewit@gmail.com