Skip to content

Commit

Permalink
Merge pull request #68 from geobeyond/feature/workspace
Browse files Browse the repository at this point in the history
Feature/workspace
  • Loading branch information
ricardogsilva authored Jan 2, 2025
2 parents 8a2837c + f09559a commit dc7dd5a
Show file tree
Hide file tree
Showing 12 changed files with 811 additions and 403 deletions.
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))
```
105 changes: 96 additions & 9 deletions docs/pages/cli/workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
!!! get "Get started"
To start using `geoserverx` using command line, activate the Environment where package is installed and use `gsx` command



## Paramters for all workspaces command

<div class="termy">
Expand All @@ -26,6 +24,7 @@ Options:
--username TEXT Geoserver username [default: admin]
--help Show this message and exit.
```

</div>

As listed above, `workspaces` command accepts four parameters.
Expand All @@ -40,12 +39,14 @@ All these parameters have default value setup which will work for local default
## Get all workspaces

<div class="termy">

```console
$ gsx workspaces

{"workspaces": {"workspace": [{"name": "cesium", "href":
"http://127.0.0.1:8080/geoserver/rest/workspaces/cesium.json"}]}}
```

</div>

## Get all workspaces of hosted GeoServer
Expand All @@ -56,6 +57,7 @@ $ gsx workspaces --url http://locahost:8080/geoserver/rest --password myPassword
{"workspaces": {"workspace": [{"name": "giz", "href":
"http://locahost:8080/geoserver/rest/workspaces/giz.json"}]}}
```

</div>


Expand All @@ -78,16 +80,17 @@ Options:
--username TEXT Geoserver username [default: admin]
--help Show this message and exit.
```

</div>

As listed above, `workspace` accepts `workspace` parameter as the name of workspace


## Get single workspaces

<div class="termy">

```console
$ gsx workspace --workspace cesium
$ gsx workspace cesium
{"workspace": {"name": "cesium", "isolated": false, "dateCreated": "2023-02-13
06:43:28.793 UTC", "dataStores":
"http://127.0.0.1:8080/geoserver/rest/workspaces/cesium/datastores.json",
Expand All @@ -96,10 +99,10 @@ $ gsx workspace --workspace cesium
"wmsStores": "http://127.0.0.1:8080/geoserver/rest/workspaces/cesium/wmsstores.json",
"wmtsStores": "http://127.0.0.1:8080/geoserver/rest/workspaces/cesium/wmtsstores.json"}}
```
</div>

</div>

## Paramters for create workspace command
## Parameters for create workspace command

<div class="termy">

Expand All @@ -120,6 +123,7 @@ Options:
--username TEXT Geoserver username [default: admin]
--help Show this message and exit.
```

</div>

As listed above, `create-workspace` command accepts parameters as follows
Expand All @@ -128,12 +132,95 @@ As listed above, `create-workspace` command accepts parameters as follows
* --default/--no-default - To keep workspace either default or not
* --isolated/--no-isolated - To keep workspace either isolated or not


## Create single workspaces

<div class="termy">
```console
$ gsx create-workspace --workspace mydefaultws --default
$ gsx create-workspace mydefaultws --default
code=201 response='Data added successfully'
```
</div>
</div>

## Parameters for delete workspace command

<div class="termy">

```console
$ gsx delete-workspace --help
Usage: gsx delete-workspace [OPTIONS]

Delete workspace in the Geoserver

Arguments:
WORKSPACE [required]

Options:
--request [sync|async] [default: requestEnum._sync]
--recurse / --no-recurse Delete all stores,layers,styles,etc. [default:
no-recurse]
--url TEXT Geoserver REST URL [default:
http://127.0.0.1:8080/geoserver/rest/]
--password TEXT Geoserver Password [default: geoserver]
--username TEXT Geoserver username [default: admin]
--help Show this message and exit.
```

</div>

As listed above, `delete-workspace` command accepts parameters as follows

* --current_name - name of workspace
* --recurse / --no-recurse - This parameter recursively deletes all layers referenced by the specified workspace, including data stores, coverage stores, feature types, and so on

## Delete single workspaces

<div class="termy">
```console
gsx delete-workspace my_wrkspace --recurse
{"code":200,"response":"Executed successfully"}
```
</div>


## Parameters for update workspace command

<div class="termy">

```console
$ gsx update-workspace --help
Usage: gsx update-workspace [OPTIONS]

Add workspace in the Geoserver

Arguments:
CURRENT_NAME [required]

Options:
--request [sync|async] [default: requestEnum._sync]
--new-name TEXT New Workspace name
--isolated / --no-isolated Make workspace isolated? [default: no-isolated]
--url TEXT Geoserver REST URL [default:
http://127.0.0.1:8080/geoserver/rest/]
--password TEXT Geoserver Password [default: geoserver]
--username TEXT Geoserver username [default: admin]
--help Show this message and exit.
```

</div>

As listed above, `update-workspace` command accepts parameters as follows

* --current-name - name of current workspace
* --new-name - name of new workspace
* --isolated/--no-isolated - To keep workspace either isolated or not

## Update single workspaces

<div class="termy">

```console
gsx update-workspace d --new-name duster
{"code":200,"response":"Executed successfully"}
```

</div>
56 changes: 47 additions & 9 deletions docs/pages/sync/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 `SyncGeoServerX` Class, read more about it [here](https://geobeyond.github.io/geoserverx/pages/sync/)

## Get all workspaces

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

```Python
Expand All @@ -11,21 +15,55 @@ client.get_all_workspaces()
```

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

This command fetches workspace with parameter as name of it from GeoServer.

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

## Create 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

This command allows user to create new workspace.

| 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 default or not |

```Python
#Create new workspace with name `my_wrkspc` , make it Default and Isolated
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`.
client.delete_workspace(workspace='my_wrkspc',recurse=True)
```

## Update workspace

This command allows user to update existing workspace.

| 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

client.update_workspace(name='my_wrkspc',update=UpdateWorkspaceInfo(name='my_new_wrkspc',isolated=True))
```
4 changes: 4 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ markdown_extensions:
- footnotes # notes bottom of page
- attr_list # used to size images
- md_in_html # used to size images
- tables
- pymdownx.emoji:
emoji_index: !!python/name:material.extensions.emoji.twemoji
emoji_generator: !!python/name:material.extensions.emoji.to_svg
- pymdownx.tabbed:
alternate_style: true

Expand Down
Loading

0 comments on commit dc7dd5a

Please sign in to comment.