Skip to content

Commit

Permalink
made recurse as parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
krishnaglodha committed Nov 6, 2024
1 parent 5c861cb commit 34254a3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 20 deletions.
6 changes: 2 additions & 4 deletions docs/pages/async/workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,15 @@ await client.create_workspace(name='my_wrkspc',default=True,Isolated=True)

## Delete workspace
This command allows user to delete workspace.
!!! danger ""

Deleting workspace will also delete all the layers and styles associated with the workspace.
Deleting workspace requires following parameters

* workspace `str` : Name of the workspace
* recurse `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')
await client.delete_workspace(workspace='my_wrkspc',recurse=True)
```

## Update workspace
Expand Down
10 changes: 4 additions & 6 deletions docs/pages/cli/workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ Usage: gsx delete-workspace [OPTIONS]
Options:
--request [sync|async] [default: requestEnum._sync]
--workspace TEXT Workspace name [required]
--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]
Expand All @@ -162,12 +163,13 @@ Options:
As listed above, `delete-workspace` command accepts parameters as follows

* --workspace - 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 --workspace my_wrkspace
gsx delete-workspace --workspace my_wrkspace --recurse
{"code":200,"response":"Executed successfully"}
```
</div>
Expand Down Expand Up @@ -202,12 +204,8 @@ As listed above, `update-workspace` command accepts parameters as follows
* --new-name - name of new workspace
* --isolated/--no-isolated - To keep workspace either isolated or not

## Delete single workspaces

!!! danger ""
## Update single workspaces

Deleting workspace will also delete all the layers and styles associated with the workspace.

<div class="termy">
```console
gsx update-workspace --current-name sde --new-name duster
Expand Down
7 changes: 2 additions & 5 deletions docs/pages/sync/workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,14 @@ client.create_workspace(name='my_wrkspc',default=True,Isolated=True)
## Delete workspace
This command allows user to delete workspace.

!!! danger ""

Deleting workspace will also delete all the layers and styles associated with the workspace.

Deleting workspace requires following parameters

* workspace `str` : Name of the workspace
* recurse `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')
client.delete_workspace(workspace='my_wrkspc',recurse=True)
```

## Update workspace
Expand Down
4 changes: 2 additions & 2 deletions src/geoserverx/_async/gsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ async def get_workspace(self, workspace: str) -> Union[WorkspaceModel, GSRespons
return results

# Delete specific workspaces
async def delete_workspace(self, workspace: str) -> GSResponse:
async def delete_workspace(self, workspace: str, recurse: bool = False) -> GSResponse:
Client = self.http_client
responses = await Client.delete(f"workspaces/{workspace}?recurse=true")
responses = await Client.delete(f"workspaces/{workspace}?recurse={recurse}")
results = self.response_recognise(responses.status_code)
return results

Expand Down
4 changes: 2 additions & 2 deletions src/geoserverx/_sync/gsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ def get_workspace(self, workspace: str) -> Union[WorkspaceModel, GSResponse]:

# Delete specific workspaces
@exception_handler
def delete_workspace(self, workspace: str) -> GSResponse:
def delete_workspace(self, workspace: str,recurse: bool = False) -> GSResponse:
Client = self.http_client
responses = Client.delete(f"workspaces/{workspace}?recurse=true")
responses = Client.delete(f"workspaces/{workspace}?recurse={recurse}")
results = self.response_recognise(responses.status_code)
return results

Expand Down
3 changes: 2 additions & 1 deletion src/geoserverx/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def workspace(
def delete_workspace(
request: requestEnum = requestEnum._sync,
workspace: str = typer.Option(..., help="Workspace name"),
recurse: bool = typer.Option(False, help="Delete all stores,layers,styles,etc."),
url: str = typer.Option(
"http://127.0.0.1:8080/geoserver/rest/", help="Geoserver REST URL"
),
Expand All @@ -99,7 +100,7 @@ def delete_workspace(
"""
if request.value == "sync":
client = SyncGeoServerX(username, password, url)
result = client.delete_workspace(workspace).model_dump_json()
result = client.delete_workspace(workspace,recurse).model_dump_json()
if "code" in result:
typer.secho(result, fg=typer.colors.RED)
else:
Expand Down

0 comments on commit 34254a3

Please sign in to comment.