Skip to content

Commit

Permalink
Merge branch 'develop' into feature/reset-reload
Browse files Browse the repository at this point in the history
  • Loading branch information
krishnaglodha committed Jan 3, 2025
2 parents 0f955b3 + dc7dd5a commit d5d65c7
Show file tree
Hide file tree
Showing 55 changed files with 1,802 additions and 1,006 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.5.1
- name: Install dependencies
run: poetry install --with docs
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- run: pip install mkdocs-material
- run: mkdocs gh-deploy --force
- name: Deploy Documentation
run: |
poetry run mkdocs gh-deploy --force
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip install --upgrade pip
pip --version
- name: Install Poetry
uses: snok/install-poetry@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip install pip
pip --version
- name: Upgrade pip in virtual environments
shell: python
Expand Down
141 changes: 129 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,140 @@
# geoserverx
A GeoServer REST API client influenced by HTTPX
# GeoServerX

-----------
A modern, powerful GeoServer REST API client influenced by HTTPX, offering Sync, Async, and CLI capabilities.

`geoserverx` allows `Sync`, `Async` as well as `CLI` Capabilities to talk to your geoserver REST APIs which makes it ideal to be used in software development project which relies on content of geoserver.
[![Downloads](https://pepy.tech/badge/geoserverx)](https://pepy.tech/project/geoserverx)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
[![Built with Material for MkDocs](https://img.shields.io/badge/Material_for_MkDocs-526CFE?style=for-the-badge&logo=MaterialForMkDocs&logoColor=white)](https://squidfunk.github.io/mkdocs-material/)

Here is a simplistic view of how geoserverx works under the hood
![architecture](/docs/assets/images/arch.png "architecture")
## Features

- 🚀 Synchronous and Asynchronous API support
- 🖥️ Command Line Interface (CLI)
- 🔄 Complete GeoServer REST API coverage
- 🏗️ Modern Pythonic interface
- 📦 Easy to install and use
- 📝 Type hints for better development experience

## Installation

```bash
pip install geoserverx
```

## Quick Start

## Contribution guide
### Synchronous Usage

### Feature/Bug request
Please open new issue if you want to report any bug or send feature request
```python
from geoserverx._sync.gsx import SyncGeoServerX

### Running on local
`geoserverx` is built with [poetry](https://python-poetry.org/) and it uses following dependencies and dev-dependencies
# Initialize with default GeoServer settings
# Default: URL=http://localhost:8080/geoserver/rest, username=admin, password=geoserver
geo_server = SyncGeoServerX()

![layout](/docs/assets/images/layout.png "layout")
# Custom initialization
geo_server = SyncGeoServerX(
url="http://your-server:8080/geoserver/rest",
username="your_username",
password="your_password"
)

# Get all workspaces
workspaces = geo_server.get_all_workspaces()

# Access workspace information
print(workspaces) # Print Workspaces Model
print(workspaces.workspaces) # Print detailed list of workspaces
print(workspaces.workspaces.workspace[0].name) # Print first workspace name
```

### Asynchronous Usage

```python
from geoserverx._async.gsx import AsyncGeoServerX
import asyncio

async def main():
geo_server = AsyncGeoServerX()
workspaces = await geo_server.get_all_workspaces()
print(workspaces)

asyncio.run(main())
```

### CLI Usage

```bash
# Get help
geoserverx --help

# List workspaces
geoserverx workspaces list

# Add a new workspace
geoserverx workspaces create --name my_workspace
```

## Documentation

Detailed documentation is available through [Material for MkDocs](https://geobeyond.github.io/geoserverx/)

## Development Setup

Install Poetry (dependency management tool):

```bash
curl -sSL https://install.python-poetry.org | python3 -
```

```bash
# Clone the repository:
git clone https://github.com/geobeyond/geoserverx.git
cd geoserverx
```

```bash
# Install dependencies:
poetry install
```

```bash

# Activate virtual environment:
poetry shell
```

## Contributing

We welcome contributions! Here's how you can help:

- Check for open issues or create a new one to discuss new features or bugs.
- Fork the repo and create a new branch for your contribution.
- Write your code and tests.
- Send a pull request.

## Development Guidelines

- Follow [Black](https://black.readthedocs.io/en/stable/) code style
- Use [isort](https://pycqa.github.io/isort/index.html) ([black profile](https://pycqa.github.io/isort/docs/configuration/black_compatibility.html)) for import sorting
- Use [Ruff](https://docs.astral.sh/ruff/) for linting
- Ensure all tests pass
- Add tests for new features
- Update documentation as needed

## Bug Reports and Feature Requests

Please use the GitHub issue tracker to report bugs or request features.

## License

This project is licensed under the MIT License - see the LICENSE file for details.

## Acknowledgments

- HTTPX for inspiration
- GeoServer community
- All contributors who have helped shape this project
23 changes: 20 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---
hide:
- navigation
- toc

title : GeoServerX
description: modern python and CLI package for communicating with GeoServer
---
# Welcome to geoserverx

`geoserverx` is a modern Python package that provides an efficient and scalable way to interact with Geoserver REST APIs. It leverages the asynchronous capabilities of Python to offer a high-performance and reliable solution for managing Geoserver data and services.
Expand All @@ -24,13 +32,22 @@ pip install geoserverx

After which , It can be used in Python projects using <i>sync, async</i> methods or can ve used as Command Line tool

## Architecture

`geoserverx` is built on top of `httpx` and `pydantic` libraries. It uses `httpx` for making HTTP requests and `pydantic` for data validation. The package is designed to be modular and extensible, allowing for easy integration with other libraries and frameworks.

The package is structured into two main components: the `SyncGeoServerX` class and the `AsyncGeoServerX` class. The `SyncGeoServerX` class provides synchronous methods for interacting with Geoserver, while the `AsyncGeoServerX` class provides asynchronous methods using the `anyio` library

![layout](./assets/images/layout.png){ align=left }


## For testing purpose
If you don't have geoserver installed locally, feel free to use following command to quickly spin up Geoserver using [Docker](https://www.docker.com/)
If you don't have GeoServer installed locally, feel free to use following command to quickly spin up Geoserver using [Docker](https://www.docker.com/)

<div class="termy">
```console
docker run -e GEOSERVER_ADMIN_USER=admin -e GEOSERVER_ADMIN_PASSWORD=geoserver -e SAMPLE_DATA=true -p 8080:8080 kartoza/geoserver
docker run -e GEOSERVER_ADMIN_USER=admin -e GEOSERVER_ADMIN_PASSWORD=geoserver -e SAMPLE_DATA=true -p 8080:8080 kartoza/GeoServer
```
</div>

Please not that this will work on amd64 architecture machines.
Please note that this will work on amd64 architecture machines.
32 changes: 16 additions & 16 deletions docs/pages/async/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ Here, we'll have a look at implementation `geoserverx` asynchronous Class

## Setup Class instance

`AsyncGeoServerX` Class has default username, password, url which points to default geoserver settings.
`AsyncGeoServerX` Class has default username, password, url which points to default GeoServer settings.
```Python
# Import class from package
from geoserverx._async.gsx import AsyncGeoServerX
import asyncio
# Create class Instance with default paramaters
client = AsyncGeoServerX()
```
We'll assume connection to local geoserver with default credentials
We'll assume connection to local GeoServer with default credentials

## Get all workspaces

Expand All @@ -29,7 +29,7 @@ async def get_info_raster_workspaces(url, username, password):
print(await client.get_all_workspaces())

async def main():
await asyncio.gather(get_info_raster_workspaces(url='http://localhost:8080/geoserver/rest/',username='admin', password='geoserver'),get_info_raster_workspaces(url='http://89.233.108.250:8080/geoserver/rest',username='admin', password='myP'),get_info_raster_workspaces(url='http://localhost:8080/geoserver/rest/',username='admin', password='geoserver'))
await asyncio.gather(get_info_raster_workspaces(url='http://localhost:8080/geoserver/rest/',username='admin', password='GeoServer'),get_info_raster_workspaces(url='http://locahost:8080/geoserver/rest',username='admin', password='myP'),get_info_raster_workspaces(url='http://localhost:8080/geoserver/rest/',username='admin', password='GeoServer'))

asyncio.run(main())

Expand All @@ -53,7 +53,7 @@ async def get_info_raster_workspaces(url, username, password,workspace):
print(await client.get_workspace(workspace))

async def main():
await asyncio.gather(get_info_raster_workspaces(url='http://localhost:8080/geoserver/rest/',username='admin', password='geoserver',workspace='cesium'))
await asyncio.gather(get_info_raster_workspaces(url='http://localhost:8080/geoserver/rest/',username='admin', password='GeoServer',workspace='cesium'))

asyncio.run(main())

Expand All @@ -80,13 +80,13 @@ async def create_single_workspaces(url, username, password,workspace,default,iso

async def main():
await asyncio.gather(create_single_workspaces(
url='http://localhost:8080/geoserver/rest/',username='admin', password='geoserver',
url='http://localhost:8080/geoserver/rest/',username='admin', password='GeoServer',
workspace='AsyncMyDefault',default=True,isolated= False),
create_single_workspaces(
url='http://localhost:8080/geoserver/rest/',username='admin', password='geoserver',
url='http://localhost:8080/geoserver/rest/',username='admin', password='GeoServer',
workspace='AsyncMyHidden',default=False,isolated= True),
create_single_workspaces(
url='http://localhost:8080/geoserver/rest/',username='admin', password='geoserver',
url='http://localhost:8080/geoserver/rest/',username='admin', password='GeoServer',
workspace='AsyncMySimple',default=False,isolated= False))

asyncio.run(main())
Expand Down Expand Up @@ -114,7 +114,7 @@ async def create_single_workspaces(url, username, password,workspace):

async def main():
await asyncio.gather(create_single_workspaces(
url='http://localhost:8080/geoserver/rest/',username='admin', password='geoserver',
url='http://localhost:8080/geoserver/rest/',username='admin', password='GeoServer',
workspace='cesium'))

asyncio.run(main())
Expand All @@ -138,7 +138,7 @@ async def get_info_vector_workspaces(url, username, password,workspace,store):

async def main():
await asyncio.gather(get_info_vector_workspaces(
url='http://localhost:8080/geoserver/rest/',username='admin', password='geoserver',
url='http://localhost:8080/geoserver/rest/',username='admin', password='GeoServer',
workspace='cesium',store='myshp'))

asyncio.run(main())
Expand All @@ -163,7 +163,7 @@ def add_vector_workspaces(url, username, password,workspace,store,file):
client = SyncGeoServerX(username, password,url)
return client.create_file_store(workspace, store, file, service_type='shapefile')
result = add_vector_workspaces(url='http://localhost:8080/geoserver/rest/',username='admin', password='geoserver',
result = add_vector_workspaces(url='http://localhost:8080/geoserver/rest/',username='admin', password='GeoServer',
workspace='cesium',store='myshp', file='safe_users.zip' )
print(result.json())
Expand All @@ -188,7 +188,7 @@ async def get_all_raster_workspaces(url, username, password,workspace):

async def main():
await asyncio.gather(get_all_raster_workspaces(
url='http://localhost:8080/geoserver/rest/',username='admin', password='geoserver',workspace='cesium'))
url='http://localhost:8080/geoserver/rest/',username='admin', password='GeoServer',workspace='cesium'))

asyncio.run(main())

Expand All @@ -211,7 +211,7 @@ async def get_info_raster_workspaces(url, username, password,workspace,store):

async def main():
await asyncio.gather(get_info_raster_workspaces(
url='http://localhost:8080/geoserver/rest/',username='admin', password='geoserver',workspace='cesium',store='dsm'))
url='http://localhost:8080/geoserver/rest/',username='admin', password='GeoServer',workspace='cesium',store='dsm'))

asyncio.run(main())

Expand All @@ -221,7 +221,7 @@ coverageStore=CoveragesStoreModelDetail(name='dsm', description=None, enabled=Tr
'''
```

## Get all Styles in geoserver
## Get all Styles in GeoServer

```Python hl_lines="7"
from geoserverx._async.gsx import AsyncGeoServerX
Expand All @@ -234,7 +234,7 @@ async def get_info_raster_workspaces(url, username, password):

async def main():
await asyncio.gather(get_info_raster_workspaces(
url='http://localhost:8080/geoserver/rest/',username='admin', password='geoserver'))
url='http://localhost:8080/geoserver/rest/',username='admin', password='GeoServer'))

asyncio.run(main())

Expand All @@ -244,7 +244,7 @@ styles=allStyle(style=[allStyleList(name='burg', href='http://localhost:8080/geo
'''
```

## Get Single Style in geoserver
## Get Single Style in GeoServer

```Python hl_lines="7"
from geoserverx._async.gsx import AsyncGeoServerX
Expand All @@ -257,7 +257,7 @@ async def get_info_raster_workspaces(url, username, password,style):

async def main():
await asyncio.gather(get_info_raster_workspaces(
url='http://localhost:8080/geoserver/rest/',username='admin', password='geoserver',style='poi'))
url='http://localhost:8080/geoserver/rest/',username='admin', password='GeoServer',style='poi'))

asyncio.run(main())
''' Console
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/async/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

## Setup Class instance

`AsyncGeoServerX` Class has default username, password, url which points to default geoserver settings.
`AsyncGeoServerX` Class has default username, password, url which points to default GeoServer settings.
```Python
# Import class from package
from geoserverx._async.gsx import AsyncGeoServerX
Expand Down
6 changes: 3 additions & 3 deletions docs/pages/async/raster-store.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Raster Stores

`geoserverx` allows users to access all/one raster stores from geoserver
`geoserverx` allows users to access all/one raster stores from GeoServer


## Get all raster stores
This command fetches all Vector store available in given workspace from geoserver.
This command fetches all Vector store available in given workspace from GeoServer.

```py
# Get all raster stores available in `cite` workspace
Expand All @@ -14,7 +14,7 @@ await client.get_raster_stores_in_workspaces('cite')

## Get single raster store

This command fetches all Information about raster store available in given workspace from geoserver.
This command fetches all Information about raster store available in given workspace from GeoServer.

```Python
# Get all information about `image` raster stores available in `cite` workspace
Expand Down
Loading

0 comments on commit d5d65c7

Please sign in to comment.