geoservercloud


Namegeoservercloud JSON
Version 0.4.0 PyPI version JSON
download
home_pageNone
SummaryLightweight Python client to interact with GeoServer Cloud REST API, GeoServer ACL and OGC services
upload_time2025-03-06 14:43:55
maintainerNone
docs_urlNone
authorCamptocamp
requires_python<4.0,>=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": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": "Camptocamp",
    "author_email": "info@camptocamp.com",
    "download_url": "https://files.pythonhosted.org/packages/0c/ec/c7b42585370adf7e3b95a6240a005c00d0ec0d0e6c04d6d70b95d8bcfd78/geoservercloud-0.4.0.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.4.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "46c4e0b209896a8b296c427ba1e71a0d99cd7aba2fc1b131bd420756dadb463b",
                "md5": "6fd5563612a97d8c956de8d7b07800aa",
                "sha256": "ca75bd9b4bdf1ad6df4f2d3a0f2b941fedae4727239f6ae5970abe5d767f7cb6"
            },
            "downloads": -1,
            "filename": "geoservercloud-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6fd5563612a97d8c956de8d7b07800aa",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 39647,
            "upload_time": "2025-03-06T14:43:54",
            "upload_time_iso_8601": "2025-03-06T14:43:54.467269Z",
            "url": "https://files.pythonhosted.org/packages/46/c4/e0b209896a8b296c427ba1e71a0d99cd7aba2fc1b131bd420756dadb463b/geoservercloud-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0cecc7b42585370adf7e3b95a6240a005c00d0ec0d0e6c04d6d70b95d8bcfd78",
                "md5": "f4409163f6c6511dd609e11670a2e1a3",
                "sha256": "8c24a907162802d3861039a701128773f55258b6093ca09e0b82a570e9d69141"
            },
            "downloads": -1,
            "filename": "geoservercloud-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f4409163f6c6511dd609e11670a2e1a3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 27755,
            "upload_time": "2025-03-06T14:43:55",
            "upload_time_iso_8601": "2025-03-06T14:43:55.613127Z",
            "url": "https://files.pythonhosted.org/packages/0c/ec/c7b42585370adf7e3b95a6240a005c00d0ec0d0e6c04d6d70b95d8bcfd78/geoservercloud-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-03-06 14:43:55",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "geoservercloud"
}
        
Elapsed time: 2.50383s