src.eddie.geoserver =================== .. py:module:: src.eddie.geoserver .. autoapi-nested-parse:: Functions and utilities for loading and serving data with geoserver. Imports here are accessible directly by `from eddie import geoserver`. Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/src/eddie/geoserver/database_layers/index /autoapi/src/eddie/geoserver/geoserver_common/index /autoapi/src/eddie/geoserver/raster_layers/index /autoapi/src/eddie/geoserver/templates/index /autoapi/src/eddie/geoserver/terria_catalogs/index Classes ------- .. autoapisummary:: src.eddie.geoserver.Workspaces Functions --------- .. autoapisummary:: src.eddie.geoserver.create_datastore_layer src.eddie.geoserver.create_db_store_if_not_exists src.eddie.geoserver.create_main_db_store src.eddie.geoserver.create_workspace_if_not_exists src.eddie.geoserver.get_geoserver_url src.eddie.geoserver.add_gtiff_to_geoserver src.eddie.geoserver.add_style src.eddie.geoserver.style_exists src.eddie.geoserver.get_terria_catalog Package Contents ---------------- .. py:function:: create_datastore_layer(workspace_name: str, data_store_name: str, layer_name: str, metadata_elem: str = '') -> None Create a GeoServer layer for a given data store if it does not currently exist. Can be used to create layers for a database table, or to create a database view for a custom dynamic query. :param workspace_name: The name of the workspace the data store is associated to :type workspace_name: str :param data_store_name: The name of the data store the layer is being created from. :type data_store_name: str :param layer_name: The name of the new layer. This is the same as the name of the database table if creating a layer from a table. :type layer_name: str :param metadata_elem: An optional XML str that contains the metadata element used to configure custom SQL queries. :type metadata_elem: str = "" :raises HTTPError: If geoserver responds with an error, raises it as an exception since it is unexpected. .. py:function:: create_db_store_if_not_exists(db_name: str, workspace_name: str, new_data_store_name: str) -> None Create PostGIS database store in a GeoServer workspace for a given database. If it already exists, do not do anything. :param db_name: The name of the connected database, to connect datastore to :type db_name: str :param workspace_name: The name of the workspace to create views for :type workspace_name: str :param new_data_store_name: The name of the new datastore to create :type new_data_store_name: str :raises HTTPError: If geoserver responds with an error, raises it as an exception since it is unexpected. .. py:function:: create_main_db_store(workspace_name: str) -> str Create PostGIS database store in a GeoServer workspace for the main PostGIS database. If it already exists, do not do anything. :param workspace_name: The name of the workspace to create views for :type workspace_name: str :returns: The name of the new datastore created. :rtype: str :raises HTTPError: If geoserver responds with an error, raises it as an exception since it is unexpected. .. py:function:: create_workspace_if_not_exists(workspace_name: str) -> None Create a GeoServer workspace if it does not currently exist. :param workspace_name: The name of the workspace to create if it does not exists. :type workspace_name: str :raises HTTPError: If geoserver responds with an error, raises it as an exception since it is unexpected. .. py:function:: get_geoserver_url() -> str Retrieve full GeoServer URL from environment variables. :returns: The full GeoServer URL :rtype: str .. py:function:: add_gtiff_to_geoserver(gtiff_filepath: pathlib.Path, workspace_name: str, layer_name: str) -> None Upload a GeoTiff file to GeoServer, ready for serving to clients. :param gtiff_filepath: The filepath to the GeoTiff file to be served. :type gtiff_filepath: pathlib.Path :param workspace_name: The name of the existing GeoServer workspace that the store is to be added to. :type workspace_name: str :param layer_name: The name of the layer being added must be unique within the workspace. #todo check uniqueness :type layer_name: str .. py:function:: add_style(style_file: pathlib.Path, replace: bool = False) -> None Create a GeoServer style in the default workspace for rasters using a SLD style definition file. :param style_file: The path to the style definition (SLD) file to upload. :type style_file: pathlib.Path :param replace: True if you want to replace the existing style, False to skip adding the style if one already exists. :type replace: bool = False .. py:function:: 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. :param style_name: The name of the style to check for :type style_name: str :returns: True if the style exists, although it may be empty. False if it does not exist. :rtype: bool :raises HTTPError: If geoserver responds with anything but OK or NOT_FOUND, raises it as an exception since it is unexpected. .. py:class:: Workspaces Bases: :py:obj:`enum.StrEnum` Enum to label and access geoserver workspaces initialized within data_to_db.py. .. attribute:: STATIC_FILES_WORKSPACE Workspace containing layers loaded from static files. :type: str .. attribute:: INPUT_LAYERS_WORKSPACE Workspace containing layers loaded from external sources used as input for later modelling or visualisation. :type: str .. py:attribute:: STATIC_FILES_WORKSPACE :value: 'static_files' .. py:attribute:: INPUT_LAYERS_WORKSPACE :value: 'input_layers' .. py:attribute:: EXTRUDED_LAYERS_WORKSPACE :value: 'extruded_layers' .. py:function:: get_terria_catalog() -> Catalog Query geoserver for available layers from key workspaces, and return a terria catalog to serve the data. :returns: Represents the Terria JSON catalog items for each layer within the workspaces. :rtype: Catalog :raises HTTPError: If geoserver responds with anything but OK or NOT_FOUND, raises it as an exception since it is unexpected.