geoservercloud.py
- class geoservercloud.GeoServerCloud(url: str = 'http://localhost:9090/geoserver/cloud', user: str = 'admin', password: str = 'geoserver', verifytls: bool = True)
Bases:
objectFacade class allowing CRUD operations on GeoServer resources
- url
base GeoServer URL
- Type:
str
- user
GeoServer username
- Type:
str
- password
GeoServer password
- Type:
str
- assign_role_to_user(user: str, role: str) tuple[str, int]
Assign a role to a GeoServer user
- cleanup()
Cleanup internal state
- create_acl_admin_rule(priority: int = 0, access: str = 'ADMIN', role: str | None = None, user: str | None = None, workspace_name: str | None = None) tuple[dict | str, int]
Create a GeoServer ACL admin rule
- create_acl_rule(priority: int = 0, access: str = 'DENY', role: str | None = None, user: str | None = None, service: str | None = None, request: str | None = None, workspace_name: str | None = None) tuple[dict | str, int]
Create a GeoServer ACL data rule
- create_acl_rules_for_requests(requests: list[str], priority: int = 0, access: str = 'DENY', role: str | None = None, service: str | None = None, workspace_name: str | None = None) list[tuple[dict | str, int]]
Create ACL rules for multiple type of OGC requests
- create_coverage(workspace_name: str, coveragestore_name: str, coverage_name: str, title: str | None = None, native_name: str | None = None) tuple[str, int]
Publish a coverage layer from a given coverage store
- create_coverage_store(workspace_name: str, coveragestore_name: str, url: str, type: str = 'ImageMosaic', enabled: bool = True, metadata: dict | None = None) tuple[dict[str, Any] | str, int]
Create a coverage store from a store definition. When using a directory path as URL, coverages will be auto-discovered
- Parameters:
workspace_name – Name of the workspace
coveragestore_name – Name of the coverage store
url – Directory path on the server or URL of the granules (raster images)
type – Type of the coverage store, e.g. ImageMosaic, GeoTIFF (default: ImageMosaic)
enabled – Whether the coverage store is enabled (default: True)
metadata – Optional metadata dictionary (e.g. {“cogSettings”: {“rangeReaderSettings”: “HTTP”}})
- create_datastore(workspace_name: str, datastore_name: str, datastore_type: str, connection_parameters: dict[str, Any], description: str | None = None, enabled: bool = True, set_default_datastore: bool = False) tuple[str, int]
Create a generic datastore of any type in GeoServer, or update if it already exists. This method accepts flexible connection parameters, allowing to create any type of datastore.
- Parameters:
workspace_name (str) – Name of the workspace
datastore_name (str) – Name for the datastore
datastore_type (str) – Type of datastore (e.g., “PostGIS”, “Shapefile”, “Directory of spatial files (shapefiles)”)
connection_parameters (dict) – Dict of connection parameters specific to the datastore type
description (str, optional) – Optional description
enabled (bool, optional) – Whether the datastore should be enabled (default: True)
set_default_datastore (bool, optional) – Whether to set as default datastore (default: False)
- Returns:
Tuple of (datastore_name, status_code)
- Return type:
tuple
- Example:
>>> create_datastore( ... workspace_name="myworkspace", ... datastore_name="my_store", ... datastore_type="PostGIS", ... connection_parameters={ ... "dbtype": "postgis", ... "host": "localhost", ... "port": 5432, ... "database": "mydb", ... "user": "user", ... "passwd": "password", ... "schema": "public", ... "Expose primary keys": "true", ... } ... )
- create_feature_type(layer_name: str, workspace_name: str | None = None, datastore_name: str | None = None, title: str | dict | None = None, abstract: str | dict | None = None, attributes: dict | None = None, epsg: int = 4326, keywords: list[str] = [], time_dimension_info: TimeDimensionInfo | None = None, layer_links: list[dict[str, str]] = []) tuple[str, int]
Create a feature type or update it if it already exists.
- Parameters:
layer_name (str) – Name of the feature type / layer
workspace_name (str) – Name of the workspace
datastore_name (str) – Name for the datastore
title (str or dict, optional) – Title for the feature type (can be internationalized as dict)
abstract (str or dict, optional) – Abstract for the feature type (can be internationalized as dict)
attributes (dict, optional) – Dict defining the feature type attributes (name and type). If omitted, GeoServer will infer the attributes from the native table
epsg (int, optional) – EPSG code for the feature type SRS (default: 4326)
keywords (list of str, optional) – List of keywords for the feature type
time_dimension_info (TimeDimensionInfo, optional) – Time dimension configuration for the feature type
layer_links (list of dict, optional) – List of metadata links for the feature type, e.g. [{‘content’:”mymetadataurl”, ‘metadataType’:”ISO19115:2003”, ‘type’:”text/xml”}]
- Returns:
Tuple of (datastore_name, status_code)
- Return type:
tuple
- Example:
>>> create_feature_type( ... layer_name="mylayer", ... workspace_name="myworkspace", ... datastore_name="mystore", ... title={"en": "English Title"}, ... abstract={"en": "English Abstract"}, ... attributes={ ... "geom": { ... "type": "Point", ... "required": True, ... }, ... "id": { ... "type": "integer", ... "required": True, ... }, ... "title": { ... "type": "string", ... "required": False, ... }, ... "timestamp": { ... "type": "datetime", ... "required": False, ... }, ... }, ... epsg=4326, ... keywords=["example"], ... time_dimension_info=TimeDimensionInfo( ... attribute="timestamp", ... presentation="LIST", ... default_value_strategy="MAXIMUM", ... ), ... layer_links=[{'content':"mymetadataurl", 'metadataType':"ISO19115:2003", 'type':"text/xml"}] ... )
- create_gridset(epsg: int) tuple[str, int]
Create a gridset for GeoWebCache for a given projection Supported EPSG codes are 2056, 21781 and 3857
- create_imagemosaic_store_from_directory(workspace_name: str, coveragestore_name: str, directory_path: str) tuple[str, int]
Create an ImageMosaic coverage store from a directory on the server which contains granules (raster images). Granules and coverages will be auto-discovered. Similar to creating a store from the WebUI. Calls /workspaces/{workspace_name}/coveragestores/{coveragestore_name}/external.imagemosaic
- create_imagemosaic_store_from_properties_zip(workspace_name: str, coveragestore_name: str, properties_zip: bytes) tuple[str, int]
Upload an ImageMosaic coverage store configuration as ZIP to create an empty coverage store. The ZIP contains two files: indexer.properties and datastore.properties Calls /workspaces/{workspace_name}/coveragestores/{coveragestore_name}/file.imagemosaic?configure=none
- create_jndi_datastore(workspace_name: str, datastore_name: str, jndi_reference: str, pg_schema: str = 'public', description: str | None = None, set_default_datastore: bool = False) tuple[str, int]
Create a PostGIS datastore from JNDI resource, or update it if it already exist.
- create_layer_group(group: str, workspace_name: str | None, layers: list[str] | None = None, styles: list[str] | None = None, title: str | dict | None = None, abstract: str | dict | None = None, epsg: int = 4326, mode: str = 'SINGLE', enabled: bool = True, advertised: bool = True, global_styles: bool = False) tuple[str, int]
Create a layer group or update it if it already exists.
- create_pg_datastore(workspace_name: str, datastore_name: str, pg_host: str, pg_port: int, pg_db: str, pg_user: str, pg_password: str, pg_schema: str = 'public', description: str | None = None, set_default_datastore: bool = False) tuple[str, int]
Create a PostGIS datastore from the DB connection parameters, or update it if it already exist.
- create_pmtiles_datastore(workspace_name: str, datastore_name: str, pmtiles_url: str, description: str | None = None, range_reader_provider: str = 'file', caching_enabled: bool = True, caching_block_aligned: bool = True, http_timeout_millis: int = 5000, http_trust_all_certificates: bool = False, s3_use_default_credentials_provider: bool = False, s3_force_path_style: bool = True, gcs_default_credentials_chain: bool = False) tuple[str, int]
Create a PMTiles datastore, or update it if it already exists.
- Parameters:
workspace_name (str) – Name of the workspace
datastore_name (str) – Name for the PMTiles datastore
pmtiles_url (str) – URL or path to the PMTiles file
description (str, optional) – Optional description for the datastore
range_reader_provider (str, optional) – Range reader provider type (default: “file”)
caching_enabled (bool, optional) – Enable caching for range reader (default: True)
caching_block_aligned (bool, optional) – Enable block-aligned caching (default: True)
http_timeout_millis (int, optional) – HTTP timeout in milliseconds (default: 5000)
http_trust_all_certificates (bool, optional) – Trust all SSL certificates for HTTP (default: False)
s3_use_default_credentials_provider (bool, optional) – Use default AWS credentials provider for S3 (default: False)
s3_force_path_style (bool, optional) – Force path-style access for S3 (default: True)
gcs_default_credentials_chain (bool, optional) – Use default credentials chain for Google Cloud Storage (default: False)
- Returns:
Tuple of (datastore_name, status_code)
- Return type:
tuple
- Example:
>>> create_pmtiles_datastore( ... workspace_name="pmtiles_workspace", ... datastore_name="pmtiles_store", ... pmtiles_url="file:///mnt/pmtiles/mypmtilesfile.pmtiles", ... description="My PMTiles datastore", ... range_reader_provider="file", ... )
- create_role(role_name: str) tuple[str, int]
Create a GeoServer role if it does not already exist
- create_style_definition(style_name: str, filename: str, workspace_name: str | None = None, format: str = 'sld') tuple[str, int]
Create a style definition
- create_style_from_file(style_name: str, file: str, workspace_name: str | None = None) tuple[str, int]
Create a style from a file, or update it if it already exists. Supported file extensions are .sld, .zip and .mbstyle.
- create_style_from_string(style_name: str, style_string: str, workspace_name: str | None = None) tuple[str, int]
Create a style (SLD) from its definition as a string or update it if it already exists.
- create_user(user: str, password: str, enabled: bool = True) tuple[str, int]
Create a GeoServer user
- create_wms(workspace: str | None = None) None
- create_wms_layer(workspace_name: str, wms_store_name: str, native_layer_name: str, published_layer_name: str | None = None) tuple[str, int]
Publish a remote WMS layer If it already exists, delete and recreate it (update is not supported by GeoServer)
- create_wms_store(workspace_name: str, wms_store_name: str, capabilities_url: str) tuple[str, int]
Create a cascaded WMS store, or update it if it already exist.
- create_wmts(workspace_name: str | None = None) None
- create_wmts_layer(workspace_name: str, wmts_store: str, native_layer: str, published_layer: str | None = None, epsg: int = 4326, international_title: dict[str, str] | None = None, international_abstract: dict[str, str] | None = None) tuple[str, int]
Publish a remote WMTS layer (first delete it if it already exists)
- create_wmts_store(workspace_name: str, name: str, capabilities: str) tuple[str, int]
Create a cascaded WMTS store, or update it if it already exist.
- create_workspace(workspace_name: str, isolated: bool = False, set_default_workspace: bool = False) tuple[str, int]
Create a workspace in GeoServer, if it does not already exist. It if exists, update it
- delete_acl_admin_rule(id: int | str) tuple[str, int]
Delete a GeoServer ACL admin rule by id
- delete_all_acl_admin_rules() tuple[str, int]
Delete all existing GeoServer ACL admin rules
- delete_all_acl_rules() tuple[str, int]
Delete all existing GeoServer ACL data rules
- delete_coverage_store(workspace_name: str, coveragestore_name: str) tuple[str, int]
Delete a coverage store recursively
- delete_feature_type(workspace_name: str, datastore_name: str, layer_name: str) tuple[str, int]
Delete a feature type and associated layer
- delete_gwc_layer(workspace_name: str, layer: str) tuple[str, int]
- delete_layer_group(workspace_name: str, layer_group_name: str) tuple[str, int]
Delete a layer group
- delete_role(role_name: str) tuple[str, int]
Delete a GeoServer role
- delete_user(user: str) tuple[str, int]
Delete a GeoServer user
- delete_wms_layer(workspace_name: str, wms_store_name: str, wms_layer_name: str) tuple[str, int]
Delete a WMS layer
- delete_wms_store(workspace_name: str, wms_store_name: str) tuple[str, int]
Delete a WMS store recursively
- delete_wmts_store(workspace_name: str, wmts_store_name: str) tuple[str, int]
Delete a WMTS store recursively
- delete_workspace(workspace_name: str) tuple[str, int]
Delete a GeoServer workspace (recursively)
- describe_feature_type(workspace_name: str | None = None, type_name: str | None = None, format: str = 'application/json') dict[str, Any] | str
WFS DescribeFeatureType request Return the feature type(s) as dict if found, otherwise return the response content as string
- get_acl_rules() tuple[dict[str, Any] | str, int]
Return all GeoServer ACL data rules
- get_coverage(workspace_name: str, coveragestore_name: str, coverage_name: str) tuple[dict[str, object] | str, int]
Get a single coverage for a given workspace, coverage store, and coverage name
- get_coverage_store(workspace_name: str, coveragestore_name: str) tuple[dict[str, Any] | str, int]
Get a coverage store by workspace and name
- get_coverages(workspace_name: str, coveragestore_name: str) tuple[list[dict[str, str]] | str, int]
Get all coverages for a given workspace and coverage store
- get_datastore(workspace_name: str, datastore_name: str) tuple[dict[str, Any] | str, int]
Get a datastore by workspace and name
- get_datastores(workspace_name: str) tuple[list[dict[str, str]] | str, int]
Get all datastores for a given workspace
- get_feature(workspace_name: str, type_name: str, feature_id: int | None = None, max_feature: int | None = None, format: str = 'application/json') dict[str, Any] | str
WFS GetFeature request Return the feature(s) as dict if found, otherwise return the response content as string
- get_feature_info(layers: list[str], bbox: tuple[float, float, float, float], size: tuple[int, int], srs: str = 'EPSG:2056', info_format: str = 'application/json', transparent: bool = True, styles: list[str] | None = None, xy: list[float] = [0, 0], workspace_name: str | None = None) ResponseWrapper | None
WMS GetFeatureInfo request
- get_feature_type(workspace_name: str, datastore_name: str, feature_type_name: str) tuple[dict[str, Any] | str, int]
Get a feature type by workspace, datastore and name
- get_feature_types(workspace_name: str, datastore_name: str) tuple[list[dict[str, Any]] | str, int]
Get all feature types for a given workspace and datastore
- get_gwc_layer(workspace_name: str, layer: str) tuple[dict[str, Any] | str, int]
- get_layer_group(workspace_name: str, layer_group_name: str) tuple[dict[str, Any] | str, int]
Get a layer group by name
- get_layer_groups(workspace_name: str) tuple[list[dict[str, str]] | str, int]
Get all layer groups for a given workspace
- get_legend_graphic(layer: str | list[str], format: str = 'image/png', language: str | None = None, style: str | None = None, workspace_name: str | None = None) Response
WMS GetLegendGraphic request
- get_map(layers: list[str], bbox: tuple[float, float, float, float], size: tuple[int, int], srs: str = 'EPSG:2056', format: str = 'image/png', transparent: bool = True, styles: list[str] | None = None, language: str | None = None) ResponseWrapper | None
WMS GetMap request
- get_pg_datastore(workspace_name: str, datastore_name: str) tuple[dict[str, Any] | str, int]
Get a datastore by workspace and name
- get_property_value(workspace_name: str, type_name: str, property: str) dict | list | str
WFS GetPropertyValue request Return the properties as dict (if one feature was found), a list (if multiple features were found), an empty dict if no feature was found or the response content as string
- get_style_definition(style: str, workspace_name: str | None = None) tuple[dict[str, Any] | str, int]
Get a style definition by name
- get_styles(workspace_name: str | None = None) tuple[list[dict[str, str]] | str, int]
Get all styles for a given workspace. If no workspace is provided, get all global styles
- get_tile(layer: str, format: str, tile_matrix_set: str, tile_matrix: str, row: int, column: int, workspace_name: str | None = None) ResponseWrapper | None
WMTS GetTile request
- Parameters:
layer – Name of the WMTS layer
format – Image format (e.g. “image/png”)
tile_matrix_set – Tile matrix set (e.g. “EPSG:3857”)
tile_matrix – Tile matrix (zoom level)
row – Tile row
column – Tile column
workspace_name – Optional workspace name
- Returns:
owslib.util.ResponseWrapper with the tile image or None
- get_user_roles(user: str) tuple[list[str] | str, int]
Get all roles assigned to a GeoServer user
- get_version() tuple[dict[str, dict[str, list]] | str, int]
Get GeoServer version information
- Returns:
- A tuple containing:
content (dict[str, dict[str, list]] or str): The version information as a dictionary if the request is successful ({‘about’: {‘resource’: […]}}) or an error message as a string if the request fails.
status (int): The HTTP status code of the response.
- Return type:
tuple
- get_wfs_layers(workspace_name: str) Any | dict[str, Any]
- get_wms_layer(workspace_name: str, wms_store_name: str, wms_layer_name: str) tuple[dict[str, Any] | str, int]
Get a WMS layer by workspace, store and name
- get_wms_layers(workspace_name: str, accept_languages: str | None = None) Any | dict[str, Any]
- get_wms_store(workspace_name: str, datastore_name: str) tuple[dict[str, Any] | str, int]
Get a WMS by workspace and name
- get_workspace(workspace_name: str) tuple[dict[str, str] | str, int]
Get a workspace by name
- get_workspace_wms_settings(workspace_name: str) tuple[dict[str, Any] | str, int]
Get the WMS settings for a given workspace
- get_workspaces() tuple[list[dict[str, str]] | str, int]
Get all GeoServer workspaces
- harvest_granules_to_coverage_store(workspace_name: str, coveragestore_name: str, directory_path: str) tuple[str, int]
Harvest granules (raster files) from a server directory into an existing ImageMosaic coverage store
- publish_granule_to_coverage_store(workspace_name: str, coveragestore_name: str, method: str, granule_path: str) tuple[str, int]
Publish a single granule (raster image) to an existing ImageMosaic coverage store. The granule is an existing file stored either on the server or remotely.
- Parameters:
workspace_name – Name of the workspace
coveragestore_name – Name of the coverage store
method – “external” for a file on the server, “remote” for a remote file
granule_path – file path (for external granules) or URL (for remote granules)
- publish_gwc_layer(workspace_name: str, layer: str, epsg: int = 4326) tuple[str, int]
- publish_workspace(workspace_name: str, versions: list[str] = ['1.1.1', '1.3.0'], cite_compliant: bool = False, schema_base_url: str = 'http://schemas.opengis.net', verbose: bool = False, bbox_for_each_crs: bool = False, watermark: dict = {'enabled': False, 'position': 'BOT_RIGHT', 'transparency': 100}, interpolation: str = 'Nearest', get_feature_info_mime_type_checking_enabled: bool = False, get_map_mime_type_checking_enabled: bool = False, dynamic_styling_disabled: bool = False, features_reprojection_disabled: bool = False, max_buffer: int = 0, max_request_memory: int = 0, max_rendering_time: int = 0, max_rendering_errors: int = 0, max_requested_dimension_values: int = 100, cache_configuration: dict = {'enabled': False, 'maxEntries': 1000, 'maxEntrySize': 51200}, remote_style_max_request_time: int = 60000, remote_style_timeout: int = 30000, default_group_style_enabled: bool = True, transform_feature_info_disabled: bool = False, auto_escape_template_values: bool = False) tuple[str, int]
Publish the WMS service for a given workspace
- recreate_workspace(workspace_name: str, isolated: bool = False, set_default_workspace: bool = False) tuple[str, int]
Create a workspace in GeoServer, and first delete it if it already exists.
- remove_role_from_user(user: str, role: str) tuple[str, int]
Remove a role from a GeoServer user
- set_default_layer_style(layer_name: str, workspace_name: str, style: str) tuple[str, int]
Set the default style for a layer
- set_default_locale_for_service(workspace_name: str, locale: str | None) tuple[str, int]
Set a default language for localized WMS requests
- unset_default_locale_for_service(workspace_name) tuple[str, int]
Remove the default language for localized WMS requests
- update_user(user: str, password: str | None = None, enabled: bool | None = None) tuple[str, int]
Update a GeoServer user