Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using check_module functions to see if certain plugin exists in geoserver #58

Open
krishnaglodha opened this issue Sep 2, 2024 · 2 comments
Assignees

Comments

@krishnaglodha
Copy link
Collaborator

We are now creating functions for plugins on geoserver using their REST APIs, as we decided to always check if the plugin already exists or not even before executing REST API, I'm suggesting following method

function which takes parameter of the name of module along with client itself

@exception_handler
def check_modules(self,name)-> Union[bool, GSResponse]:
    Client = self.http_client
    response = Client.get("about/status.json")
    
    if response.status_code != 200:
        return self.response_recognise(response.status_code)
    
    modules = [item["name"].lower() for item in response.json()['statuss']['status']]
    return name.lower() in modules

Example function using check_modules

# Get all geofence rules
@exception_handler
def get_all_geofence_rules(self) -> Union[RulesResponse, GSResponse]:
    Client = self.http_client
    # Check if the module exist
    if not self.check_modules('geofence'):
        return self.response_recognise(404)
    responses = Client.get("geofence/rules/", headers={'Accept': "application/json"})
    if responses.status_code == 200:
        return RulesResponse.model_validate(responses.json())
    else:
        results = self.response_recognise(responses.status_code)
        return results

Here my thoughts are that along with returning 404, we should return a custom error msg saying No Module Found

@krishnaglodha
Copy link
Collaborator Author

Great, I'll add it accordingly and raise PR

krishnaglodha added a commit that referenced this issue Sep 2, 2024
francbartoli pushed a commit that referenced this issue Oct 8, 2024
* added base code to get geofence rules

* added header to geofence function

* added tests for geofence

* added single geofence rule

* adding new geofence rule

* added check_modules as per #58

* linting done

* added try: except in checl_module

* hotfix response schema to get geofence rule

* fixed as black

* hotfix - returning response in case of http error

* fixed remaining geofence functions

* added custom exception

* fixed as per black
francbartoli pushed a commit that referenced this issue Nov 4, 2024
* addd layer rest api (#43)

* added layer REST

* updated all pages

* param workspace added to get_all_layers

* added delete layer api

* addd layer rest api (#43)

* added layer REST

* updated all pages

* param workspace added to get_all_layers

* added delete layer api

* upgraded version in pyproject (#44)

* fixed all pydantic calls (#51)

* fixed all pydantic calls

* upgraded constraints file

* updated version of checkout and python in test.yml

* updated poetry version in contraints

* trying poetry installer

* updated poetry installation method in release.yml

* fixed few pydanticv2 issues (#53)

* fixed suggestions as per review (#54)

* Feature/create-stores (#46)

* added vector and raster store function

* added vector and raster store

* fixed test issue

* updated add vector layer to omit null

* updated good_layer_connection

* fixed suggestions as per review

* added vector and raster store function

* added vector and raster store

* fixed test issue

* updated add vector layer to omit null

* updated good_layer_connection

* fixed suggestions as per review

* added vector and raster store

* updated add vector layer to omit null

* Feature/layer-group (#52)

* added get layer group function

* fixed model names and lowercased function names in test

* added tests for LayerGroupsModel

* fixed as per pydanticv2 protocol (#55)

* fixed issues as per ruff (#57)

* using black isort and ruff in the test CI pipeline (#63)

* using black isort and ruff in the test CI pipeline

* removed duplicate installation

* testing with black and isort marketplace options

* testing black action

* testing with ruff

* fixed black .

* updated black and ruff version and run black again

* fixed as per isort

* added profile black to isort in CI

* testing if ruff gives error in CI

* fixed black but keeping error as per ruff

* fixed as per ruff

* updated readme (#59)

* updated readme

* using black isort and ruff in the test CI pipeline (#63)

* using black isort and ruff in the test CI pipeline

* removed duplicate installation

* testing with black and isort marketplace options

* testing black action

* testing with ruff

* fixed black .

* updated black and ruff version and run black again

* fixed as per isort

* added profile black to isort in CI

* testing if ruff gives error in CI

* fixed black but keeping error as per ruff

* fixed as per ruff

* Feature/get-geofence (#56)

* added base code to get geofence rules

* added header to geofence function

* added tests for geofence

* added single geofence rule

* adding new geofence rule

* added check_modules as per #58

* linting done

* added try: except in checl_module

* hotfix response schema to get geofence rule

* fixed as black

* hotfix - returning response in case of http error

* fixed remaining geofence functions

* added custom exception

* fixed as per black

* updated version to 0.0.4 (#64)

* updated version to 0.0.4

* updated description

* added readme config to toml

* update documents (#65)

* update docs

* updated requirements.txt

* updated flow for docs

* updating workflow file

* added site_url to mkdocs

* updated toml for mypu

* updated lock file

* fixed as per black
@ricardogsilva ricardogsilva moved this to Backlog in geoserverx Jan 3, 2025
@ricardogsilva
Copy link
Collaborator

@krishnaglodha I see there is currently a self.check_modules() method on the core. Does this mean this issue can be closed?

@ricardogsilva ricardogsilva moved this from Backlog to In review in geoserverx Jan 3, 2025
@ricardogsilva ricardogsilva moved this from In review to In progress in geoserverx Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In progress
Development

No branches or pull requests

3 participants