Skip to content

Commit 98e82b0

Browse files
committed
support updating service's options
1 parent b566a47 commit 98e82b0

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

geo/Geoserver.py

+43
Original file line numberDiff line numberDiff line change
@@ -3141,3 +3141,46 @@ def delete_usergroup(self, group: str, service=None) -> str:
31413141
return "Group deleted successfully"
31423142
else:
31433143
raise GeoserverException(r.status_code, r.content)
3144+
3145+
# _______________________________________________________________________________________________
3146+
#
3147+
# SERVICES
3148+
# _______________________________________________________________________________________________
3149+
#
3150+
3151+
def update_service(self, service: str, **kwargs):
3152+
"""
3153+
Update selected service's options.
3154+
3155+
Parameters
3156+
----------
3157+
service : str
3158+
Type of service (e.g., wms, wfs)
3159+
kwargs : dict
3160+
Options to be modified (e.g., maxRenderingTime=600)
3161+
3162+
Returns
3163+
-------
3164+
str
3165+
A success message indicating that the options were updated.
3166+
3167+
Raises
3168+
------
3169+
GeoserverException
3170+
If there is an issue updating the service's options.
3171+
"""
3172+
url = "{}/rest/services/{}/settings".format(self.service_url, service)
3173+
headers = {"content-type": "text/xml"}
3174+
3175+
data = ""
3176+
for key, value in kwargs.items():
3177+
data += "<{}><{}>{}</{}></{}>".format(
3178+
service, key, value, key, service
3179+
)
3180+
3181+
r = self._requests("put", url, data=data, headers=headers)
3182+
3183+
if r.status_code == 200:
3184+
return "Service's option updated successfully"
3185+
else:
3186+
raise GeoserverException(r.status_code, r.content)

0 commit comments

Comments
 (0)