GeoserverConfig.StyleAssignToLayer (GeoserverConfig v0.4.1)

Copy Markdown View Source

Provides functionality to assign a style to a layer in GeoServer.

Verifies that the specified style exists before attempting to assign it as the default style for a given layer. All functions require a GeoserverConfig.Connection as their first argument.

Summary

Functions

Assigns a style to a layer as its default style, verifying the style exists first.

Removes the default style assignment from a layer (resets to no default style).

Functions

assign_style_to_layer(conn, workspace, layer_name, style_name, style_workspace \\ nil)

Assigns a style to a layer as its default style, verifying the style exists first.

Pass nil or "" as style_name to remove the current default style (same as calling unassign_style_from_layer/3).

Parameters

  • conn — a GeoserverConfig.Connection
  • workspace — workspace in which the layer resides
  • layer_name — name of the layer
  • style_name — name of the style to assign, or nil/"" to unassign
  • style_workspace — workspace of the style, or nil to check globally (default: nil)

Returns

  • {:ok, message} if the style was successfully assigned
  • {:error, reason} if the style does not exist or the assignment failed

unassign_style_from_layer(conn, workspace, layer_name)

Removes the default style assignment from a layer (resets to no default style).

Equivalent to calling assign_style_to_layer(conn, ws, layer, nil).

Parameters

Returns

  • {:ok, message} if the style was successfully unassigned
  • {:error, reason} on failure