geoservercloud


Namegeoservercloud JSON
Version 0.3.1 PyPI version JSON
download
home_pageNone
SummaryLightweight Python client to interact with GeoServer Cloud REST API, GeoServer ACL and OGC services
upload_time2025-02-10 09:25:16
maintainerNone
docs_urlNone
authorCamptocamp
requires_python>=3.10
licenseBSD-2-Clause
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # python-geoservercloud

## Installation

From PyPI:

```shell
pip install geoservercloud
```

From git repository:

```shell
git clone https://github.com/camptocamp/python-geoservercloud
cd python-geoservercloud
python3 -m venv .venv
source .venv/bin/activate
poetry install
```

## Quick start

```python
from geoservercloud import GeoServerCloud
geoserver = GeoServerCloud(
    url="http://localhost:9090/geoserver/cloud/",
    user="admin",
    password="geoserver",
)
geoserver.create_workspace("newworkspace")
```

## About

Lightweight Python client to interact with GeoServer Cloud REST API, GeoServer ACL and OGC services.
Intended use cases are listed below.

### Programmatic setup of a GeoServer catalog

For example, creating a workspace, connecting to a PostGIS datastore and publishing a PG layer:

```python
geoserver.create_workspace("example")
geoserver.create_pg_datastore(
    workspace_name="example",
    datastore_name="example_store",
    pg_host="localhost",
    pg_port=5432,
    pg_db="database",
    pg_user="user",
    pg_password="password"
)
geoserver.create_feature_type(
    layer_name="layer_example",
    workspace_name="example",
    datastore_name="example_store",
    title={
        "en":"Layer title",
        "fr": "Titre de la couche",
        "default": "Default title",
    },
)
```

### Testing

Automatic tests of GeoServer functionalities with `pytest`, for example before upgrading.
The example below tests the fallback mechanism for internationalized layer titles in the GetCapabilities document.

```python
@pytest.mark.parametrize(
    "language,expected_title",
    [
        (
            "en",
            "Layer title",
        ),
        (
            "fr",
            "Titre de la couche",
        ),
        (
            "de,en",
            "Layer title",
        ),
        (
            None,
            "Default title",
        ),
    ],
)
def test_i18n_layer_title(geoserver, language, expected_title):
    capabilities = geoserver.get_wms_layers(
        workspace="example",
        accept_languages=language,
    )
    layer = capabilities.get("Layer")
    assert layer.get("Title") == expected_title
```

### Syncing

Copying a workspace from one GeoServer instance to another, including PG datastores, layers, styles and style images.

#### In a Python console or script

```python
from geoservercloud import GeoServerCloudSync
geoserversync = GeoServerCloudSync(
    src_url="http://localhost:8080/geoserver",
    src_user="admin",
    src_password="geoserver",
    dst_url="http://localhost:9099/geoserver",
    dst_user="admin",
    dst_password="geoserver",
)
geoserversync.copy_workspace("workspace_name", deep_copy=True)
```

#### In a shell terminal or script

