Skip to content

Commit

Permalink
Merge branch 'develop' into feature/system-status
Browse files Browse the repository at this point in the history
  • Loading branch information
krishnaglodha committed Jan 3, 2025
2 parents 3a802cf + dc7dd5a commit 3dcdf2e
Show file tree
Hide file tree
Showing 13 changed files with 985 additions and 510 deletions.
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
56 changes: 48 additions & 8 deletions docs/pages/async/workspace.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Workspaces
# Workspaces

`geoserverx` allows users to access all/one workspace from GeoServer, along with ability to add new workspaces.
`geoserverx` allows users to access all/one workspace from GeoServer, along with ability to do CRUD operations on workspaces.

!!! get "Get started"
To start using `geoserverx` in Sync mode, create a new instance of `AsyncGeoServerX` Class, read more about it [here](https://geobeyond.github.io/geoserverx/pages/async/)

## Get all workspaces

This command fetches all workspaces available in GeoServer. No parameters are required to be passed.

```py
Expand All @@ -11,21 +15,57 @@ await client.get_all_workspaces()
```

## Get single workspace
This command fetches workspace with paramter as name of it from GeoServer.

Fetches workspace details.

```Python
# Get workspace with name `cite`
await client.get_workspace('cite')
```

## Create workspace
This command allows user to create new workspace.

This command allows user to create new workspace.
Creating new workspace requires following parameters

* Name `str` : To define Name of the workspace
* default `bool` : To define whether to keep workspace as default or not
* Isolated `bool` : To define whether to keep workspace Isolated or not

| Parameter | Required | Default value | Data type | Description |
| --------- | ----------------------------- | ------------- | --------- | ------------------------------------------------------ |
| Name | :white_check_mark: | | `str` | To define Name of the workspace |
| default | :negative_squared_cross_mark: | `False` | `bool` | To define whether to keep workspace as default or not |
| isolated | :negative_squared_cross_mark: | `False` | `bool` | To define whether to keep workspace as Isolated or not |

```Python
#Create new workspace with name `my_wrkspc` , make it Default and Isolated
await client.create_workspace(name='my_wrkspc',default=True,Isolated=True)
```

## Delete workspace

This command allows user to delete workspace.

| Parameter | Required | Default value | Data type | Description |
| --------- | ----------------------------- | ------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| workspace | :white_check_mark: | | `str` | Name of the workspace |
| recurse | :negative_squared_cross_mark: | `False` | `bool` | This parameter recursively deletes all layers referenced by the specified workspace, including data stores, coverage stores, feature types, and so on |

```Python
#Delete workspace with name `my_wrkspc`.
await client.delete_workspace(workspace='my_wrkspc',recurse=True)
```

## Update workspace

This command allows user to update existing workspace.
Updating workspace requires following parameters

| Parameter | Required | Data type | Description |
| --------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
| name | :white_check_mark: | `str` | Name of the workspace to be updated |
| update | :white_check_mark: | [`UpdateWorkspaceInfo`](https://github.com/geobeyond/geoserverx/blob/b7757c9f0130864b06c40c2faa17afc841fc705f/src/geoserverx/models/workspace.py#L42) | To define body of the update request |

```Python
#Updating workspace with name `my_wrkspc` , make is Isolated and rename it to `my_new_wrkspc`
from geoserverx.models.workspace import UpdateWorkspaceInfo

await client.update_workspace(name='my_wrkspc',update=UpdateWorkspaceInfo(name='my_new_wrkspc',isolated=True))
```
Loading

0 comments on commit 3dcdf2e

Please sign in to comment.