Skip to content

Commit

Permalink
Merge pull request #166 from pesekon2/support_updating_service_options
Browse files Browse the repository at this point in the history
support updating service's settings
  • Loading branch information
iamtekson authored Sep 17, 2024
2 parents b566a47 + 98e82b0 commit 734e14c
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions geo/Geoserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3141,3 +3141,46 @@ def delete_usergroup(self, group: str, service=None) -> str:
return "Group deleted successfully"
else:
raise GeoserverException(r.status_code, r.content)

# _______________________________________________________________________________________________
#
# SERVICES
# _______________________________________________________________________________________________
#

def update_service(self, service: str, **kwargs):
"""
Update selected service's options.
Parameters
----------
service : str
Type of service (e.g., wms, wfs)
kwargs : dict
Options to be modified (e.g., maxRenderingTime=600)
Returns
-------
str
A success message indicating that the options were updated.
Raises
------
GeoserverException
If there is an issue updating the service's options.
"""
url = "{}/rest/services/{}/settings".format(self.service_url, service)
headers = {"content-type": "text/xml"}

data = ""
for key, value in kwargs.items():
data += "<{}><{}>{}</{}></{}>".format(
service, key, value, key, service
)

r = self._requests("put", url, data=data, headers=headers)

if r.status_code == 200:
return "Service's option updated successfully"
else:
raise GeoserverException(r.status_code, r.content)

0 comments on commit 734e14c

Please sign in to comment.