From 34254a3ed93753e931b45f4efc5c2af59d2148ef Mon Sep 17 00:00:00 2001 From: krishnaglodha Date: Wed, 6 Nov 2024 18:56:14 +0530 Subject: [PATCH] made recurse as parameter --- docs/pages/async/workspace.md | 6 ++---- docs/pages/cli/workspace.md | 10 ++++------ docs/pages/sync/workspace.md | 7 ++----- src/geoserverx/_async/gsx.py | 4 ++-- src/geoserverx/_sync/gsx.py | 4 ++-- src/geoserverx/cli/cli.py | 3 ++- 6 files changed, 14 insertions(+), 20 deletions(-) diff --git a/docs/pages/async/workspace.md b/docs/pages/async/workspace.md index 415c9ce..9bcc1e6 100644 --- a/docs/pages/async/workspace.md +++ b/docs/pages/async/workspace.md @@ -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 diff --git a/docs/pages/cli/workspace.md b/docs/pages/cli/workspace.md index 7f80a8f..8034fe3 100644 --- a/docs/pages/cli/workspace.md +++ b/docs/pages/cli/workspace.md @@ -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] @@ -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
```console -gsx delete-workspace --workspace my_wrkspace +gsx delete-workspace --workspace my_wrkspace --recurse {"code":200,"response":"Executed successfully"} ```
@@ -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. -
```console gsx update-workspace --current-name sde --new-name duster diff --git a/docs/pages/sync/workspace.md b/docs/pages/sync/workspace.md index 075e020..5f3bbd3 100644 --- a/docs/pages/sync/workspace.md +++ b/docs/pages/sync/workspace.md @@ -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 diff --git a/src/geoserverx/_async/gsx.py b/src/geoserverx/_async/gsx.py index b9b0552..dd62b6e 100644 --- a/src/geoserverx/_async/gsx.py +++ b/src/geoserverx/_async/gsx.py @@ -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 diff --git a/src/geoserverx/_sync/gsx.py b/src/geoserverx/_sync/gsx.py index 38ec11c..26131cb 100644 --- a/src/geoserverx/_sync/gsx.py +++ b/src/geoserverx/_sync/gsx.py @@ -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 diff --git a/src/geoserverx/cli/cli.py b/src/geoserverx/cli/cli.py index 8a804a1..51db5f8 100644 --- a/src/geoserverx/cli/cli.py +++ b/src/geoserverx/cli/cli.py @@ -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" ), @@ -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: