When using the following REST API
I would expect every LayerGroup to be returned but only those layergroups without a workspace specified are returned. This means I'd have to iterate every workspace to get all layergroups which seems very painful
The same happens for rest/layers, it's how it's supposed to work, even if not ideal for some.
The current behavior cannot be changed for backwards compatibility, if you want you can sponsor an improvement (e.g, a query parameter to control what's in the output), see the process here:
Thanks for the quick feedback
In my testing the same does NOT happen with rest/layers. I get all the layers from every workspace, with a href link to get specific details on each layer. This was why I was surprised at the inconsistency.
Unfortunately I'm not much of a Java programmer or might have had a stab at fixing myself.
You're right, the layers case is different. Backwards compatibility however is a strong requirement. Switching type and working to feature request. One note, the REST API was fully rewritten about a year ago (it was based on a old unmaintained library), if you can check 2.10.x and it works in a different way (e..g, show this is a regression) then I can turn it back to "bug" status.