First install the package in your current virtual environment (see [Installation](#installation)), then run the script with:

```shell
copy-workspace --src_url "http://localhost:8080/geoserver" --src_user admin --src_password geoserver --dst_url "http://localhost:9099/geoserver" --dst_user admin --dst_password geoserver --workspace workspace_name
```


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "geoservercloud",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": "Camptocamp",
    "author_email": "info@camptocamp.com",
    "download_url": "https://files.pythonhosted.org/packages/46/46/39ec3bbb1810a8366411958bfdc989b542d96cd2a938698d6372f59eedff/geoservercloud-0.3.1.tar.gz",
    "platform": null,
    "description": "# python-geoservercloud\n\n## Installation\n\nFrom PyPI:\n\n```shell\npip install geoservercloud\n```\n\nFrom git repository:\n\n```shell\ngit clone https://github.com/camptocamp/python-geoservercloud\ncd python-geoservercloud\npython3 -m venv .venv\nsource .venv/bin/activate\npoetry install\n```\n\n## Quick start\n\n```python\nfrom geoservercloud import GeoServerCloud\ngeoserver = GeoServerCloud(\n    url=\"http://localhost:9090/geoserver/cloud/\",\n    user=\"admin\",\n    password=\"geoserver\",\n)\ngeoserver.create_workspace(\"newworkspace\")\n```\n\n## About\n\nLightweight Python client to interact with GeoServer Cloud REST API, GeoServer ACL and OGC services.\nIntended use cases are listed below.\n\n### Programmatic setup of a GeoServer catalog\n\nFor example, creating a workspace, connecting to a PostGIS datastore and publishing a PG layer:\n\n```python\ngeoserver.create_workspace(\"example\")\ngeoserver.create_pg_datastore(\n    workspace_name=\"example\",\n    datastore_name=\"example_store\",\n    pg_host=\"localhost\",\n    pg_port=5432,\n    pg_db=\"database\",\n    pg_user=\"user\",\n    pg_password=\"password\"\n)\ngeoserver.create_feature_type(\n    layer_name=\"layer_example\",\n    workspace_name=\"example\",\n    datastore_name=\"example_store\",\n    title={\n        \"en\":\"Layer title\",\n        \"fr\": \"Titre de la couche\",\n        \"default\": \"Default title\",\n    },\n)\n```\n\n### Testing\n\nAutomatic tests of GeoServer functionalities with `pytest`, for example before upgrading.\nThe example below tests the fallback mechanism for internationalized layer titles in the GetCapabilities document.\n\n```python\n@pytest.mark.parametrize(\n    \"language,expected_title\",\n    [\n        (\n            \"en\",\n            \"Layer title\",\n        ),\n        (\n            \"fr\",\n            \"Titre de la couche\",\n        ),\n        (\n            \"de,en\",\n            \"Layer title\",\n        ),\n        (\n            None,\n            \"Default title\",\n        ),\n    ],\n)\ndef test_i18n_layer_title(geoserver, language, expected_title):\n    capabilities = geoserver.get_wms_layers(\n        workspace=\"example\",\n        accept_languages=language,\n    )\n    layer = capabilities.get(\"Layer\")\n    assert layer.get(\"Title\") == expected_title\n```\n\n### Syncing\n\nCopying a workspace from one GeoServer instance to another, including PG datastores, layers, styles and style images.\n\n#### In a Python console or script\n\n```python\nfrom geoservercloud import GeoServerCloudSync\ngeoserversync = GeoServerCloudSync(\n    src_url=\"http://localhost:8080/geoserver\",\n    src_user=\"admin\",\n    src_password=\"geoserver\",\n    dst_url=\"http://localhost:9099/geoserver\",\n    dst_user=\"admin\",\n    dst_password=\"geoserver\",\n)\ngeoserversync.copy_workspace(\"workspace_name\", deep_copy=True)\n```\n\n#### In a shell terminal or script\n\nFirst install the package in your current virtual environment (see [Installation](#installation)), then run the script with:\n\n```shell\ncopy-workspace --src_url \"http://localhost:8080/geoserver\" --src_user admin --src_password geoserver --dst_url \"http://localhost:9099/geoserver\" --dst_user admin --dst_password geoserver --workspace workspace_name\n```\n\n",
    "bugtrack_url": null,
    "license": "BSD-2-Clause",
    "summary": "Lightweight Python client to interact with GeoServer Cloud REST API, GeoServer ACL and OGC services",
    "version": "0.3.1",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c2d8e882d4f07a79634440cac340529bf3a8af87be44a2128d4a5477b352d4af",
                "md5": "4c4177ab419cdcef83200c5057d6c1f6",
                "sha256": "1d62a8fdc0ffc7e4960c68e39c56e2dca29544eec9769c92aa5b9e1caa0a2530"
            },
            "downloads": -1,
            "filename": "geoservercloud-0.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4c4177ab419cdcef83200c5057d6c1f6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 36326,
            "upload_time": "2025-02-10T09:25:14",
            "upload_time_iso_8601": "2025-02-10T09:25:14.419697Z",
            "url": "https://files.pythonhosted.org/packages/c2/d8/e882d4f07a79634440cac340529bf3a8af87be44a2128d4a5477b352d4af/geoservercloud-0.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "464639ec3bbb1810a8366411958bfdc989b542d96cd2a938698d6372f59eedff",
                "md5": "9d421a7989abffe60f76697ab3732edd",
                "sha256": "15b37a6a9062654022c45a957fec7023b16c10bc920043ff3ef5494a602908b4"
            },
            "downloads": -1,
            "filename": "geoservercloud-0.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "9d421a7989abffe60f76697ab3732edd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 26259,
            "upload_time": "2025-02-10T09:25:16",
            "upload_time_iso_8601": "2025-02-10T09:25:16.269514Z",
            "url": "https://files.pythonhosted.org/packages/46/46/39ec3bbb1810a8366411958bfdc989b542d96cd2a938698d6372f59eedff/geoservercloud-0.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-10 09:25:16",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "geoservercloud"
}
        
Elapsed time: 1.39424s