src.geoserver.geoserver_common
Core functions for serving data and working with workspaces in geoserver.
Attributes
Functions
|
Retrieve full GeoServer URL from environment variables. |
|
Create a GeoServer workspace if it does not currently exist. |
|
Upload a file to a new GeoServer store, to enable serving. |
|
Create a GeoServer Layer from a GeoServer store, making it ready to serve. |
|
Check if a GeoServer style definition already exists for a given style_name. |
Module Contents
- src.geoserver.geoserver_common.log
- src.geoserver.geoserver_common._xml_header
- src.geoserver.geoserver_common.get_geoserver_url() str
Retrieve full GeoServer URL from environment variables.
- Returns:
The full GeoServer URL
- Return type:
str
- src.geoserver.geoserver_common.create_workspace_if_not_exists(workspace_name: str) None
Create a GeoServer workspace if it does not currently exist.
- Parameters:
workspace_name (str) – The name of the workspace to create if it does not exists.
- Raises:
HTTPError – If geoserver responds with an error, raises it as an exception since it is unexpected.
- src.geoserver.geoserver_common.upload_file_to_store(geoserver_url: str, file_to_add: pathlib.Path, store_name: str, workspace_name: str) None
Upload a file to a new GeoServer store, to enable serving.
- Parameters:
geoserver_url (str) – The URL to the geoserver instance.
file_to_add (pathlib.Path) – The filepath to the GeoTiff file to be served, currently support NetCDF and GeoTiff.
store_name (str) – The name of the new Geoserver store to be created.
workspace_name (str) – The name of the existing GeoServer workspace that the store is to be added to.
- Raises:
HTTPError – If geoserver responds with an error, raises it as an exception since it is unexpected.
ValueError – If file_to_add does not have a file extension matching one of the supported file types..
- src.geoserver.geoserver_common.send_create_layer_request(geoserver_url: str, layer_name: str, workspace_name: str, coverage_payload: str) None
Create a GeoServer Layer from a GeoServer store, making it ready to serve.
- Parameters:
geoserver_url (str) – The URL to the geoserver instance.
layer_name (str) – Defines the name of the layer in GeoServer.
workspace_name (str) – The name of the existing GeoServer workspace that the store is to be added to.
coverage_payload (str) – The coverage XML data to send in the Geoserver request payload.
- Raises:
HTTPError – If geoserver responds with an error, raises it as an exception since it is unexpected.
- src.geoserver.geoserver_common.style_exists(style_name: str) bool
Check if a GeoServer style definition already exists for a given style_name. The style definition may be empty.
- Parameters:
style_name (str) – The name of the style to check for
- Returns:
True if the style exists, although it may be empty. False if it does not exist.
- Return type:
bool
- Raises:
HTTPError – If geoserver responds with anything but OK or NOT_FOUND, raises it as an exception since it is unexpected.