Provides functions to manage styles in GeoServer via the REST API.
All functions require a GeoserverConfig.Connection as their first argument,
except write_sld_file/2 which is a local file operation.
Summary
Functions
Copies a style from one workspace to another or between workspace and global scope.
Creates a new style in GeoServer.
Deletes a style from GeoServer.
Retrieves the SLD content for a specific style.
Lists all global styles available in GeoServer.
Lists all styles scoped to a specific workspace.
Moves a style from one workspace to another or between workspace and global scope.
Updates an existing style's content.
Writes SLD content to a local file. Does not require a connection.
Functions
Copies a style from one workspace to another or between workspace and global scope.
Parameters
conn— aGeoserverConfig.Connectionsource_style— name of the style to copysource_workspace— source workspace, ornilfor global stylestarget_style— name for the copied style (can be same as source)target_workspace— target workspace, ornilfor global scopeopts— options including:format(:sld or :css, auto-detected if nil)
Returns
{:ok, target_style}on success{:error, reason}on failure
Creates a new style in GeoServer.
Parameters
conn— aGeoserverConfig.Connectionopts— map with::name(required) — style name:content(required) — style content (SLD XML or CSS):format—:sld(default) or:css:workspace— workspace name (optional, nil for global):filename— filename (optional):title— style title (optional):abstract— style description (optional):keywords— list of keywords (optional)
Returns
{:ok, style_name}on success{:error, %{status: status, body: body}}on HTTP failure{:error, reason}on transport error
Deletes a style from GeoServer.
Parameters
conn— aGeoserverConfig.Connectionstyle_name— name of the style to deleteworkspace— workspace of the style, ornilfor global styles (default:nil)opts—:purgeand/or:recurse(both boolean, default false)
Returns
{:ok, style_name}on success{:error, {:not_found, style_name}}if the style does not exist{:error, {:http_error, status, body}}on other HTTP failure{:error, {:request_failed, reason}}on transport error
Retrieves the SLD content for a specific style.
Pass nil or "" as workspace to fetch a global style.
Returns
{:ok, sld_content}on success{:error, {:not_found, style_name}}when the style does not exist{:error, {:http_error, status, body}}on other HTTP failure{:error, {:request_failed, reason}}on transport error
Lists all global styles available in GeoServer.
Lists all styles scoped to a specific workspace.
Moves a style from one workspace to another or between workspace and global scope.
Parameters
conn— aGeoserverConfig.Connectionstyle_name— name of the style to movesource_workspace— source workspace, ornilfor global stylestarget_workspace— target workspace, ornilfor global scopeopts— options including:purge(boolean, default false)
Returns
{:ok, style_name}on success{:error, reason}on failure
Updates an existing style's content.
Parameters
conn— aGeoserverConfig.Connectionopts— map with::name(required) — style name:content(required) — style content (SLD XML or CSS):format—:sld(default) or:css:workspace— workspace name (optional, nil for global):filename— filename (optional)
Returns
{:ok, style_name}on success{:error, {:http_error, status, body}}on failure{:error, {:request_failed, reason}}on transport error
Writes SLD content to a local file. Does not require a connection.
Returns
{:ok, %{file_path: path, size: bytes}}on success{:error, {:file_write_failed, reason, file_path}}on failure