Provides functionality to manage Layer Groups in GeoServer via the REST API.
All functions require a GeoserverConfig.Connection as their first argument.
Summary
Functions
Adds a layer with an optional style to a GeoServer layer group.
Creates a new layer group in GeoServer.
Deletes a layer group from GeoServer by name.
Lists all layer groups in GeoServer.
Lists layer groups scoped to a specific workspace.
Removes a layer from a GeoServer layer group.
Updates an existing layer group.
Functions
Adds a layer with an optional style to a GeoServer layer group.
Fetches the current group state and appends the new layer before updating.
If a style name is provided, it is also appended to the group-level
styles array to maintain the layer:style count parity required by GeoServer.
Returns
{:ok, body}on success{:error, reason}on failure
Creates a new layer group in GeoServer.
Accepts either an XML string or a JSON map as the body.
Returns
{:ok, body}on success (2xx){:error, {:http_error, status, body}}on failure{:error, {:request_failed, reason}}on transport error
Deletes a layer group from GeoServer by name.
Returns
{:ok, name}on success{:error, {:http_error, status, body}}on failure{:error, {:request_failed, reason}}on transport error
Lists all layer groups in GeoServer.
When workspace is provided, only layer groups in that workspace are returned
(hitting /workspaces/:workspace/layergroups). Without a workspace argument,
the global /layergroups endpoint is used.
GeoServer returns a map instead of a list when only one group exists, and
returns the string "" instead of an empty map when no groups exist; both
cases are normalised to a list.
Returns
{:ok, [group]}on success{:error, {:http_error, status, body}}on non-200 response{:error, {:request_failed, reason}}on transport error
Lists layer groups scoped to a specific workspace.
Returns
{:ok, [group]}on success{:error, {:http_error, status, body}}on non-200 response{:error, {:request_failed, reason}}on transport error
Removes a layer from a GeoServer layer group.
Fetches the current group state and filters out the named layer before updating. If the group has a matching number of styles, the corresponding style at the same index is also removed to maintain layer:style parity.
Returns
{:ok, body}on success{:error, :layer_not_found}if the layer is not in the group{:error, reason}on other failure
Updates an existing layer group.
Accepts either an XML string or a JSON map as the body.
Returns
{:ok, body}on success{:error, {:http_error, status, body}}on failure{:error, {:request_failed, reason}}on transport error