Skip to content

Support briefRepresentation in RealmsResource.findAll() - #55209

Open
mushfika-faria-nova wants to merge 1 commit into
keycloak:mainfrom
mushfika-faria-nova:feat/realms-brief-representation
Open

mushfika-faria-nova wants to merge 1 commit into
keycloak:mainfrom
mushfika-faria-nova:feat/realms-brief-representation

Conversation

@mushfika-faria-nova

Copy link
Copy Markdown

Closes #55207

The admin REST endpoint GET /admin/realms already supports briefRepresentation, but the Java admin client's RealmsResource only had findAll() without parameters. This adds findAll(boolean briefRepresentation) and keeps the existing findAll() for compatibility. Requested in keycloak/keycloak-client#202.

Testing

  • New test RealmCreateTest#getRealmsBriefRepresentation: brief and full return the same realms; brief realms have no accessTokenLifespan, full realms do.
  • Checked that the test fails when brief is not requested (expected: <null> but was: <60>).
  • RealmCreateTest#getRealms and the new test pass locally (embedded server). Spotless applied, no changes.

I used an AI assistant (Claude) to draft the change and the test; I reviewed, built and tested it myself.

Closes keycloak#55207

Signed-off-by: Mushfika Faria Nova <mushfika.faria.nova@gmail.com>
@mushfika-faria-nova
mushfika-faria-nova requested a review from a team as a code owner November 15, 2026 07:34
Copilot AI balanced review requested due to automatic review settings November 15, 2026 07:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the Java admin-client overload supporting brief realm representations.

No open issues 🎉

What changed in this PR

Adds Java admin client support for the existing realm-listing briefRepresentation parameter, addressing #55207 without server-side changes.

Changes:

  • Adds findAll(boolean briefRepresentation) while preserving the existing no-argument method.
  • Documents the brief representation fields.
  • Adds a test verifying that brief and full responses contain the same realms, with the expected field differences.
File Description
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​admin/​realm/​RealmCreateTest.java Tests realm listings with brief and full representations.
integration/​admin-client-core/​src/​main/​java/​org/​keycloak/​admin/​client/​resource/​RealmsResource.java Adds and documents the overload accepting briefRepresentation.

Review effort: Balanced

@jamesconwaydev jamesconwaydev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. On main, RealmsAdminResource.getRealms takes @DefaultValue("false") @QueryParam("briefRepresentation"), and ModelToRepresentation.toBriefRepresentation(RealmModel) sets exactly id, realm, displayName, displayNameHtml and enabled, so the javadoc matches.

One detail the javadoc could mention: in toRealmRep, a realm where canView fails but isAdmin passes comes back with only realm set, whether brief or not.

Read only: I checked RealmsAdminResource.java and ModelToRepresentation.java on main and didn't run it. Written with help from an AI assistant (Claude Code); each reference was checked against the source.

@mushfika-faria-nova

Copy link
Copy Markdown
Author

@jamesconwaydev Thanks for checking. Good point about the isAdmin-only case. That applies to the existing findAll() too, so I kept the Javadoc to the brief/full difference. Happy to add a line if the maintainers prefer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Admin client: support briefRepresentation in RealmsResource.findAll()

3 participants