Skip to content

GeoServer

Bases: Base

GeoServer Client for Python. Use this class to interact with a GeoServer instance.

Note

This class implements most of the GeoServer REST API endpoints. You can follow the official GeoServer REST API documentation here.

Parameters:

Name Type Description Default
service_url str

The URL of the GeoServer instance.

'http://localhost:8080/geoserver'
username Optional[str]

The username to authenticate with the GeoServer instance.

None
password Optional[str]

The password to authenticate with the GeoServer instance.

None
headers Optional[Dict[str, Any]]

The headers to be included in the requests.

None
cookies Optional[Dict[str, Any]]

The cookies to be included in the requests.

None
auth Optional[AuthBase]

The authentication to be included in the requests.

None
allow_redirects bool

A boolean indicating whether or not the requests should follow redirects.

True
proxies Any

The proxies to be included in the requests.

None
verify bool

A boolean indicating whether or not the SSL certificates should be verified.

True
cert Optional[str]

The certificate to be included in the requests.

None
Example
from geoserver import GeoServer

geoserver = GeoServer(
    service_url="http://localhost:8080/geoserver",
    username="admin",
    password="geoserver"
)
Source code in geoserver/base.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
def __init__(
    self,
    service_url: str = "http://localhost:8080/geoserver",
    username: Optional[str] = None,
    password: Optional[str] = None,
    headers: Optional[Dict[str, Any]] = None,
    cookies: Optional[Dict[str, Any]] = None,
    auth: Optional[AuthBase] = None,
    allow_redirects: bool = True,
    proxies: Any = None,
    verify: bool = True,
    cert: Optional[str] = None,
):
    if auth is None and username is not None and password is not None:
        auth = HTTPBasicAuth(username, password)

    self.service_url = service_url.rstrip("/")
    self.auth = auth
    self.headers = headers or {}
    self.cookies = cookies or {}
    self.allow_redirects = allow_redirects
    self.proxies = proxies or {}
    self.verify = verify
    self.cert = cert

get_manifest

get_manifest(*, manifest: Optional[str] = None, key: Optional[str] = None, value: Optional[str] = None, format: Literal['json'] = 'json') -> Dict[str, Any]
get_manifest(*, manifest: Optional[str] = None, key: Optional[str] = None, value: Optional[str] = None, format: Literal['xml']) -> str
get_manifest(*, manifest: Optional[str] = None, key: Optional[str] = None, value: Optional[str] = None, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Retrieves the manifest of the GeoServer instance, in JSON format.

Parameters:

Name Type Description Default
manifest Optional[str]

Optional. The manifest parameter is used to filter over resulting resource (manifest) names attribute using Java regular expressions. Defaults to None.

None
key Optional[str]

Optional. Only return manifest entries with this key in their properties. It can be optionally combined with the value parameter. Defaults to None.

None
value Optional[str]

Optional. Only return manifest entries that have this value for the provided key parameter. Defaults to None.

None
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The manifest of the GeoServer instance.

Example

To get the manifest of the GeoServer instance, use the following code:

geoserver.get_manifest()
Source code in geoserver/geoserver.py
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
def get_manifest(
    self,
    *,
    manifest: Optional[str] = None,
    key: Optional[str] = None,
    value: Optional[str] = None,
    format: Literal["json", "xml"] = "json",
) -> Union[str, Dict[str, Any]]:
    """Retrieves the manifest of the GeoServer instance, in JSON format.

    Args:
        manifest: Optional. The manifest parameter is used to filter over resulting resource (manifest) names attribute using Java regular expressions. Defaults to None.
        key: Optional. Only return manifest entries with this key in their properties. It can be optionally combined with the value parameter. Defaults to None.
        value: Optional. Only return manifest entries that have this value for the provided key parameter. Defaults to None.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The manifest of the GeoServer instance.

    Example:
        To get the manifest of the GeoServer instance, use the following code:

        ```python
        geoserver.get_manifest()
        ```

    """
    url = f"{self.service_url}/rest/about/manifest.{format}"
    params = dict(manifest=manifest, key=key, value=value)
    response = self._request(method="get", url=url, params=params)
    return response.json() if format == "json" else response.text

get_version

get_version(*, manifest: Optional[str] = None, key: Optional[str] = None, value: Optional[str] = None, format: Literal['json'] = 'json') -> Dict[str, Any]
get_version(*, manifest: Optional[str] = None, key: Optional[str] = None, value: Optional[str] = None, format: Literal['xml']) -> str
get_version(*, manifest: Optional[str] = None, key: Optional[str] = None, value: Optional[str] = None, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Shows only the details for the high-level components: GeoServer, GeoTools, and GeoWebCache

Parameters:

Name Type Description Default
manifest Optional[str]

Optional. The manifest parameter is used to filter over resulting resource (manifest) names attribute using Java regular expressions. Defaults to None.

None
key Optional[str]

Optional. Only return manifest entries with this key in their properties. It can be optionally combined with the value parameter. Defaults to None.

None
value Optional[str]

Optional. Only return manifest entries that have this value for the provided key parameter. Defaults to None.

None
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The version of the GeoServer instance.

Example

To get the version of the GeoServer instance, use the following code:

geoserver.get_version()
Source code in geoserver/geoserver.py
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
def get_version(
    self,
    *,
    manifest: Optional[str] = None,
    key: Optional[str] = None,
    value: Optional[str] = None,
    format: Literal["json", "xml"] = "json",
) -> Union[str, Dict[str, Any]]:
    """Shows only the details for the high-level components: GeoServer, GeoTools, and GeoWebCache

    Args:
        manifest: Optional. The manifest parameter is used to filter over resulting resource (manifest) names attribute using Java regular expressions. Defaults to None.
        key: Optional. Only return manifest entries with this key in their properties. It can be optionally combined with the value parameter. Defaults to None.
        value: Optional. Only return manifest entries that have this value for the provided key parameter. Defaults to None.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The version of the GeoServer instance.

    Example:
        To get the version of the GeoServer instance, use the following code:

        ```python
        geoserver.get_version()
        ```
    """
    url = f"{self.service_url}/rest/about/version.{format}"
    params = dict(manifest=manifest, key=key, value=value)
    response = self._request(method="get", url=url, params=params)
    return response.json() if format == "json" else response.text

get_status

get_status(*, manifest: Optional[str] = None, key: Optional[str] = None, value: Optional[str] = None, format: Literal['json'] = 'json') -> Dict[str, Any]
get_status(*, manifest: Optional[str] = None, key: Optional[str] = None, value: Optional[str] = None, format: Literal['xml']) -> str
get_status(*, manifest: Optional[str] = None, key: Optional[str] = None, value: Optional[str] = None, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Shows the status details of all installed and configured modules. Status details always include human readable name, and module name. Optional details include version, availability, status message, and links to documentation.

Parameters:

Name Type Description Default
manifest Optional[str]

Optional. The manifest parameter is used to filter over resulting resource (manifest) names attribute using Java regular expressions. Defaults to None.

None
key Optional[str]

Optional. Only return manifest entries with this key in their properties. It can be optionally combined with the value parameter. Defaults to None.

None
value Optional[str]

Optional. Only return manifest entries that have this value for the provided key parameter. Defaults to None.

None
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The version of the GeoServer instance.

Example

To get the status of the GeoServer instance, use the following code:

geoserver.get_status()
Source code in geoserver/geoserver.py
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
def get_status(
    self,
    *,
    manifest: Optional[str] = None,
    key: Optional[str] = None,
    value: Optional[str] = None,
    format: Literal["json", "xml"] = "json",
) -> Union[str, Dict[str, Any]]:
    """Shows the status details of all installed and configured modules. Status details always include human readable name, and module name. Optional details include version, availability, status message, and links to documentation.

    Args:
        manifest: Optional. The manifest parameter is used to filter over resulting resource (manifest) names attribute using Java regular expressions. Defaults to None.
        key: Optional. Only return manifest entries with this key in their properties. It can be optionally combined with the value parameter. Defaults to None.
        value: Optional. Only return manifest entries that have this value for the provided key parameter. Defaults to None.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The version of the GeoServer instance.

    Example:
        To get the status of the GeoServer instance, use the following code:

        ```python
        geoserver.get_status()
        ```
    """
    url = f"{self.service_url}/rest/about/status.{format}"
    params = dict(manifest=manifest, key=key, value=value)
    response = self._request(method="get", url=url, params=params)
    return response.json() if format == "json" else response.text

get_system_status

get_system_status(*, format: Literal['json'] = 'json') -> Dict[str, Any]
get_system_status(*, format: Literal['xml']) -> str
get_system_status(*, format: Literal['html']) -> str
get_system_status(*, format: Literal['json', 'xml', 'html'] = 'json') -> Union[str, Dict[str, Any]]

Returns a list of system-level information. Major operating systems (Linux, Windows and MacOX) are supported out of the box.

Returns:

Type Description
Union[str, Dict[str, Any]]

The system status of the GeoServer instance.

Example

To get the system status of the GeoServer instance, use the following code:

geoserver.get_system_status()
Source code in geoserver/geoserver.py
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
def get_system_status(self, *, format: Literal["json", "xml", "html"] = "json") -> Union[str, Dict[str, Any]]:
    """Returns a list of system-level information. Major operating systems (Linux, Windows and MacOX) are supported out of the box.

    Returns:
        The system status of the GeoServer instance.

    Example:
        To get the system status of the GeoServer instance, use the following code:

        ```python
        geoserver.get_system_status()
        ```
    """
    url = f"{self.service_url}/rest/about/system-status.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

get_data_stores

get_data_stores(*, workspace: str, format: Literal['json'] = 'json') -> Dict[str, Any]
get_data_stores(*, workspace: str, format: Literal['xml']) -> str
get_data_stores(*, workspace: str, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

List all data stores in workspace ws.

Parameters:

Name Type Description Default
workspace str

The name of the workspace containing the data stores.

required
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The list of all datastores in the workspace.

Example

To get the list of all data stores in the workspace, use the following code:

geoserver.get_data_stores(workspace="my_workspace")
Source code in geoserver/geoserver.py
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
def get_data_stores(self, *, workspace: str, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """List all data stores in workspace ws.

    Args:
        workspace: The name of the workspace containing the data stores.
        format: Optional. The format of the response. It can be either "json" or "xml".

    Returns:
        The list of all datastores in the workspace.

    Example:
        To get the list of all data stores in the workspace, use the following code:

        ```python
        geoserver.get_data_stores(workspace="my_workspace")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/datastores.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

data_store_exists

data_store_exists(name: str, *, workspace: str) -> bool

Check if a data store exists in a workspace.

Parameters:

Name Type Description Default
name str

The name of the data store.

required
workspace str

The name of the workspace containing the data stores.

required

Returns:

Type Description
bool

True if the data store exists, False otherwise.

Example

To check if a data store exists in a workspace, use the following code:

geoserver.data_store_exists("my_data_store", workspace="my_workspace")
Source code in geoserver/geoserver.py
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
def data_store_exists(self, name: str, *, workspace: str) -> bool:
    """Check if a data store exists in a workspace.

    Args:
        name: The name of the data store.
        workspace: The name of the workspace containing the data stores.

    Returns:
        True if the data store exists, False otherwise.

    Example:
        To check if a data store exists in a workspace, use the following code:

        ```python
        geoserver.data_store_exists("my_data_store", workspace="my_workspace")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/datastores/{name}.xml"
    response = self._request(method="head", url=url, ignore=[404])
    return response.status_code == 200

create_data_store

create_data_store(body: Union[str, Dict[str, Any]], *, workspace: str) -> str

Adds a new data store to the workspace.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to create the data store.

required
workspace str

The name of the workspace containing the data stores.

required

Returns:

Type Description
str

The data store created.

Example

To create a new data store in a workspace, use the following code:

body = """
<dataStore>
    <name>my_data_store</name>
    <connectionParameters>
        <entry key="host">localhost</entry>
        <entry key="port">5432</entry>
        <entry key="database">my_database</entry>
        <entry key="user">my_user</entry>
        <entry key="passwd">my_password</entry>
        <entry key="dbtype">postgis</entry>
    </connectionParameters>
</dataStore>
"""

geoserver.create_data_store(body, workspace="my_workspace")
Source code in geoserver/geoserver.py
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
def create_data_store(self, body: Union[str, Dict[str, Any]], *, workspace: str) -> str:
    """Adds a new data store to the workspace.

    Args:
        body: The body of the request used to create the data store.
        workspace: The name of the workspace containing the data stores.

    Returns:
        The data store created.

    Example:
        To create a new data store in a workspace, use the following code:

        ```python
        body = \"\"\"
        <dataStore>
            <name>my_data_store</name>
            <connectionParameters>
                <entry key="host">localhost</entry>
                <entry key="port">5432</entry>
                <entry key="database">my_database</entry>
                <entry key="user">my_user</entry>
                <entry key="passwd">my_password</entry>
                <entry key="dbtype">postgis</entry>
            </connectionParameters>
        </dataStore>
        \"\"\"

        geoserver.create_data_store(body, workspace="my_workspace")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/datastores"
    self._request(method="post", url=url, body=body)
    return CREATED_MESSAGE

upload_data_store

upload_data_store(file: Union[str, Path, BufferedReader], *, workspace: str, name: Optional[str] = None, filename: Optional[str] = None, format: str = 'shp', configure: Literal['none', 'all'] = 'all', overwrite: bool = False) -> str

Uploads a new or update an existing data store from a local file.

Note

The store parameter is automatically inferred from the file, if not provided. In case the file is a buffer, the store parameter is required.

Note

The file name of the resource can be overwritten by: - Providing the filename parameter. - Using the name parameter. In this case, if the filename is not provided, the file name will be the same as the store name.

Parameters:

Name Type Description Default
file Union[str, Path, BufferedReader]

The file to upload.

required
workspace str

The name of the workspace.

required
name Optional[str]

Optional. The name of the data store.

None
filename Optional[str]

Optional. The filename parameter specifies the target file name for a file that needs to be harvested as part of a mosaic. This is important to avoid clashes and to make sure the right dimension values are available in the name for multidimensional mosaics to work. Only used if method="file".

None

Returns:

Type Description
str

Success message.

Example

To upload a new data store from a local file, use the following code:

geoserver.upload_data_store("my_shapefile.zip", workspace="my_workspace", name="my_data_store")

Or, using a buffer:

with open("my_shapefile.zip", "rb") as f:
    geoserver.upload_data_store(f, workspace="my_workspace", name="my_data_store")
Source code in geoserver/geoserver.py
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
def upload_data_store(
    self,
    file: Union[str, Path, BufferedReader],
    *,
    workspace: str,
    name: Optional[str] = None,
    filename: Optional[str] = None,
    format: str = "shp",
    configure: Literal["none", "all"] = "all",
    overwrite: bool = False,
) -> str:
    """Uploads a new or update an existing data store from a local file.

    Note:
        The `store` parameter is automatically inferred from the file, if not provided.
        In case the file is a buffer, the `store` parameter is required.

    Note:
        The file name of the resource can be overwritten by:
        - Providing the `filename` parameter.
        - Using the `name` parameter. In this case, if the `filename` is not provided,
            the file name will be the same as the store name.

    Args:
        file: The file to upload.
        workspace: The name of the workspace.
        name: Optional. The name of the data store.
        filename:  Optional. The filename parameter specifies the target file name for a file that needs to be harvested as part of a mosaic.
            This is important to avoid clashes and to make sure the right dimension values are available in the name for multidimensional mosaics to work.
            Only used if method="file".

    Returns:
        Success message.

    Example:
        To upload a new data store from a local file, use the following code:

        ```python
        geoserver.upload_data_store("my_shapefile.zip", workspace="my_workspace", name="my_data_store")
        ```

        Or, using a buffer:

        ```python
        with open("my_shapefile.zip", "rb") as f:
            geoserver.upload_data_store(f, workspace="my_workspace", name="my_data_store")
        ```
    """
    if isinstance(file, Path):
        file = file.as_posix()
    if isinstance(file, str):
        name = name or Path(file).stem
        filename = filename or f"{name}.{Path(file).suffix[1:]}"
    if name is None:
        raise ValueError("The `store` parameter is required.")

    headers = {}
    if zipfile.is_zipfile(file):
        headers["Content-Type"] = "application/zip"

    params = dict(filename=filename, configure=configure)
    if overwrite:
        params["update"] = "overwrite"

    if isinstance(file, str) and file.startswith(("file:", "http://", "https://")):
        headers["Content-Type"] = "text/plain"
        url = f"{self.service_url}/rest/workspaces/{workspace}/datastores/{name}/external.{format}"
        self._request(method="put", url=url, data=file, params=params, headers=headers)
        return CREATED_MESSAGE

    url = f"{self.service_url}/rest/workspaces/{workspace}/datastores/{name}/file.{format}"
    self._request(method="put", url=url, file=file, params=params, headers=headers)
    return CREATED_MESSAGE

get_data_store

get_data_store(name: str, *, workspace: str, quiet_on_not_found: bool = False, format: Literal['json'] = 'json') -> Dict[str, Any]
get_data_store(name: str, *, workspace: str, quiet_on_not_found: bool = False, format: Literal['xml']) -> str
get_data_store(name: str, *, workspace: str, quiet_on_not_found: bool = False, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Controls a particular data store in a given workspace.

Parameters:

Name Type Description Default
name str

The name of the data store.

required
workspace str

The name of the workspace containing the data stores.

required
quiet_on_not_found bool

Optional. If true, the server will not report an error if the data store is not found.

False
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The requested data store.

Example

To get the data store, use the following code:

geoserver.get_data_store("my_data_store", workspace="my_workspace")
Source code in geoserver/geoserver.py
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
def get_data_store(
    self, name: str, *, workspace: str, quiet_on_not_found: bool = False, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """Controls a particular data store in a given workspace.

    Args:
        name: The name of the data store.
        workspace: The name of the workspace containing the data stores.
        quiet_on_not_found: Optional. If true, the server will not report an error if the data store is not found.
        format: Optional. The format of the response. It can be either "json" or "xml".

    Returns:
        The requested data store.

    Example:
        To get the data store, use the following code:

        ```python
        geoserver.get_data_store("my_data_store", workspace="my_workspace")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/datastores/{name}.{format}"
    params = dict(quietOnNotFound=quiet_on_not_found)
    response = self._request(method="get", url=url, params=params)
    return response.json() if format == "json" else response.text

update_data_store

update_data_store(name: str, body: Union[str, Dict[str, Any]], *, workspace: str) -> str

Modify a data store from a workspace.

Parameters:

Name Type Description Default
name str

The name of the data store to modify.

required
workspace str

The name of the workspace containing the data stores.

required
body Union[str, Dict[str, Any]]

The body of the request used to modify the data store.

required

Returns:

Type Description
str

Success message.

Example

To update a data store, use the following code:

body = """
<dataStore>
    <name>my_new_data_store</name>
</dataStore>
"""

geoserver.update_data_store("my_data_store", body, workspace="my_workspace")
Source code in geoserver/geoserver.py
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
def update_data_store(self, name: str, body: Union[str, Dict[str, Any]], *, workspace: str) -> str:
    """Modify a data store from a workspace.

    Args:
        name: The name of the data store to modify.
        workspace: The name of the workspace containing the data stores.
        body: The body of the request used to modify the data store.

    Returns:
        Success message.

    Example:
        To update a data store, use the following code:

        ```python
        body = \"\"\"
        <dataStore>
            <name>my_new_data_store</name>
        </dataStore>
        \"\"\"

        geoserver.update_data_store("my_data_store", body, workspace="my_workspace")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/datastores/{name}"
    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

delete_data_store

delete_data_store(name: str, *, workspace: str, recurse: bool = False) -> str

Remove data store from workspace ws.

Parameters:

Name Type Description Default
name str

The name of the data store to remove.

required
workspace str

The name of the workspace containing the data stores.

required
recurse bool

Optional. If true, all resources contained in the store are also removed. Defaults to False.

False

Returns:

Type Description
str

Success message.

Example

To delete a data store, use the following code:

geoserver.delete_data_store("my_data_store", workspace="my_workspace")
Source code in geoserver/geoserver.py
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
def delete_data_store(self, name: str, *, workspace: str, recurse: bool = False) -> str:
    """Remove data store from workspace ws.

    Args:
        name: The name of the data store to remove.
        workspace: The name of the workspace containing the data stores.
        recurse: Optional. If true, all resources contained in the store are also removed. Defaults to `False`.

    Returns:
        Success message.

    Example:
        To delete a data store, use the following code:

        ```python
        geoserver.delete_data_store("my_data_store", workspace="my_workspace")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/datastores/{name}"
    params = dict(recurse=recurse)
    self._request(method="delete", url=url, params=params)
    return DELETED_MESSAGE

reset_data_store_caches

reset_data_store_caches(name: str, *, workspace: str) -> str

Resets caches for this data store. This operation is used to force GeoServer to drop caches associated to this data store, and reconnect to the vector source the next time it is needed by a request. This is useful as the store can keep state, such as a connection pool, and the structure of the feature types it's serving.

Parameters:

Name Type Description Default
name str

The name of the data store.

required
workspace str

The name of the workspace containing the data stores.

required

Returns:

Type Description
str

Success message.

Example

To reset the caches of a data store, use the following code:

geoserver.reset_data_store_caches("my_data_store", workspace="my_workspace")
Source code in geoserver/geoserver.py
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
def reset_data_store_caches(self, name: str, *, workspace: str) -> str:
    """Resets caches for this data store.
    This operation is used to force GeoServer to drop caches associated to this data store,
    and reconnect to the vector source the next time it is needed by a request.
    This is useful as the store can keep state, such as a connection pool,
    and the structure of the feature types it's serving.

    Args:
        name: The name of the data store.
        workspace: The name of the workspace containing the data stores.

    Returns:
        Success message.

    Example:
        To reset the caches of a data store, use the following code:

        ```python
        geoserver.reset_data_store_caches("my_data_store", workspace="my_workspace")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/datastores/{name}/reset"
    self._request(method="put", url=url)  # NOTE: Can also be a POST
    return OK_MESSAGE

get_coverages

get_coverages(*, workspace: str, store: Optional[str] = None, list: Optional[str] = None, format: Literal['json'] = 'json') -> Dict[str, Any]
get_coverages(*, workspace: str, store: Optional[str] = None, list: Optional[str] = None, format: Literal['xml']) -> str
get_coverages(*, workspace: str, store: Optional[str] = None, list: Optional[str] = None, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

List the coverages available for the provided workspace and data store.

Parameters:

Name Type Description Default
workspace str

The name of the workspace containing the data stores.

required
store Optional[str]

Optional. The name of the data store.

None
list Optional[str]

Optional. The list parameter is used to filter over resulting resource names attribute using Java regular expressions.

None
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The list of all coverages in the workspace and data store.

Example

To get the list of all coverages in a workspace, use the following code:

geoserver.get_coverages(workspace="my_workspace")

To specify a coverage store, use the following code:

geoserver.get_coverages(workspace="my_workspace", store="my_coverage_store")
Source code in geoserver/geoserver.py
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
def get_coverages(
    self,
    *,
    workspace: str,
    store: Optional[str] = None,
    list: Optional[str] = None,
    format: Literal["json", "xml"] = "json",
) -> Union[str, Dict[str, Any]]:
    """List the coverages available for the provided workspace and data store.

    Args:
        workspace: The name of the workspace containing the data stores.
        store: Optional. The name of the data store.
        list: Optional. The list parameter is used to filter over resulting resource names attribute using Java regular expressions.
        format: Optional. The format of the response. It can be either "json" or "xml".

    Returns:
        The list of all coverages in the workspace and data store.

    Example:
        To get the list of all coverages in a workspace, use the following code:

        ```python
        geoserver.get_coverages(workspace="my_workspace")
        ```

        To specify a coverage store, use the following code:

        ```python
        geoserver.get_coverages(workspace="my_workspace", store="my_coverage_store")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/coverages.{format}"
    if store is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{store}/coverages.{format}"

    response = self._request(method="get", url=url, params=dict(list=list))
    return response.json() if format == "json" else response.text

create_coverage

create_coverage(body: Union[str, Dict[str, Any]], *, workspace: str, store: Optional[str] = None) -> str

Creates a new coverage, the underlying data store must exist.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body the coverage to be created.

required
workspace str

The name of the workspace.

required
store Optional[str]

Optional. The name of the coverage store.

None

Returns:

Type Description
str

The created coverage.

Example

To create a new coverage, use the following code:

# Check the GeoServer official documentation for the body structure
body = "..."

geoserver.create_coverage(body, workspace="my_workspace", store="my_coverage_store")
Source code in geoserver/geoserver.py
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
def create_coverage(self, body: Union[str, Dict[str, Any]], *, workspace: str, store: Optional[str] = None) -> str:
    """Creates a new coverage, the underlying data store must exist.

    Args:
        body: The body the coverage to be created.
        workspace: The name of the workspace.
        store: Optional. The name of the coverage store.

    Returns:
        The created coverage.

    Example:
        To create a new coverage, use the following code:

        ```python
        # Check the GeoServer official documentation for the body structure
        body = "..."

        geoserver.create_coverage(body, workspace="my_workspace", store="my_coverage_store")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/coverages"
    if store is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{store}/coverages"

    self._request(method="post", url=url, body=body)
    return CREATED_MESSAGE

get_coverage

get_coverage(name: str, *, workspace: str, store: Optional[str] = None, quiet_on_not_found: bool = False, format: Literal['json'] = 'json') -> Dict[str, Any]
get_coverage(name: str, *, workspace: str, store: Optional[str] = None, quiet_on_not_found: bool = False, format: Literal['xml']) -> str
get_coverage(name: str, *, workspace: str, store: Optional[str] = None, quiet_on_not_found: bool = False, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Get an individual coverage.

Parameters:

Name Type Description Default
name str

The name of the coverage.

required
workspace str

The name of the workspace.

required
store Optional[str]

Optional. The name of the coverage datastore. Defaults to None.

None
quiet_on_not_found bool

Optional. If true, the server will not report an error if the coverage is not found.

False
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The requested coverage.

Example

To get a coverage, use the following code:

geoserver.get_coverage("my_coverage", workspace="my_workspace")

To specify a coverage store, use the following code:

geoserver.get_coverage("my_coverage", workspace="my_workspace", store="my_coverage_store")
Source code in geoserver/geoserver.py
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
def get_coverage(
    self,
    name: str,
    *,
    workspace: str,
    store: Optional[str] = None,
    quiet_on_not_found: bool = False,
    format: Literal["json", "xml"] = "json",
) -> Union[str, Dict[str, Any]]:
    """Get an individual coverage.

    Args:
        name: The name of the coverage.
        workspace: The name of the workspace.
        store: Optional. The name of the coverage datastore. Defaults to None.
        quiet_on_not_found: Optional. If true, the server will not report an error if the coverage is not found.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The requested coverage.

    Example:
        To get a coverage, use the following code:

        ```python
        geoserver.get_coverage("my_coverage", workspace="my_workspace")
        ```

        To specify a coverage store, use the following code:

        ```python
        geoserver.get_coverage("my_coverage", workspace="my_workspace", store="my_coverage_store")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/coverages/{name}.{format}"
    if store is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{store}/coverages/{name}.{format}"

    response = self._request(method="get", url=url, params=dict(quietOnNotFound=quiet_on_not_found))
    return response.json() if format == "json" else response.text

get_coverage_index

get_coverage_index(name: str, *, workspace: str, store: Optional[str] = None, quiet_on_not_found: bool = False, format: Literal['json'] = 'json') -> Dict[str, Any]
get_coverage_index(name: str, *, workspace: str, store: Optional[str] = None, quiet_on_not_found: bool = False, format: Literal['xml']) -> str
get_coverage_index(name: str, *, workspace: str, store: Optional[str] = None, quiet_on_not_found: bool = False, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Get an individual coverage index structure.

Parameters:

Name Type Description Default
name str

The name of the coverage.

required
workspace str

The name of the workspace.

required
store Optional[str]

Optional. The name of the coverage datastore. Defaults to None.

None
quiet_on_not_found bool

Optional. If true, the server will not report an error if the coverage is not found.

False
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The requested coverage.

Example

To get a coverage index, use the following code:

geoserver.get_coverage_index("my_coverage", workspace="my_workspace")

To specify a coverage store, use the following code:

geoserver.get_coverage_index("my_coverage", workspace="my_workspace", store="my_coverage_store")
Source code in geoserver/geoserver.py
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
def get_coverage_index(
    self,
    name: str,
    *,
    workspace: str,
    store: Optional[str] = None,
    quiet_on_not_found: bool = False,
    format: Literal["json", "xml"] = "json",
) -> Union[str, Dict[str, Any]]:
    """Get an individual coverage index structure.

    Args:
        name: The name of the coverage.
        workspace: The name of the workspace.
        store: Optional. The name of the coverage datastore. Defaults to None.
        quiet_on_not_found: Optional. If true, the server will not report an error if the coverage is not found.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The requested coverage.

    Example:
        To get a coverage index, use the following code:

        ```python
        geoserver.get_coverage_index("my_coverage", workspace="my_workspace")
        ```

        To specify a coverage store, use the following code:

        ```python
        geoserver.get_coverage_index("my_coverage", workspace="my_workspace", store="my_coverage_store")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/coverages/{name}/index.{format}"
    if store is not None:
        url = (
            f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{store}/coverages/{name}/index.{format}"
        )

    response = self._request(method="get", url=url, params=dict(quietOnNotFound=quiet_on_not_found))
    return response.json() if format == "json" else response.text

update_coverage

update_coverage(name: str, body: Union[str, Dict[str, Any]], *, workspace: str, store: str) -> str

Update an individual coverage

Parameters:

Name Type Description Default
name str

The name of the coverage.

required
body Union[str, Dict[str, Any]]

The body of the request used to update the coverage.

required
workspace str

The name of the workspace.

required
store str

The name of the coverage datastore

required

Returns:

Type Description
str

Success message.

Example

To update a coverage, use the following code:

# Check the GeoServer official documentation for the body structure
body = "..."

geoserver.update_coverage("my_coverage", body, workspace="my_workspace", store="my_coverage_store")
Source code in geoserver/geoserver.py
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
def update_coverage(self, name: str, body: Union[str, Dict[str, Any]], *, workspace: str, store: str) -> str:
    """Update an individual coverage

    Args:
        name: The name of the coverage.
        body: The body of the request used to update the coverage.
        workspace: The name of the workspace.
        store: The name of the coverage datastore

    Returns:
        Success message.

    Example:
        To update a coverage, use the following code:

        ```python
        # Check the GeoServer official documentation for the body structure
        body = "..."

        geoserver.update_coverage("my_coverage", body, workspace="my_workspace", store="my_coverage_store")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{store}/coverages/{name}"
    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

delete_coverage

delete_coverage(name: str, *, workspace: str, store: str, recurse: bool = False) -> str

Delete a coverage (optionally recursively deleting layers).

Parameters:

Name Type Description Default
name str

The name of the coverage.

required
workspace str

The name of the workspace.

required
store str

The name of the coverage datastore

required
recurse bool

Optional. If true all stores containing the resource are also removed.

False

Returns:

Type Description
str

Success message.

Example

To delete a coverage, use the following code:

geoserver.delete_coverage("my_coverage", workspace="my_workspace", store="my_coverage_store")
Source code in geoserver/geoserver.py
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
def delete_coverage(self, name: str, *, workspace: str, store: str, recurse: bool = False) -> str:
    """Delete a coverage (optionally recursively deleting layers).

    Args:
        name: The name of the coverage.
        workspace: The name of the workspace.
        store: The name of the coverage datastore
        recurse: Optional. If true all stores containing the resource are also removed.

    Returns:
        Success message.

    Example:
        To delete a coverage, use the following code:

        ```python
        geoserver.delete_coverage("my_coverage", workspace="my_workspace", store="my_coverage_store")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{store}/coverages/{name}"
    params = dict(recurse=recurse)
    self._request(method="delete", url=url, params=params)
    return DELETED_MESSAGE

reset_coverage_caches

reset_coverage_caches(name: str, *, workspace: str, store: str) -> str

Resets raster caches for this coverage. This operation is used to force GeoServer to drop caches associated to this coverage, and reconnect to the raster source the next time it is needed by a request. This is useful as the readers often cache some information about the bounds, coordinate system and image structure that might have changed in the meantime. Warning, the band structure is stored as part of the coverage configuration and won't be modified by this call, in case of need it should be modified issuing a PUT request against the coverage resource itself.

Parameters:

Name Type Description Default
name str

The name of the coverage.

required
workspace str

The name of the workspace.

required
store str

The name of the coverage datastore

required

Returns:

Type Description
str

Success message.

Example

To reset the caches of a coverage, use the following code:

geoserver.reset_coverage_caches("my_coverage", workspace="my_workspace", store="my_coverage_store")
Source code in geoserver/geoserver.py
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
def reset_coverage_caches(self, name: str, *, workspace: str, store: str) -> str:
    """Resets raster caches for this coverage.
    This operation is used to force GeoServer to drop caches associated to this coverage,
    and reconnect to the raster source the next time it is needed by a request.
    This is useful as the readers often cache some information about the bounds,
    coordinate system and image structure that might have changed in the meantime.
    Warning, the band structure is stored as part of the coverage configuration and won't be modified by this call,
    in case of need it should be modified issuing a PUT request against the coverage resource itself.

    Args:
        name: The name of the coverage.
        workspace: The name of the workspace.
        store: The name of the coverage datastore

    Returns:
        Success message.

    Example:
        To reset the caches of a coverage, use the following code:

        ```python
        geoserver.reset_coverage_caches("my_coverage", workspace="my_workspace", store="my_coverage_store")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{store}/coverages/{name}/reset"
    self._request(method="put", url=url)  # NOTE: Can also be a POST
    return OK_MESSAGE

get_coverage_stores

get_coverage_stores(*, workspace: str, format: Literal['json'] = 'json') -> Dict[str, Any]
get_coverage_stores(*, workspace: str, format: Literal['xml']) -> str
get_coverage_stores(*, workspace: str, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Displays a list of all styles on the server.

Parameters:

Name Type Description Default
workspace str

The name of the workspace.

required
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The list of all coverage stores in the workspace.

Example

To get the list of all coverage stores in a workspace, use the following code:

geoserver.get_coverage_stores(workspace="my_workspace")
Source code in geoserver/geoserver.py
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
def get_coverage_stores(
    self, *, workspace: str, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """Displays a list of all styles on the server.

    Args:
        workspace: The name of the workspace.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The list of all coverage stores in the workspace.

    Example:
        To get the list of all coverage stores in a workspace, use the following code:

        ```python
        geoserver.get_coverage_stores(workspace="my_workspace")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

coveragestore_exists

coveragestore_exists(name: str, *, workspace: str) -> bool

Check if a coverage store exists in a workspace.

Parameters:

Name Type Description Default
name str

The name of the coverage store.

required
workspace str

The name of the workspace containing the coverage stores.

required

Returns:

Type Description
bool

True if the coverage store exists, False otherwise.

Example

To check if a coverage store exists in a workspace, use the following code:

geoserver.coveragestore_exists("my_coverage_store", workspace="my_workspace")
Source code in geoserver/geoserver.py
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
def coveragestore_exists(self, name: str, *, workspace: str) -> bool:
    """Check if a coverage store exists in a workspace.

    Args:
        name: The name of the coverage store.
        workspace: The name of the workspace containing the coverage stores.

    Returns:
        True if the coverage store exists, False otherwise.

    Example:
        To check if a coverage store exists in a workspace, use the following code:

        ```python
        geoserver.coveragestore_exists("my_coverage_store", workspace="my_workspace")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{name}.xml"
    response = self._request(method="head", url=url, ignore=[404])
    return response.status_code == 200

create_coverage_store

create_coverage_store(body: Union[str, Dict[str, Any]], *, workspace: str) -> str

Adds a new coverage store.

Warning

It is preferred to use the upload_coverage_store method to upload a new coverage store.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to create the coverage store.

required
workspace str

The name of the workspace.

required

Returns:

Type Description
str

Success message.

Example

To create a new coverage store, use the following code:

# Check the GeoServer official documentation for the body structure
body = "..."

geoserver.create_coverage_store(body, workspace="my_workspace")
Source code in geoserver/geoserver.py
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
def create_coverage_store(self, body: Union[str, Dict[str, Any]], *, workspace: str) -> str:
    """Adds a new coverage store.

    Warning:
        It is preferred to use the `upload_coverage_store` method to upload a new coverage store.

    Args:
        body: The body of the request used to create the coverage store.
        workspace: The name of the workspace.

    Returns:
        Success message.

    Example:
        To create a new coverage store, use the following code:

        ```python
        # Check the GeoServer official documentation for the body structure
        body = "..."

        geoserver.create_coverage_store(body, workspace="my_workspace")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores"
    self._request(method="post", url=url, body=body)
    return CREATED_MESSAGE

upload_coverage_store

upload_coverage_store(file: Union[str, Path, BufferedReader], *, workspace: str, name: Optional[str] = None, method: Literal['auto', 'file', 'external', 'url', 'remote'] = 'auto', format: Literal['geotiff', 'worldimage', 'imagemosaic'], update_bbox: bool = False, configure: Literal['none', 'all'] = 'all', use_jai_imageread: bool = False, coverage_name: Optional[str] = None, filename: Optional[str] = None) -> str

Adds a new or update an existing coverage store from a local file.

Tip

This method is the preferred way to upload a new coverage store.

Note

The store parameter is automatically inferred from the file, if not provided. In case the file is a buffer, the store parameter is required.

Note

The file name of the resource can be overwritten by: - Providing the filename parameter. - Using the store parameter. In this case, if the filename is not provided, the file name will be the same as the store name.

Parameters:

Name Type Description Default
file Union[str, Path, BufferedReader]

The file to upload.

required
workspace str

The name of the workspace.

required
name Optional[str]

Optional. The name of the coverage store.

None
filename Optional[str]

Optional. The filename parameter specifies the target file name for a file that needs to be harvested as part of a mosaic. This is important to avoid clashes and to make sure the right dimension values are available in the name for multidimensional mosaics to work. Only used if method="file".

None
format Literal['geotiff', 'worldimage', 'imagemosaic']

The type of the file. Must be one of "geotiff", "worldimage", or "imagemosaic".

required
update_bbox bool

When set to True, triggers re-calculation of the layer native bbox. Defaults to False.

False

Returns:

Type Description
str

Success message.

Example

To upload a new coverage store from a local file, use the following code:

geoserver.upload_coverage_store("my_coverage_store.zip", workspace="my_workspace", name="my_coverage_store", format="geotiff")

Or, using a buffer:

with open("my_coverage_store.zip", "rb") as f:
    geoserver.upload_coverage_store(f, workspace="my_workspace", name="my_coverage_store", format="geotiff")
Source code in geoserver/geoserver.py
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
def upload_coverage_store(
    self,
    file: Union[str, Path, BufferedReader],
    *,
    workspace: str,
    name: Optional[str] = None,
    method: Literal["auto", "file", "external", "url", "remote"] = "auto",
    format: Literal["geotiff", "worldimage", "imagemosaic"],
    update_bbox: bool = False,
    configure: Literal["none", "all"] = "all",
    use_jai_imageread: bool = False,
    coverage_name: Optional[str] = None,
    filename: Optional[str] = None,
) -> str:
    """Adds a new or update an existing coverage store from a local file.

    Tip:
        This method is the preferred way to upload a new coverage store.

    Note:
        The `store` parameter is automatically inferred from the file, if not provided.
        In case the file is a buffer, the `store` parameter is required.

    Note:
        The file name of the resource can be overwritten by:
        - Providing the `filename` parameter.
        - Using the `store` parameter. In this case, if the `filename` is not provided,
            the file name will be the same as the store name.

    Args:
        file: The file to upload.
        workspace: The name of the workspace.
        name: Optional. The name of the coverage store.
        filename:  Optional. The filename parameter specifies the target file name for a file that needs to be harvested as part of a mosaic.
            This is important to avoid clashes and to make sure the right dimension values are available in the name for multidimensional mosaics to work.
            Only used if method="file".
        format: The type of the file. Must be one of "geotiff", "worldimage", or "imagemosaic".
        update_bbox: When set to `True`, triggers re-calculation of the layer native bbox. Defaults to `False`.

    Returns:
        Success message.

    Example:
        To upload a new coverage store from a local file, use the following code:

        ```python
        geoserver.upload_coverage_store("my_coverage_store.zip", workspace="my_workspace", name="my_coverage_store", format="geotiff")
        ```

        Or, using a buffer:

        ```python
        with open("my_coverage_store.zip", "rb") as f:
            geoserver.upload_coverage_store(f, workspace="my_workspace", name="my_coverage_store", format="geotiff")
        ```
    """
    if isinstance(file, Path):
        file = file.as_posix()
    if isinstance(file, str):
        name = name or Path(file).stem
        filename = filename or f"{name}.{Path(file).suffix[1:]}"

    if name is None:
        raise ValueError("The `name` parameter is required")

    headers = {}
    if zipfile.is_zipfile(file):
        headers["Content-Type"] = "application/zip"

    params = dict(
        update=update_bbox,
        filename=filename,
        configure=configure,
        USE_JAI_IMAGEREAD=use_jai_imageread,
        coverage_name=coverage_name,
    )

    if method == "auto":
        if isinstance(file, str) and file.startswith(("file:")):
            method = "external"
        elif isinstance(file, str) and file.startswith(("http://", "https://")):
            method = "url"

    if isinstance(file, str) and method in ["external", "url", "remote"]:
        headers["Content-Type"] = "text/plain"
        url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{name}/{method}.{format}"
        self._request(method="put", url=url, data=file, params=params, headers=headers)
        return CREATED_MESSAGE

    url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{name}/file.{format}"
    self._request(method="put", url=url, file=file, params=params, headers=headers)
    return CREATED_MESSAGE

get_coverage_store

get_coverage_store(name: str, *, workspace: str, quiet_on_not_found: bool = False, format: Literal['json'] = 'json') -> Dict[str, Any]
get_coverage_store(name: str, *, workspace: str, quiet_on_not_found: bool = False, format: Literal['xml']) -> str
get_coverage_store(name: str, *, workspace: str, quiet_on_not_found: bool = False, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Get an individual coverage store.

Parameters:

Name Type Description Default
name str

The name of the coverage store.

required
workspace str

The name of the workspace.

required
quiet_on_not_found bool

Optional. If true, the server will not report an error if the coverage store is not found.

False
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The requested coverage store.

Example

To get a coverage store, use the following code:

geoserver.get_coverage_store("my_coverage_store", workspace="my_workspace")
Source code in geoserver/geoserver.py
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
def get_coverage_store(
    self, name: str, *, workspace: str, quiet_on_not_found: bool = False, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """Get an individual coverage store.

    Args:
        name: The name of the coverage store.
        workspace: The name of the workspace.
        quiet_on_not_found: Optional. If true, the server will not report an error if the coverage store is not found.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The requested coverage store.

    Example:
        To get a coverage store, use the following code:

        ```python
        geoserver.get_coverage_store("my_coverage_store", workspace="my_workspace")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{name}.{format}"
    response = self._request(method="get", url=url, params=dict(quietOnNotFound=quiet_on_not_found))
    return response.json()

update_coverage_store

update_coverage_store(name: str, body: Union[str, Dict[str, Any]], *, workspace: str) -> str

Modifies a single coverage store.

Parameters:

Name Type Description Default
name str

The name of the coverage store.

required
body Union[str, Dict[str, Any]]

The body of the request used to update the coverage store.

required
workspace str

The name of the workspace.

required

Returns:

Type Description
str

Success message.

Example

To update a coverage store, use the following code:

# Check the GeoServer official documentation for the body structure
body = "..."

geoserver.update_coverage_store("my_coverage_store", body, workspace="my_workspace")
Source code in geoserver/geoserver.py
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
def update_coverage_store(self, name: str, body: Union[str, Dict[str, Any]], *, workspace: str) -> str:
    """Modifies a single coverage store.

    Args:
        name: The name of the coverage store.
        body: The body of the request used to update the coverage store.
        workspace: The name of the workspace.

    Returns:
        Success message.

    Example:
        To update a coverage store, use the following code:

        ```python
        # Check the GeoServer official documentation for the body structure
        body = "..."

        geoserver.update_coverage_store("my_coverage_store", body, workspace="my_workspace")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{name}"
    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

delete_coverage_store

delete_coverage_store(name: str, *, workspace: str, purge: Literal['none', 'metadata', 'all'] = 'all', recurse: bool = False) -> str

Deletes a coverage store.

Parameters:

Name Type Description Default
name str

The name of the coverage store.

required
workspace str

The name of the workspace.

required
purge Literal['none', 'metadata', 'all']

Optional. The purge parameter specifies if and how the underlying raster data source is deleted. When set to "none" data and auxiliary files are preserved. When set to "metadata" delete only auxiliary files and metadata. It's recommended when data files (such as granules) should not be deleted from disk. Finally, when set to "all both data and auxiliary files are removed. Defaults to "none".

'all'
recurse bool

Optional. The recurse controls recursive deletion. When set to true all resources contained in the store are also removed. The default to false.

False

Returns:

Type Description
str

Success message.

Example

To delete a coverage store, use the following code:

geoserver.delete_coverage_store("my_coverage_store", workspace="my_workspace")

To remove all resources contained in the store, use the following code:

geoserver.delete_coverage_store("my_coverage_store", workspace="my_workspace", recurse=True)
Source code in geoserver/geoserver.py
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
def delete_coverage_store(
    self, name: str, *, workspace: str, purge: Literal["none", "metadata", "all"] = "all", recurse: bool = False
) -> str:
    """Deletes a coverage store.

    Args:
        name: The name of the coverage store.
        workspace: The name of the workspace.
        purge: Optional. The purge parameter specifies if and how the underlying raster data source is deleted.
            When set to "none" data and auxiliary files are preserved.
            When set to "metadata" delete only auxiliary files and metadata.
            It's recommended when data files (such as granules) should not be deleted from disk.
            Finally, when set to "all both data and auxiliary files are removed.
            Defaults to "none".
        recurse: Optional. The recurse controls recursive deletion.
            When set to true all resources contained in the store are also removed.
            The default to false.

    Returns:
        Success message.

    Example:
        To delete a coverage store, use the following code:

        ```python
        geoserver.delete_coverage_store("my_coverage_store", workspace="my_workspace")
        ```

        To remove all resources contained in the store, use the following code:

        ```python
        geoserver.delete_coverage_store("my_coverage_store", workspace="my_workspace", recurse=True)
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{name}"
    params = dict(purge=purge, recurse=recurse)
    self._request(method="delete", url=url, params=params)
    return DELETED_MESSAGE

reset_coverage_store_caches

reset_coverage_store_caches(name: str, *, workspace: str) -> str

Resets raster caches for this coverage store. This operation is used to force GeoServer to drop caches associated to this coverage store, and reconnect to the raster source the next time it is needed by a request. This is useful as the readers often cache some information about the bounds, coordinate system and image structure that might have changed in the meantime.

Parameters:

Name Type Description Default
name str

The name of the coverage store.

required
workspace str

The name of the workspace.

required

Returns:

Type Description
str

Success message.

Example

To reset the caches of a coverage store, use the following code:

geoserver.reset_coverage_store_caches("my_coverage_store", workspace="my_workspace")
Source code in geoserver/geoserver.py
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
def reset_coverage_store_caches(self, name: str, *, workspace: str) -> str:
    """Resets raster caches for this coverage store.
    This operation is used to force GeoServer to drop caches associated to this coverage store,
    and reconnect to the raster source the next time it is needed by a request.
    This is useful as the readers often cache some information about the bounds,
    coordinate system and image structure that might have changed in the meantime.

    Args:
        name: The name of the coverage store.
        workspace: The name of the workspace.

    Returns:
        Success message.

    Example:
        To reset the caches of a coverage store, use the following code:

        ```python
        geoserver.reset_coverage_store_caches("my_coverage_store", workspace="my_workspace")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{name}/reset"
    self._request(method="put", url=url)
    return OK_MESSAGE

get_feature_types

get_feature_types(*, workspace: str, store: Optional[str] = None, format: Literal['json'] = 'json') -> Dict[str, Any]
get_feature_types(*, workspace: str, store: Optional[str] = None, format: Literal['xml']) -> str
get_feature_types(*, workspace: str, store: Optional[str] = None, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

List all feature types in the workspace.

Parameters:

Name Type Description Default
workspace str

The name of the workspace.

required
store Optional[str]

The name of the data store.

None
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The list of all feature types in the workspace.

Example

To get the list of all feature types in a workspace, use the following code:

geoserver.get_feature_types(workspace="my_workspace")
Source code in geoserver/geoserver.py
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
def get_feature_types(
    self, *, workspace: str, store: Optional[str] = None, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """List all feature types in the workspace.

    Args:
        workspace: The name of the workspace.
        store: The name of the data store.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The list of all feature types in the workspace.

    Example:
        To get the list of all feature types in a workspace, use the following code:

        ```python
        geoserver.get_feature_types(workspace="my_workspace")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/featuretypes.{format}"
    if store is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/datastores/{store}/featuretypes.{format}"

    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

create_feature_type

create_feature_type(body: Union[str, Dict[str, Any]], *, workspace: str, store: Optional[str] = None) -> str

Create a new feature type.

Note

When creating a new feature type via POST, if no underlying dataset with the specified name exists an attempt will be made to create it. This will work only in cases where the underlying data format supports the creation of new types (such as a database). When creating a feature type in this manner the client should include all attribute information in the feature type representation.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to create the feature type.

required
workspace str

The name of the workspace.

required
store Optional[str]

Optional. The name of the data store.

None

Returns:

Type Description
str

Success message.

Example

To create a new feature type, use the following code:

# Check the GeoServer official documentation for the body structure
body = "..."

geoserver.create_feature_type(body, workspace="my_workspace", store="my_data_store")
Source code in geoserver/geoserver.py
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
def create_feature_type(
    self, body: Union[str, Dict[str, Any]], *, workspace: str, store: Optional[str] = None
) -> str:
    """Create a new feature type.

    Note:
        When creating a new feature type via POST, if no underlying dataset
        with the specified name exists an attempt will be made to create it.
        This will work only in cases where the underlying data format supports the creation of new types (such as a database).
        When creating a feature type in this manner the client should include all attribute information
        in the feature type representation.

    Args:
        body: The body of the request used to create the feature type.
        workspace: The name of the workspace.
        store: Optional. The name of the data store.

    Returns:
        Success message.

    Example:
        To create a new feature type, use the following code:

        ```python
        # Check the GeoServer official documentation for the body structure
        body = "..."

        geoserver.create_feature_type(body, workspace="my_workspace", store="my_data_store")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/featuretypes"
    if store is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/datastores/{store}/featuretypes"

    self._request(method="post", url=url, body=body)
    return CREATED_MESSAGE

get_feature_type

get_feature_type(name: str, *, workspace: str, store: Optional[str] = None, quiet_on_not_found: bool = False, format: Literal['json'] = 'json') -> Dict[str, Any]
get_feature_type(name: str, *, workspace: str, store: Optional[str] = None, quiet_on_not_found: bool = False, format: Literal['xml']) -> str
get_feature_type(name: str, *, workspace: str, store: Optional[str] = None, quiet_on_not_found: bool = False, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Get an individual feature type.

Parameters:

Name Type Description Default
name str

The name of the feature type.

required
workspace str

The name of the workspace.

required
store Optional[str]

Optional. The name of the data store.

None
quiet_on_not_found bool

Optional. If true, the server will not report an error if the feature type is not found.

False
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The requested feature type.

Example

To get a feature type, use the following code:

geoserver.get_feature_type("my_feature_type", workspace="my_workspace")
Source code in geoserver/geoserver.py
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
def get_feature_type(
    self,
    name: str,
    *,
    workspace: str,
    store: Optional[str] = None,
    quiet_on_not_found: bool = False,
    format: Literal["json", "xml"] = "json",
) -> Union[str, Dict[str, Any]]:
    """Get an individual feature type.

    Args:
        name: The name of the feature type.
        workspace: The name of the workspace.
        store: Optional. The name of the data store.
        quiet_on_not_found: Optional. If true, the server will not report an error if the feature type is not found.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The requested feature type.

    Example:
        To get a feature type, use the following code:

        ```python
        geoserver.get_feature_type("my_feature_type", workspace="my_workspace")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/featuretypes/{name}.{format}"
    if store is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/datastores/{store}/featuretypes/{name}.{format}"

    response = self._request(method="get", url=url, params=dict(quietOnNotFound=quiet_on_not_found))
    return response.json() if format == "json" else response.text

update_feature_type

update_feature_type(name: str, body: Union[str, Dict[str, Any]], *, workspace: str, store: Optional[str] = None, recalculate: Literal['', 'nativebbox', 'nativebbox,latlonbbox'] = '') -> str

Update an individual feature type.

Parameters:

Name Type Description Default
name str

The name of the feature type.

required
body Union[str, Dict[str, Any]]

The body of the request used to modify the feature type.

required
workspace str

The name of the workspace.

required
store Optional[str]

Optional. The name of the data store.

None
recalculate Literal['', 'nativebbox', 'nativebbox,latlonbbox']

Optional. Specifies whether to recalculate properties for a feature type. Some properties of feature types are automatically recalculated when necessary. In particular, the native bounding box is recalculated when the projection or projection policy are changed, and the lat/lon bounding box is recalculated when the native bounding box is recalculated, or when a new native bounding box is explicitly provided in the request. (The native and lat/lon bounding boxes are not automatically recalculated when they are explicitly included in the request.) In addition, the client may explicitly request a fixed set of fields to calculate, by including a comma-separated list of their names in the recalculate parameter. The empty parameter 'recalculate=' is useful avoid slow recalculation when operating against large datasets as 'recalculate=' avoids calculating any fields, regardless of any changes to projection, projection policy, etc. The nativebbox parameter 'recalculate=nativebbox' is used recalculates the native bounding box, while avoiding recalculating the lat/lon bounding box. Recalculate parameters can be used in together - 'recalculate=nativebbox,latlonbbox' can be used after a bulk import to recalculate both the native bounding box and the lat/lon bounding box. Finally, 'recalculate=attributes' can be used to reset the attributes and reload them from the original vector source. Pay attention to its usage, if attributes were explicitly configured to perform attribute selection, renaming, and other transformations, such configuration will be lost, resetting the feature type to the list of attributes found in the vector data source.

''

Returns:

Type Description
str

Success message.

Example

To update a feature type, use the following code:

# Check the GeoServer official documentation for the body structure
body = "..."

geoserver.update_feature_type("my_feature_type", body, workspace="my_workspace")
Source code in geoserver/geoserver.py
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
def update_feature_type(
    self,
    name: str,
    body: Union[str, Dict[str, Any]],
    *,
    workspace: str,
    store: Optional[str] = None,
    recalculate: Literal["", "nativebbox", "nativebbox,latlonbbox"] = "",
) -> str:
    """Update an individual feature type.

    Args:
        name: The name of the feature type.
        body: The body of the request used to modify the feature type.
        workspace: The name of the workspace.
        store: Optional. The name of the data store.
        recalculate: Optional. Specifies whether to recalculate properties for a feature type.
            Some properties of feature types are automatically recalculated when necessary.
            In particular, the native bounding box is recalculated when the projection or projection policy are changed,
            and the lat/lon bounding box is recalculated when the native bounding box is recalculated,
            or when a new native bounding box is explicitly provided in the request.
            (The native and lat/lon bounding boxes are not automatically recalculated when they are explicitly included in the request.)
            In addition, the client may explicitly request a fixed set of fields to calculate, by including a comma-separated list of their names in the recalculate parameter.
            The empty parameter 'recalculate=' is useful avoid slow recalculation when operating against large datasets as 'recalculate=' avoids calculating any fields,
            regardless of any changes to projection, projection policy, etc. The nativebbox parameter 'recalculate=nativebbox'
            is used recalculates the native bounding box, while avoiding recalculating the lat/lon bounding box. Recalculate parameters
            can be used in together - 'recalculate=nativebbox,latlonbbox' can be used after a bulk import to recalculate both
            the native bounding box and the lat/lon bounding box. Finally, 'recalculate=attributes' can be used to reset the attributes
            and reload them from the original vector source. Pay attention to its usage, if attributes were explicitly configured to
            perform attribute selection, renaming, and other transformations, such configuration will be lost, resetting the
            feature type to the list of attributes found in the vector data source.

    Returns:
        Success message.

    Example:
        To update a feature type, use the following code:

        ```python
        # Check the GeoServer official documentation for the body structure
        body = "..."

        geoserver.update_feature_type("my_feature_type", body, workspace="my_workspace")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/featuretypes/{name}"
    if store is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/datastores/{store}/featuretypes/{name}"

    params = dict(recalculate=recalculate)
    self._request(method="put", url=url, body=body, params=params)
    return UPDATED_MESSAGE

delete_feature_type

delete_feature_type(name: str, *, workspace: str, store: Optional[str] = None, recurse: bool = False) -> str

Delete an individual feature type.

Parameters:

Name Type Description Default
name str

The name of the feature type.

required
workspace str

The name of the workspace.

required
store Optional[str]

Optional. The name of the data store.

None
recurse bool

Optional. If true, all resources contained in the store are also removed.

False

Returns:

Type Description
str

Success message.

Example

To delete a feature type, use the following code:

geoserver.delete_feature_type("my_feature_type", workspace="my_workspace")

To also remove all associated resources, use the following code:

geoserver.delete_feature_type("my_feature_type", workspace="my_workspace", recurse=True)
Source code in geoserver/geoserver.py
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
def delete_feature_type(
    self, name: str, *, workspace: str, store: Optional[str] = None, recurse: bool = False
) -> str:
    """Delete an individual feature type.

    Args:
        name: The name of the feature type.
        workspace: The name of the workspace.
        store: Optional. The name of the data store.
        recurse: Optional. If true, all resources contained in the store are also removed.

    Returns:
        Success message.

    Example:
        To delete a feature type, use the following code:

        ```python
        geoserver.delete_feature_type("my_feature_type", workspace="my_workspace")
        ```

        To also remove all associated resources, use the following code:

        ```python
        geoserver.delete_feature_type("my_feature_type", workspace="my_workspace", recurse=True)
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/featuretypes/{name}"
    if store is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/datastores/{store}/featuretypes/{name}"

    params = dict(recurse=recurse)
    self._request(method="delete", url=url, params=params)
    return DELETED_MESSAGE

reset_feature_type_caches

reset_feature_type_caches(name: str, *, workspace: str, store: Optional[str] = None) -> str

Resets caches for this feature type. This operation is used to force GeoServer to drop caches associated to this feature type, and reconnect to the vector source the next time it is needed by a request. This is useful as the store can keep state, such as a connection pool, and the structure of the feature types it's serving.

Parameters:

Name Type Description Default
name str

The name of the feature type.

required
workspace str

The name of the workspace.

required
store Optional[str]

Optional. The name of the data store.

None

Returns:

Type Description
str

Success message.

Example

To reset the caches of a feature type, use the following code:

geoserver.reset_feature_type_caches("my_feature_type", workspace="my_workspace")

To specify a data store, use the following code:

geoserver.reset_feature_type_caches("my_feature_type", workspace="my_workspace", store="my_data_store")
Source code in geoserver/geoserver.py
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
def reset_feature_type_caches(self, name: str, *, workspace: str, store: Optional[str] = None) -> str:
    """Resets caches for this feature type.
    This operation is used to force GeoServer to drop caches associated to this feature type,
    and reconnect to the vector source the next time it is needed by a request.
    This is useful as the store can keep state, such as a connection pool,
    and the structure of the feature types it's serving.

    Args:
        name: The name of the feature type.
        workspace: The name of the workspace.
        store: Optional. The name of the data store.

    Returns:
        Success message.

    Example:
        To reset the caches of a feature type, use the following code:

        ```python
        geoserver.reset_feature_type_caches("my_feature_type", workspace="my_workspace")
        ```

        To specify a data store, use the following code:

        ```python
        geoserver.reset_feature_type_caches("my_feature_type", workspace="my_workspace", store="my_data_store")
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/featuretypes/{name}/reset"
    if store is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/datastores/{store}/featuretypes/{name}/reset"

    self._request(method="put", url=url)
    return OK_MESSAGE

get_fonts

get_fonts(*, format: Literal['json'] = 'json') -> Dict[str, Any]
get_fonts(*, format: Literal['xml']) -> str
get_fonts(*, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

List all fonts available to GeoServer.

Parameters:

Name Type Description Default
format Literal['json', 'xml']

The format of the response. It can be either "json" or "xml".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The list of all fonts available to GeoServer.

Example

To get the list of all fonts available to GeoServer, use the following code:

geoserver.get_fonts()
Source code in geoserver/geoserver.py
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
def get_fonts(self, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """List all fonts available to GeoServer.

    Args:
        format: The format of the response. It can be either "json" or "xml".

    Returns:
        The list of all fonts available to GeoServer.

    Example:
        To get the list of all fonts available to GeoServer, use the following code:

        ```python
        geoserver.get_fonts()
        ```
    """
    url = f"{self.service_url}/rest/fonts.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

get_layer_groups

get_layer_groups(*, workspace: Optional[str] = None, format: Literal['json'] = 'json') -> Dict[str, Any]
get_layer_groups(*, workspace: Optional[str] = None, format: Literal['xml']) -> str
get_layer_groups(*, workspace: Optional[str] = None, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

List all layer groups in the workspace.

Parameters:

Name Type Description Default
workspace Optional[str]

Optional. The name of the workspace.

None
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The list of all layer groups in the workspace.

Example

To get the list of all layer groups, use the following code:

geoserver.get_layer_groups()
Source code in geoserver/geoserver.py
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
def get_layer_groups(
    self, *, workspace: Optional[str] = None, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """List all layer groups in the workspace.

    Args:
        workspace: Optional. The name of the workspace.
        format: Optional. The format of the response. It can be either "json" or "xml".

    Returns:
        The list of all layer groups in the workspace.

    Example:
        To get the list of all layer groups, use the following code:

        ```python
        geoserver.get_layer_groups()
        ```
    """
    url = f"{self.service_url}/rest/layergroups.{format}"
    if workspace is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/layergroups.{format}"

    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

layer_group_exists

layer_group_exists(name: str, *, workspace: Optional[str] = None) -> bool

Check if a layer group exists.

Parameters:

Name Type Description Default
name str

The name of the layer group.

required
workspace Optional[str]

Optional. The name of the workspace.

None

Returns:

Type Description
bool

True if the layer group exists, False otherwise.

Source code in geoserver/geoserver.py
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
def layer_group_exists(self, name: str, *, workspace: Optional[str] = None) -> bool:
    """Check if a layer group exists.

    Args:
        name: The name of the layer group.
        workspace: Optional. The name of the workspace.

    Returns:
        True if the layer group exists, False otherwise.
    """
    url = f"{self.service_url}/rest/layergroups/{name}.xml"
    if workspace is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/layergroups/{name}.xml"

    response = self._request(method="head", url=url, ignore=[404])
    return response.status_code == 200

create_layer_group

create_layer_group(body: Union[str, Dict[str, Any]], *, workspace: Optional[str] = None) -> str

Create a new layer group.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to create the layer group.

required
workspace Optional[str]

Optional. The name of the workspace.

None

Returns:

Type Description
str

The created layer group.

Source code in geoserver/geoserver.py
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
def create_layer_group(self, body: Union[str, Dict[str, Any]], *, workspace: Optional[str] = None) -> str:
    """Create a new layer group.

    Args:
        body: The body of the request used to create the layer group.
        workspace: Optional. The name of the workspace.

    Returns:
        The created layer group.
    """
    url = f"{self.service_url}/rest/layergroups"
    if workspace is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/layergroups"

    self._request(method="post", url=url, body=body)
    return CREATED_MESSAGE

get_layer_group

get_layer_group(name: str, *, workspace: Optional[str] = None, quiet_on_not_found: bool = False, format: Literal['json'] = 'json') -> Dict[str, Any]
get_layer_group(name: str, *, workspace: Optional[str] = None, quiet_on_not_found: bool = False, format: Literal['xml']) -> str
get_layer_group(name: str, *, workspace: Optional[str] = None, quiet_on_not_found: bool = False, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Get an individual layer group.

Parameters:

Name Type Description Default
name str

The name of the layer group.

required
workspace Optional[str]

Optional. The name of the workspace.

None
quiet_on_not_found bool

Optional. If true, the server will not report an error if the layer group is not found.

False
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The requested layer group.

Source code in geoserver/geoserver.py
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
def get_layer_group(
    self,
    name: str,
    *,
    workspace: Optional[str] = None,
    quiet_on_not_found: bool = False,
    format: Literal["json", "xml"] = "json",
) -> Union[str, Dict[str, Any]]:
    """Get an individual layer group.

    Args:
        name: The name of the layer group.
        workspace: Optional. The name of the workspace.
        quiet_on_not_found: Optional. If true, the server will not report an error if the layer group is not found.
        format: Optional. The format of the response. It can be either "json" or "xml".

    Returns:
        The requested layer group.
    """
    url = f"{self.service_url}/rest/layergroups/{name}.{format}"
    if workspace is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/layergroups/{name}.{format}"

    response = self._request(method="get", url=url, params=dict(quietOnNotFound=quiet_on_not_found))
    return response.json() if format == "json" else response.text

update_layer_group

update_layer_group(name: str, body: Union[str, Dict[str, Any]], *, workspace: Optional[str] = None) -> str

Update an individual layer group.

Parameters:

Name Type Description Default
name str

The name of the layer group.

required
body Union[str, Dict[str, Any]]

The body of the request used to modify the layer group.

required
workspace Optional[str]

Optional. The name of the workspace.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
def update_layer_group(
    self, name: str, body: Union[str, Dict[str, Any]], *, workspace: Optional[str] = None
) -> str:
    """Update an individual layer group.

    Args:
        name: The name of the layer group.
        body: The body of the request used to modify the layer group.
        workspace: Optional. The name of the workspace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/layergroups/{name}"
    if workspace is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/layergroups/{name}"

    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

delete_layer_group

delete_layer_group(name: str, *, workspace: Optional[str] = None) -> str

Delete an individual layer group.

Parameters:

Name Type Description Default
name str

The name of the layer group.

required
workspace Optional[str]

Optional. The name of the workspace.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
def delete_layer_group(self, name: str, *, workspace: Optional[str] = None) -> str:
    """Delete an individual layer group.

    Args:
        name: The name of the layer group.
        workspace: Optional. The name of the workspace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/layergroups/{name}"
    if workspace is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/layergroups/{name}"

    self._request(method="delete", url=url)
    return DELETED_MESSAGE

get_layers

get_layers(*, workspace: Optional[str] = None, format: Literal['json'] = 'json') -> Dict[str, Any]
get_layers(*, workspace: Optional[str] = None, format: Literal['xml']) -> str
get_layers(*, workspace: Optional[str] = None, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

List all layers in the workspace.

Parameters:

Name Type Description Default
workspace Optional[str]

Optional. The name of the workspace.

None
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The list of all layers in the workspace.

Source code in geoserver/geoserver.py
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
def get_layers(
    self, *, workspace: Optional[str] = None, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """List all layers in the workspace.

    Args:
        workspace: Optional. The name of the workspace.
        format: Optional. The format of the response. It can be either "json" or "xml".

    Returns:
        The list of all layers in the workspace.
    """
    url = f"{self.service_url}/rest/layers.{format}"
    if workspace is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/layers.{format}"

    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

create_layer

create_layer(body: Union[str, Dict[str, Any]], *, workspace: Optional[str] = None) -> str

Creates a new layer.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to create the layer.

required
workspace Optional[str]

Optional. The name of the workspace.

None

Returns:

Type Description
str

The created layer.

Source code in geoserver/geoserver.py
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
def create_layer(self, body: Union[str, Dict[str, Any]], *, workspace: Optional[str] = None) -> str:
    """Creates a new layer.

    Args:
        body: The body of the request used to create the layer.
        workspace: Optional. The name of the workspace.

    Returns:
        The created layer.
    """
    url = f"{self.service_url}/rest/layers"
    if workspace is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/layers"

    self._request(method="post", url=url, body=body)
    return CREATED_MESSAGE

get_layer

get_layer(name: str, *, workspace: Optional[str] = None, quiet_on_not_found: bool = False, format: Literal['json'] = 'json') -> Dict[str, Any]
get_layer(name: str, *, workspace: Optional[str] = None, quiet_on_not_found: bool = False, format: Literal['xml']) -> str
get_layer(name: str, *, workspace: Optional[str] = None, quiet_on_not_found: bool = False, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Get an individual layer.

Parameters:

Name Type Description Default
name str

The name of the layer.

required
workspace Optional[str]

Optional. The name of the workspace.

None
quiet_on_not_found bool

Optional. If true, the server will not report an error if the layer is not found.

False
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The requested layer.

Source code in geoserver/geoserver.py
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
def get_layer(
    self,
    name: str,
    *,
    workspace: Optional[str] = None,
    quiet_on_not_found: bool = False,
    format: Literal["json", "xml"] = "json",
) -> Union[str, Dict[str, Any]]:
    """Get an individual layer.

    Args:
        name: The name of the layer.
        workspace: Optional. The name of the workspace.
        quiet_on_not_found: Optional. If true, the server will not report an error if the layer is not found.
        format: Optional. The format of the response. It can be either "json" or "xml".

    Returns:
        The requested layer.
    """
    url = f"{self.service_url}/rest/layers/{name}.{format}"
    if workspace is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/layers/{name}.{format}"

    response = self._request(method="get", url=url, params=dict(quietOnNotFound=quiet_on_not_found))
    return response.json() if format == "json" else response.text

update_layer

update_layer(name: str, body: Union[str, Dict[str, Any]], *, workspace: Optional[str] = None) -> str

Update an individual layer.

Parameters:

Name Type Description Default
name str

The name of the layer.

required
body Union[str, Dict[str, Any]]

The body of the request used to modify the layer.

required
workspace Optional[str]

The name of the workspace.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
def update_layer(self, name: str, body: Union[str, Dict[str, Any]], *, workspace: Optional[str] = None) -> str:
    """Update an individual layer.

    Args:
        name: The name of the layer.
        body: The body of the request used to modify the layer.
        workspace: The name of the workspace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/layers/{name}"
    if workspace is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/layers/{name}"

    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

delete_layer

delete_layer(name: str, *, workspace: Optional[str] = None) -> str

Delete an individual layer.

Parameters:

Name Type Description Default
name str

The name of the layer.

required
workspace Optional[str]

The name of the workspace.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
def delete_layer(self, name: str, *, workspace: Optional[str] = None) -> str:
    """Delete an individual layer.

    Args:
        name: The name of the layer.
        workspace: The name of the workspace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/layers/{name}"
    if workspace is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/layers/{name}"

    self._request(method="delete", url=url)
    return DELETED_MESSAGE

get_logging

get_logging(*, format: Literal['json'] = 'json') -> Dict[str, Any]
get_logging(*, format: Literal['xml']) -> str
get_logging(*, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Displays a list of all logging settings on the server.

Parameters:

Name Type Description Default
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The logging settings.

Source code in geoserver/geoserver.py
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
def get_logging(self, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Displays a list of all logging settings on the server.

    Args:
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The logging settings.
    """
    url = f"{self.service_url}/rest/logging.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

update_logging

update_logging(body: Union[str, Dict[str, Any]]) -> str

Modify the logging settings on the server.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to modify the logging settings.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
def update_logging(self, body: Union[str, Dict[str, Any]]) -> str:
    """Modify the logging settings on the server.

    Args:
        body: The body of the request used to modify the logging settings.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/logging"
    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

get_monitored_requests

get_monitored_requests(*, format: Literal['json'] = 'json') -> Dict[str, Any]
get_monitored_requests(*, format: Literal['xml']) -> str
get_monitored_requests(*, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Returns a list of all requests known to the monitoring system. If no list of fields is specified, the full list will be returned, with the exception of Class, Body and Error fields. The HTML format return a summary of the requests, and links to the single request to gather details.

Parameters:

Name Type Description Default
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The monitoring requests.

Source code in geoserver/geoserver.py
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
def get_monitored_requests(self, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Returns a list of all requests known to the monitoring system.
    If no list of fields is specified, the full list will be returned,
    with the exception of Class, Body and Error fields.
    The HTML format return a summary of the requests,
    and links to the single request to gather details.

    Args:
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The monitoring requests.
    """
    url = f"{self.service_url}/rest/monitor/requests.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

delete_monitored_requests

delete_monitored_requests() -> str

Removes a request from the monitoring system.

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
1713
1714
1715
1716
1717
1718
1719
1720
1721
def delete_monitored_requests(self) -> str:
    """Removes a request from the monitoring system.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/monitor/requests"
    self._request(method="delete", url=url)
    return OK_MESSAGE

get_monitored_request

get_monitored_request(id: str, *, format: Literal['json'] = 'json') -> Dict[str, Any]
get_monitored_request(id: str, *, format: Literal['xml']) -> str
get_monitored_request(id: str, *, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Returns the details of a single request.

Parameters:

Name Type Description Default
id str

The id of the request to retrieve.

required
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The monitoring request.

Source code in geoserver/geoserver.py
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
def get_monitored_request(self, id: str, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Returns the details of a single request.

    Args:
        id: The id of the request to retrieve.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The monitoring request.
    """
    url = f"{self.service_url}/rest/monitor/requests/{id}.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

get_namespaces

get_namespaces(*, format: Literal['json'] = 'json') -> Dict[str, Any]
get_namespaces(*, format: Literal['xml']) -> str
get_namespaces(*, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

List all namespaces on the server.

Parameters:

Name Type Description Default
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The list of all namespaces on the server.

Source code in geoserver/geoserver.py
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
def get_namespaces(self, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """List all namespaces on the server.

    Args:
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The list of all namespaces on the server.
    """
    url = f"{self.service_url}/rest/namespaces.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

create_namespace

create_namespace(body: Union[str, Dict[str, Any]]) -> str

Create a new namespace.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to create the namespace.

required

Returns:

Type Description
str

The created namespace.

Source code in geoserver/geoserver.py
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
def create_namespace(self, body: Union[str, Dict[str, Any]]) -> str:
    """Create a new namespace.

    Args:
        body: The body of the request used to create the namespace.

    Returns:
        The created namespace.
    """
    url = f"{self.service_url}/rest/namespaces"
    self._request(method="post", url=url, body=body)
    return CREATED_MESSAGE

get_namespace

get_namespace(name: str, *, format: Literal['json'] = 'json') -> Dict[str, Any]
get_namespace(name: str, *, format: Literal['xml']) -> str
get_namespace(name: str, *, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Get an individual namespace.

Parameters:

Name Type Description Default
name str

The name of the namespace.

required
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The requested namespace.

Source code in geoserver/geoserver.py
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
def get_namespace(self, name: str, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Get an individual namespace.

    Args:
        name: The name of the namespace.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The requested namespace.
    """
    url = f"{self.service_url}/rest/namespaces/{name}.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

update_namespace

update_namespace(name: str, body: Union[str, Dict[str, Any]]) -> str

Update an individual namespace.

Parameters:

Name Type Description Default
name str

The name of the namespace.

required
body Union[str, Dict[str, Any]]

The body of the request used to modify the namespace.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
def update_namespace(self, name: str, body: Union[str, Dict[str, Any]]) -> str:
    """Update an individual namespace.

    Args:
        name: The name of the namespace.
        body: The body of the request used to modify the namespace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/namespaces/{name}"
    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

delete_namespace

delete_namespace(name: str) -> str

Delete an individual namespace.

Parameters:

Name Type Description Default
name str

The name of the namespace.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
def delete_namespace(self, name: str) -> str:
    """Delete an individual namespace.

    Args:
        name: The name of the namespace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/namespaces/{name}"
    self._request(method="delete", url=url)
    return DELETED_MESSAGE

get_wms_settings

get_wms_settings(*, workspace: Optional[str] = None, format: Literal['json'] = 'json') -> Dict[str, Any]
get_wms_settings(*, workspace: Optional[str] = None, format: Literal['xml']) -> str
get_wms_settings(*, workspace: Optional[str] = None, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Get the WMS settings for the workspace.

Parameters:

Name Type Description Default
workspace Optional[str]

Optional. The name of the workspace.

None
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The WMS settings for the workspace.

Source code in geoserver/geoserver.py
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
def get_wms_settings(
    self, *, workspace: Optional[str] = None, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """Get the WMS settings for the workspace.

    Args:
        workspace: Optional. The name of the workspace.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The WMS settings for the workspace.
    """
    url = f"{self.service_url}/rest/services/wms/settings.{format}"
    if workspace is not None:
        url = f"{self.service_url}/rest/services/wms/workspaces/{workspace}/settings.{format}"

    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

update_wms_settings

update_wms_settings(body: Union[str, Dict[str, Any]], *, workspace: Optional[str] = None) -> str

Update the WMS settings for the workspace.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to modify the WMS settings.

required
workspace Optional[str]

The name of the workspace.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
def update_wms_settings(self, body: Union[str, Dict[str, Any]], *, workspace: Optional[str] = None) -> str:
    """Update the WMS settings for the workspace.

    Args:
        body: The body of the request used to modify the WMS settings.
        workspace: The name of the workspace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/services/wms/settings"
    if workspace is not None:
        url = f"{self.service_url}/rest/services/wms/workspaces/{workspace}/settings"

    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

delete_wms_settings

delete_wms_settings(*, workspace: Optional[str] = None) -> str

Delete the WMS settings for the workspace.

Parameters:

Name Type Description Default
workspace Optional[str]

Optional. The name of the workspace.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
def delete_wms_settings(self, *, workspace: Optional[str] = None) -> str:
    """Delete the WMS settings for the workspace.

    Args:
        workspace: Optional. The name of the workspace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/services/wms/settings"
    if workspace is not None:
        url = f"{self.service_url}/rest/services/wms/workspaces/{workspace}/settings"

    self._request(method="delete", url=url)
    return DELETED_MESSAGE

get_wfs_settings

get_wfs_settings(*, workspace: Optional[str] = None, format: Literal['json'] = 'json') -> Dict[str, Any]
get_wfs_settings(*, workspace: Optional[str] = None, format: Literal['xml']) -> str
get_wfs_settings(*, workspace: Optional[str] = None, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Get the WFS settings for the workspace.

Parameters:

Name Type Description Default
workspace Optional[str]

Optional. The name of the workspace.

None
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The WFS settings for the workspace.

Source code in geoserver/geoserver.py
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
def get_wfs_settings(
    self, *, workspace: Optional[str] = None, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """Get the WFS settings for the workspace.

    Args:
        workspace: Optional. The name of the workspace.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The WFS settings for the workspace.
    """
    url = f"{self.service_url}/rest/services/wfs/settings.{format}"
    if workspace is not None:
        url = f"{self.service_url}/rest/services/wfs/workspaces/{workspace}/settings.{format}"

    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

update_wfs_settings

update_wfs_settings(body: Union[str, Dict[str, Any]], *, workspace: Optional[str] = None) -> str

Update the WFS settings for the workspace.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to modify the WFS settings.

required
workspace Optional[str]

Optional. The name of the workspace.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
def update_wfs_settings(self, body: Union[str, Dict[str, Any]], *, workspace: Optional[str] = None) -> str:
    """Update the WFS settings for the workspace.

    Args:
        body: The body of the request used to modify the WFS settings.
        workspace: Optional. The name of the workspace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/services/wfs/settings"
    if workspace is not None:
        url = f"{self.service_url}/rest/services/wfs/workspaces/{workspace}/settings"

    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

delete_wfs_settings

delete_wfs_settings(*, workspace: Optional[str] = None) -> str

Delete the WFS settings for the workspace.

Parameters:

Name Type Description Default
workspace Optional[str]

Optional. The name of the workspace.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
def delete_wfs_settings(self, *, workspace: Optional[str] = None) -> str:
    """Delete the WFS settings for the workspace.

    Args:
        workspace: Optional. The name of the workspace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/services/wfs/settings"
    if workspace is not None:
        url = f"{self.service_url}/rest/services/wfs/workspaces/{workspace}/settings"

    self._request(method="delete", url=url)
    return DELETED_MESSAGE

get_wcs_settings

get_wcs_settings(*, workspace: Optional[str] = None, format: Literal['json'] = 'json') -> Dict[str, Any]
get_wcs_settings(*, workspace: Optional[str] = None, format: Literal['xml']) -> str
get_wcs_settings(*, workspace: Optional[str] = None, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Get the WCS settings for the workspace.

Parameters:

Name Type Description Default
workspace Optional[str]

Optional. The name of the workspace.

None
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The WCS settings for the workspace.

Source code in geoserver/geoserver.py
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
def get_wcs_settings(
    self, *, workspace: Optional[str] = None, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """Get the WCS settings for the workspace.

    Args:
        workspace: Optional. The name of the workspace.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The WCS settings for the workspace.
    """
    url = f"{self.service_url}/rest/services/wcs/settings.{format}"
    if workspace is not None:
        url = f"{self.service_url}/rest/services/wcs/workspaces/{workspace}/settings.{format}"

    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

update_wcs_settings

update_wcs_settings(body: Union[str, Dict[str, Any]], *, workspace: Optional[str] = None) -> str

Update the WCS settings for the workspace.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to modify the WCS settings.

required
workspace Optional[str]

Optional. The name of the workspace.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
def update_wcs_settings(self, body: Union[str, Dict[str, Any]], *, workspace: Optional[str] = None) -> str:
    """Update the WCS settings for the workspace.

    Args:
        body: The body of the request used to modify the WCS settings.
        workspace: Optional. The name of the workspace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/services/wcs/settings"
    if workspace is not None:
        url = f"{self.service_url}/rest/services/wcs/workspaces/{workspace}/settings"

    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

delete_wcs_settings

delete_wcs_settings(*, workspace: Optional[str] = None) -> str

Delete the WCS settings for the workspace.

Parameters:

Name Type Description Default
workspace Optional[str]

Optional. The name of the workspace.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
def delete_wcs_settings(self, *, workspace: Optional[str] = None) -> str:
    """Delete the WCS settings for the workspace.

    Args:
        workspace: Optional. The name of the workspace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/services/wcs/settings"
    if workspace is not None:
        url = f"{self.service_url}/rest/services/wcs/workspaces/{workspace}/settings"

    self._request(method="delete", url=url)
    return DELETED_MESSAGE

get_wmts_settings

get_wmts_settings(*, workspace: Optional[str] = None, format: Literal['json'] = 'json') -> Dict[str, Any]
get_wmts_settings(*, workspace: Optional[str] = None, format: Literal['xml']) -> str
get_wmts_settings(*, workspace: Optional[str] = None, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Get the WMTS settings for the workspace.

Parameters:

Name Type Description Default
workspace Optional[str]

Optional. The name of the workspace.

None
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The WMTS settings for the workspace.

Source code in geoserver/geoserver.py
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
def get_wmts_settings(
    self, *, workspace: Optional[str] = None, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """Get the WMTS settings for the workspace.

    Args:
        workspace: Optional. The name of the workspace.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The WMTS settings for the workspace.
    """
    url = f"{self.service_url}/rest/services/wmts/settings.{format}"
    if workspace is not None:
        url = f"{self.service_url}/rest/services/wmts/workspaces/{workspace}/settings.{format}"

    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

update_wmts_settings

update_wmts_settings(body: Union[str, Dict[str, Any]], *, workspace: Optional[str] = None) -> str

Update the WMTS settings for the workspace.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to modify the WMTS settings.

required
workspace Optional[str]

Optional. The name of the workspace.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
def update_wmts_settings(self, body: Union[str, Dict[str, Any]], *, workspace: Optional[str] = None) -> str:
    """Update the WMTS settings for the workspace.

    Args:
        body: The body of the request used to modify the WMTS settings.
        workspace: Optional. The name of the workspace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/services/wmts/settings"
    if workspace is not None:
        url = f"{self.service_url}/rest/services/wmts/workspaces/{workspace}/settings"

    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

delete_wmts_settings

delete_wmts_settings(*, workspace: Optional[str] = None) -> str

Delete the WMTS settings for the workspace.

Parameters:

Name Type Description Default
workspace Optional[str]

Optional. The name of the workspace.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
def delete_wmts_settings(self, *, workspace: Optional[str] = None) -> str:
    """Delete the WMTS settings for the workspace.

    Args:
        workspace: Optional. The name of the workspace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/services/wmts/settings"
    if workspace is not None:
        url = f"{self.service_url}/rest/services/wmts/workspaces/{workspace}/settings"

    self._request(method="delete", url=url)
    return DELETED_MESSAGE

get_oseo_settings

get_oseo_settings(*, format: Literal['json'] = 'json') -> Dict[str, Any]
get_oseo_settings(*, format: Literal['xml']) -> str
get_oseo_settings(*, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Retrieves Open Search for Earth Observation Service settings globally for the server.

Parameters:

Name Type Description Default
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The OSEO settings for the workspace.

Source code in geoserver/geoserver.py
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
def get_oseo_settings(self, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Retrieves Open Search for Earth Observation Service settings globally for the server.

    Args:
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The OSEO settings for the workspace.
    """
    url = f"{self.service_url}/rest/services/oseo/settings.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

update_oseo_settings

update_oseo_settings(body: Union[str, Dict[str, Any]]) -> str

Update the Open Search for Earth Observation Service settings globally for the server.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to modify the OSEO settings.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
def update_oseo_settings(self, body: Union[str, Dict[str, Any]]) -> str:
    """Update the Open Search for Earth Observation Service settings globally for the server.

    Args:
        body: The body of the request used to modify the OSEO settings.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/services/oseo/settings"
    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

reset

reset() -> str

Resets all store, raster, and schema caches. This operation is used to force GeoServer to drop all caches and store connections and reconnect to each of them the next time they are needed by a request. This is useful in case the stores themselves cache some information about the data structures they manage that may have changed in the meantime.

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
def reset(self) -> str:
    """Resets all store, raster, and schema caches.
    This operation is used to force GeoServer to drop all caches and store connections and reconnect
    to each of them the next time they are needed by a request.
    This is useful in case the stores themselves cache some information about the data structures
    they manage that may have changed in the meantime.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/reset"
    self._request(method="put", url=url)
    return OK_MESSAGE

reload

reload() -> str

Reloads the GeoServer catalog and configuration from disk. This operation is used in cases where an external tool has modified the on-disk configuration. This operation will also force GeoServer to drop any internal caches and reconnect to all data stores.

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
def reload(self) -> str:
    """Reloads the GeoServer catalog and configuration from disk.
    This operation is used in cases where an external tool has modified the on-disk configuration.
    This operation will also force GeoServer to drop any internal caches and reconnect to all data stores.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/reload"
    self._request(method="put", url=url)
    return OK_MESSAGE

get_resource

get_resource(path: str, *, operation: Literal['default', 'metadata'] = 'default', format: Literal['json'] = 'json') -> Dict[str, Any]
get_resource(path: str, *, operation: Literal['default', 'metadata'] = 'default', format: Literal['xml']) -> str
get_resource(path: str, *, operation: Literal['default', 'metadata'] = 'default', format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Download a resource, list contents of directory, or show formatted resource metadata. Response content depends upon parameters. With operation=default, if the request is made against a non-directory resource, the content of the resource is returned.

Parameters:

Name Type Description Default
path str

The path to the resource.

required
operation Literal['default', 'metadata']

Optional. The type of resource to get. It can be either "default" or "metadata". Defaults to "default".

'default'
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The requested resource.

Example
geoserver.get_resource(resource="styles/default_point.sld", operation="default")
Source code in geoserver/geoserver.py
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
def get_resource(
    self,
    path: str,
    *,
    operation: Literal["default", "metadata"] = "default",
    format: Literal["json", "xml"] = "json",
) -> Union[str, Dict[str, Any]]:
    """Download a resource, list contents of directory, or show formatted resource metadata.
    Response content depends upon parameters.
    With operation=default, if the request is made against a non-directory resource, the content of the resource is returned.

    Args:
        path: The path to the resource.
        operation: Optional. The type of resource to get. It can be either "default" or "metadata". Defaults to "default".
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The requested resource.

    Example:
        ```python
        geoserver.get_resource(resource="styles/default_point.sld", operation="default")
        ```
    """
    url = f"{self.service_url}/rest/resources/{path}.{format}"
    params = dict(operation=operation, format="json")
    response = self._request(method="get", url=url, params=params)
    return response.json() if format == "json" else response.text

update_resource

update_resource(path: str, body: Union[str, Dict[str, Any]]) -> str

Upload/move/copy a resource, create directories on the fly (overwrite if exists). For move/copy operations, place source path in body. Copying is not supported for directories.

Parameters:

Name Type Description Default
path str

The path to the resource.

required
body Union[str, Dict[str, Any]]

The content of the resource to upload. In the case of a move or copy operation, this is instead the path to the source resource to move/copy from.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
def update_resource(self, path: str, body: Union[str, Dict[str, Any]]) -> str:
    """Upload/move/copy a resource, create directories on the fly (overwrite if exists). For move/copy operations, place source path in body. Copying is not supported for directories.

    Args:
        path: The path to the resource.
        body: The content of the resource to upload. In the case of a move or copy operation,
            this is instead the path to the source resource to move/copy from.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/resources/{path}"
    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

delete_resource

delete_resource(path: str) -> str

Delete a resource (recursively if directory)

Parameters:

Name Type Description Default
path str

The full path to the resource. Required, but may be empty; a request to /resource references the top level resource directory.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
def delete_resource(self, path: str) -> str:
    """Delete a resource (recursively if directory)

    Args:
        path: The full path to the resource. Required, but may be empty; a request to /resource references the top level resource directory.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/resources/{path}"
    self._request(method="delete", url=url)
    return DELETED_MESSAGE

resource_exists

resource_exists(path: str) -> bool

Check if a resource exists.

Parameters:

Name Type Description Default
path str

The full path to the resource.

required

Returns:

Type Description
bool

Success message.

Source code in geoserver/geoserver.py
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
def resource_exists(self, path: str) -> bool:
    """Check if a resource exists.

    Args:
        path: The full path to the resource.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/resources/{path}"
    response = self._request(method="head", url=url, ignore=[404])
    return response.status_code == 200

get_master_password

get_master_password(*, format: Literal['json'] = 'json') -> Dict[str, Any]
get_master_password(*, format: Literal['xml']) -> str
get_master_password(*, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Displays the keystore password. HTTPS is strongly suggested, otherwise password will be sent in plain text.

Parameters:

Name Type Description Default
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The master password.

Source code in geoserver/geoserver.py
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
def get_master_password(self, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Displays the keystore password. HTTPS is strongly suggested, otherwise password will be sent in plain text.

    Args:
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The master password.
    """
    url = f"{self.service_url}/rest/security/masterpw.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

update_master_password

update_master_password(body: Union[str, Dict[str, Any]]) -> str

Changes keystore password. Must supply current keystore password. HTTPS is strongly suggested, otherwise password will be sent in plain text.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to set the master password.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
def update_master_password(self, body: Union[str, Dict[str, Any]]) -> str:
    """Changes keystore password. Must supply current keystore password. HTTPS is strongly suggested, otherwise password will be sent in plain text.

    Args:
        body: The body of the request used to set the master password.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/security/masterpw"
    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

update_password

update_password(body: Union[str, Dict[str, Any]]) -> str

Updates the password for the account used to issue the request.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to set the password.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
def update_password(self, body: Union[str, Dict[str, Any]]) -> str:
    """Updates the password for the account used to issue the request.

    Args:
        body: The body of the request used to set the password.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/security/self/password"
    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

get_catalog_mode

get_catalog_mode(*, format: Literal['json'] = 'json') -> Dict[str, Any]
get_catalog_mode(*, format: Literal['xml']) -> str
get_catalog_mode(*, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Gets the catalog mode, which specifies how GeoServer will advertise secured layers and behave when a secured layer is accessed without the necessary privileges.

Parameters:

Name Type Description Default
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The catalog mode.

Source code in geoserver/geoserver.py
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
def get_catalog_mode(self, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Gets the catalog mode, which specifies how GeoServer will advertise secured layers
    and behave when a secured layer is accessed without the necessary privileges.

    Args:
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The catalog mode.
    """
    url = f"{self.service_url}/rest/security/acl/catalog.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

update_catalog_mode

update_catalog_mode(body: Union[str, Dict[str, Any]]) -> str

Changes catalog mode. The mode must be one of HIDE, MIXED, or CHALLENGE.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The catalog mode information to upload.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
def update_catalog_mode(self, body: Union[str, Dict[str, Any]]) -> str:
    """Changes catalog mode. The mode must be one of HIDE, MIXED, or CHALLENGE.

    Args:
        body: The catalog mode information to upload.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/security/acl/catalog"
    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

get_security_layers

get_security_layers(*, format: Literal['json'] = 'json') -> Dict[str, Any]
get_security_layers(*, format: Literal['xml']) -> str
get_security_layers(*, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Displays the current layer-based security rules.

Parameters:

Name Type Description Default
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The security layers.

Source code in geoserver/geoserver.py
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
def get_security_layers(self, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Displays the current layer-based security rules.

    Args:
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The security layers.
    """
    url = f"{self.service_url}/rest/security/acl/layers.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

security_layer_exists

security_layer_exists(rule: str) -> bool

Check if a security layer exists.

Parameters:

Name Type Description Default
rule str

The specified rule, as the last part in the URI, e.g. /security/acl/layers/..r

required

Returns:

Type Description
bool

Success message.

Source code in geoserver/geoserver.py
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
def security_layer_exists(self, rule: str) -> bool:
    """Check if a security layer exists.

    Args:
        rule: The specified rule, as the last part in the URI, e.g. /security/acl/layers/*.*.r

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/security/acl/layers/{rule}"
    response = self._request(method="head", url=url, ignore=[404, 405])
    return response.status_code == 200

create_security_layers

create_security_layers(body: Union[str, Dict[str, Any]]) -> str

Adds one or more new layer-based rules to the list of security rules.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to create the security layer.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
def create_security_layers(self, body: Union[str, Dict[str, Any]]) -> str:
    """Adds one or more new layer-based rules to the list of security rules.

    Args:
        body: The body of the request used to create the security layer.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/security/acl/layers"
    self._request(method="post", url=url, body=body)
    return CREATED_MESSAGE

update_security_layers

update_security_layers(body: Union[str, Dict[str, Any]]) -> str

Updates one or more layer-based security rules.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to modify the security layer.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
def update_security_layers(self, body: Union[str, Dict[str, Any]]) -> str:
    """Updates one or more layer-based security rules.

    Args:
        body: The body of the request used to modify the security layer.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/security/acl/layers"
    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

delete_security_layer

delete_security_layer(rule: Optional[str] = None) -> str

Removes one or more layer-based security rules from the list of security rules. The rule must specified in the last part of the URL and of the form ..[r|w|a]

Parameters:

Name Type Description Default
rule Optional[str]

Optional. The specified rule, as the last part in the URI, e.g. /security/acl/layers/..r

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
def delete_security_layer(self, rule: Optional[str] = None) -> str:
    """Removes one or more layer-based security rules from the list of security rules.
    The `rule` must specified in the last part of the URL and of the form <workspace>.<layer>.[r|w|a]

    Args:
        rule: Optional. The specified rule, as the last part in the URI, e.g. /security/acl/layers/*.*.r

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/security/acl/layers"
    if rule is not None:
        url = f"{self.service_url}/rest/security/acl/layers/{rule}"

    self._request(method="delete", url=url)
    return DELETED_MESSAGE

get_security_services

get_security_services(*, rule: Optional[str] = None, format: Literal['json'] = 'json') -> Dict[str, Any]
get_security_services(*, rule: Optional[str] = None, format: Literal['xml']) -> str
get_security_services(*, rule: Optional[str] = None, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Displays the current service-based security rules.

Parameters:

Name Type Description Default
rule Optional[str]

Optional. The specified rule, as the last part in the URI, e.g. /security/acl/layers/..r

None
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The security services.

Source code in geoserver/geoserver.py
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
def get_security_services(
    self, *, rule: Optional[str] = None, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """Displays the current service-based security rules.

    Args:
        rule: Optional. The specified rule, as the last part in the URI, e.g. /security/acl/layers/*.*.r
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The security services.
    """
    url = f"{self.service_url}/rest/security/acl/services.{format}"
    if rule is not None:
        url = f"{self.service_url}/rest/security/acl/services/{rule}.{format}"

    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

update_security_services

update_security_services(body: Union[str, Dict[str, Any]], *, rule: Optional[str] = None) -> str

Adds one or more new service-based rules to the list of security rules.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to create the security services.

required
rule Optional[str]

Optional. The specified rule, as the last part in the URI, e.g. /security/acl/layers/..r

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
def update_security_services(self, body: Union[str, Dict[str, Any]], *, rule: Optional[str] = None) -> str:
    """Adds one or more new service-based rules to the list of security rules.

    Args:
        body: The body of the request used to create the security services.
        rule: Optional. The specified rule, as the last part in the URI, e.g. /security/acl/layers/*.*.r

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/security/acl/services"
    if rule is not None:
        url = f"{self.service_url}/rest/security/acl/services/{rule}"

    self._request(method="post", url=url, body=body)
    return UPDATED_MESSAGE

delete_security_services

delete_security_services(*, rule: Optional[str] = None) -> str

Removes one or more service-based security rules from the list of security rules.

Parameters:

Name Type Description Default
rule Optional[str]

Optional. The specified rule, as the last part in the URI, e.g. /security/acl/layers/..r

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
def delete_security_services(self, *, rule: Optional[str] = None) -> str:
    """Removes one or more service-based security rules from the list of security rules.

    Args:
        rule: Optional. The specified rule, as the last part in the URI, e.g. /security/acl/layers/*.*.r

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/security/acl/services"
    if rule is not None:
        url = f"{self.service_url}/rest/security/acl/services/{rule}"

    self._request(method="delete", url=url)
    return DELETED_MESSAGE

get_security_access

get_security_access(*, rule: Optional[str] = None, format: Literal['json'] = 'json') -> Dict[str, Any]
get_security_access(*, rule: Optional[str] = None, format: Literal['xml']) -> str
get_security_access(*, rule: Optional[str] = None, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Displays the current REST access rules.

Parameters:

Name Type Description Default
rule Optional[str]

Optional. The specified rule, as the last part in the URI, e.g. /security/acl/layers/..r

None
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The security REST.

Source code in geoserver/geoserver.py
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
def get_security_access(
    self, *, rule: Optional[str] = None, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """Displays the current REST access rules.

    Args:
        rule: Optional. The specified rule, as the last part in the URI, e.g. /security/acl/layers/*.*.r
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The security REST.
    """
    url = f"{self.service_url}/rest/security/acl/rest.{format}"
    if rule is not None:
        url = f"{self.service_url}/rest/security/acl/{rule}.{format}"

    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

create_security_access

create_security_access(body: Union[str, Dict[str, Any]], *, rule: Optional[str] = None) -> str

Adds one or more new REST access rules.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to create the security access.

required
rule Optional[str]

Optional. The specified rule, as the last part in the URI, e.g. /security/acl/layers/..r

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
def create_security_access(self, body: Union[str, Dict[str, Any]], *, rule: Optional[str] = None) -> str:
    """Adds one or more new REST access rules.

    Args:
        body: The body of the request used to create the security access.
        rule: Optional. The specified rule, as the last part in the URI, e.g. /security/acl/layers/*.*.r

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/security/acl/rest"
    if rule is not None:
        url = f"{self.service_url}/rest/security/acl/{rule}"

    self._request(method="post", url=url, body=body)
    return CREATED_MESSAGE

update_security_access

update_security_access(body: Union[str, Dict[str, Any]], *, rule: Optional[str] = None) -> str

Updates one or more REST access rules.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to modify the security access.

required
rule Optional[str]

Optional. The specified rule, as the last part in the URI, e.g. /security/acl/layers/..r

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
def update_security_access(self, body: Union[str, Dict[str, Any]], *, rule: Optional[str] = None) -> str:
    """Updates one or more REST access rules.

    Args:
        body: The body of the request used to modify the security access.
        rule: Optional. The specified rule, as the last part in the URI, e.g. /security/acl/layers/*.*.r

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/security/acl/rest"
    if rule is not None:
        url = f"{self.service_url}/rest/security/acl/{rule}"

    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

delete_security_access

delete_security_access(body: Union[str, Dict[str, Any]], *, rule: Optional[str] = None) -> str

Removes one or more REST access rules.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to delete the security access.

required
rule Optional[str]

Optional. The specified rule, as the last part in the URI, e.g. /security/acl/layers/..r

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
def delete_security_access(self, body: Union[str, Dict[str, Any]], *, rule: Optional[str] = None) -> str:
    """Removes one or more REST access rules.

    Args:
        body: The body of the request used to delete the security access.
        rule: Optional. The specified rule, as the last part in the URI, e.g. /security/acl/layers/*.*.r

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/security/acl/rest"
    if rule is not None:
        url = f"{self.service_url}/rest/security/acl/{rule}"

    self._request(method="delete", url=url, body=body)
    return DELETED_MESSAGE

get_settings

get_settings(*, workspace: Optional[str] = None, format: Literal['json'] = 'json') -> Dict[str, Any]
get_settings(*, workspace: Optional[str] = None, format: Literal['xml']) -> str
get_settings(*, workspace: Optional[str] = None, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Displays a list of all global or workspace settings on the server.

Parameters:

Name Type Description Default
workspace Optional[str]

Optional. The name of the workspace.

None
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The settings for the workspace.

Source code in geoserver/geoserver.py
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
def get_settings(
    self, *, workspace: Optional[str] = None, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """Displays a list of all global or workspace settings on the server.

    Args:
        workspace: Optional. The name of the workspace.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The settings for the workspace.
    """
    url = f"{self.service_url}/rest/settings.{format}"
    if workspace is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/settings.{format}"

    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

update_settings

update_settings(body: Union[str, Dict[str, Any]], *, workspace: Optional[str] = None) -> str

Updates global or workspace settings on the server.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to modify the settings.

required
workspace Optional[str]

Optional. The name of the workspace.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
def update_settings(self, body: Union[str, Dict[str, Any]], *, workspace: Optional[str] = None) -> str:
    """Updates global or workspace settings on the server.

    Args:
        body: The body of the request used to modify the settings.
        workspace: Optional. The name of the workspace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/settings"
    if workspace is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/settings"

    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

delete_settings

delete_settings(*, workspace: str) -> str

Deletes workspace settings on the server.

Parameters:

Name Type Description Default
workspace str

Optional. The name of the workspace.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
def delete_settings(self, *, workspace: str) -> str:
    """Deletes workspace settings on the server.

    Args:
        workspace: Optional. The name of the workspace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/settings"
    response = self._request(method="delete", url=url)
    return response.text

get_contact_settings

get_contact_settings(*, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Displays a list of all global contact settings on the server. This is a subset of what is available at the /settings endpoint.

Parameters:

Name Type Description Default
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The contact settings.

Source code in geoserver/geoserver.py
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
def get_contact_settings(self, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Displays a list of all global contact settings on the server.
    This is a subset of what is available at the /settings endpoint.

    Args:
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The contact settings.
    """
    url = f"{self.service_url}/rest/settings/contact.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

update_contact_settings

update_contact_settings() -> str

Updates global contact settings on the server.

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2572
2573
2574
2575
2576
2577
2578
2579
2580
def update_contact_settings(self) -> str:
    """Updates global contact settings on the server.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/settings/contact"
    self._request(method="put", url=url)
    return UPDATED_MESSAGE

get_coverage_granules

get_coverage_granules(name: str, *, workspace: str, store: str, format: Literal['json'] = 'json') -> Dict[str, Any]
get_coverage_granules(name: str, *, workspace: str, store: str, format: Literal['xml']) -> str
get_coverage_granules(name: str, *, workspace: str, store: str, limit: int = -1, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Displays a list of all the attributes associated to a particular coverage's granules

Parameters:

Name Type Description Default
name str

The name of the coverage.

required
workspace str

The name of the workspace containing the coverage stores.

required
store str

The name of the store.

required
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The granules in the structured coverage store.

Source code in geoserver/geoserver.py
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
def get_coverage_granules(
    self, name: str, *, workspace: str, store: str, limit: int = -1, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """Displays a list of all the attributes associated to a particular coverage's granules

    Args:
        name: The name of the coverage.
        workspace: The name of the workspace containing the coverage stores.
        store: The name of the store.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The granules in the structured coverage store.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{store}/coverages/{name}/index/granules.{format}"
    params = dict(limit=limit) if limit >= 0 else {}
    response = self._request(method="get", url=url, params=params)
    return response.json() if format == "json" else response.text

delete_coverage_granules

delete_coverage_granules(name: str, *, workspace: str, store: str, filter: str = '', purge: Literal['none', 'metadata', 'all'] = 'none', update_bbox: bool = False) -> str

Allows removing one or more granules from the index.

Parameters:

Name Type Description Default
name str

The name of the coverage.

required
workspace str

The name of the workspace containing the coverage stores.

required
store str

The name of the store.

required
filter str

Optional. A CQL filter to reduce the returned granules.

''
purge Literal['none', 'metadata', 'all']

Optional. The purge parameter specifies if and how the underlying raster data source is deleted. Allowable values for this parameter are none, metadata and all. When set to none data and auxiliary files are preserved, only the registration in the mosaic is removed When set to metadata delete only auxiliary files and metadata (e.g. NetCDF sidecar indexes). It's recommended when data files (such as granules) should not be deleted from disk. Finally, when set to all both data and auxiliary files are removed.

'none'
update_bbox bool

Optional. When set to True, triggers re-calculation of the layer native bbox. Defaults to False.

False

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
def delete_coverage_granules(
    self,
    name: str,
    *,
    workspace: str,
    store: str,
    filter: str = "",
    purge: Literal["none", "metadata", "all"] = "none",
    update_bbox: bool = False,
) -> str:
    """Allows removing one or more granules from the index.

    Args:
        name: The name of the coverage.
        workspace: The name of the workspace containing the coverage stores.
        store: The name of the store.
        filter: Optional. A CQL filter to reduce the returned granules.
        purge: Optional. The purge parameter specifies if and how the underlying raster data source is deleted.
            Allowable values for this parameter are `none`, `metadata` and `all`. When set to `none` data and auxiliary files are preserved,
            only the registration in the mosaic is removed When set to `metadata` delete only auxiliary files and metadata
            (e.g. NetCDF sidecar indexes). It's recommended when data files (such as granules) should not be deleted from disk.
            Finally, when set to `all` both data and auxiliary files are removed.
        update_bbox: Optional. When set to True, triggers re-calculation of the layer native bbox. Defaults to False.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{store}/coverages/{name}/index/granules"
    params = dict(filter=filter, purge=purge, updateBBox=update_bbox)
    self._request(method="delete", url=url, params=params)
    return DELETED_MESSAGE

get_coverages_granule

get_coverages_granule(name: str, *, workspace: str, store: str, coverage: str, format: Literal['json'] = 'json') -> Dict[str, Any]
get_coverages_granule(name: str, *, workspace: str, store: str, coverage: str, format: Literal['xml']) -> str
get_coverages_granule(name: str, *, workspace: str, store: str, coverage: str, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Displays a list of all the attributes associated to a particular coverage's granule

Parameters:

Name Type Description Default
name str

The ID of the granule.

required
workspace str

The name of the workspace containing the coverage stores.

required
store str

The name of the store.

required
coverage str

The name of the coverage.

required
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The granule in the structured coverage store.

Source code in geoserver/geoserver.py
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
def get_coverages_granule(
    self, name: str, *, workspace: str, store: str, coverage: str, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """Displays a list of all the attributes associated to a particular coverage's granule

    Args:
        name: The ID of the granule.
        workspace: The name of the workspace containing the coverage stores.
        store: The name of the store.
        coverage: The name of the coverage.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The granule in the structured coverage store.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{store}/coverages/{coverage}/granules/index/{name}.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

delete_coverage_granule

delete_coverage_granule(name: str, *, workspace: str, store: str, coverage: str, purge: bool = False, update_bbox: bool = False) -> str

Allows removing the specified granule.

Parameters:

Name Type Description Default
name str

The ID of the granule.

required
workspace str

The name of the workspace containing the coverage stores.

required
store str

The name of the store.

required
coverage str

The name of the coverage.

required
purge bool

Optional. The purge parameter specifies if and how the underlying raster data source is deleted. Allowable values for this parameter are none, metadata and all. When set to none data and auxiliary files are preserved, only the registration in the mosaic is removed When set to metadata delete only auxiliary files and metadata (e.g. NetCDF sidecar indexes). It's recommended when data files (such as granules) should not be deleted from disk. Finally, when set to all both data and auxiliary files are removed.

False
update_bbox bool

Optional. When set to True, triggers re-calculation of the layer native bbox. Defaults to False.

False

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
def delete_coverage_granule(
    self, name: str, *, workspace: str, store: str, coverage: str, purge: bool = False, update_bbox: bool = False
) -> str:
    """Allows removing the specified granule.

    Args:
        name: The ID of the granule.
        workspace: The name of the workspace containing the coverage stores.
        store: The name of the store.
        coverage: The name of the coverage.
        purge: Optional. The purge parameter specifies if and how the underlying raster data source is deleted.
            Allowable values for this parameter are `none`, `metadata` and `all`. When set to `none` data and auxiliary files are preserved,
            only the registration in the mosaic is removed When set to `metadata` delete only auxiliary files and metadata
            (e.g. NetCDF sidecar indexes). It's recommended when data files (such as granules) should not be deleted from disk.
            Finally, when set to `all` both data and auxiliary files are removed.
        update_bbox: Optional. When set to True, triggers re-calculation of the layer native bbox. Defaults to False.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{store}/coverages/{coverage}/granules/index/{name}"
    params = dict(purge=purge, updateBBox=update_bbox)
    self._request(method="delete", url=url, params=params)
    return DELETED_MESSAGE

get_styles

get_styles(*, workspace: Optional[str] = None, format: Literal['json'] = 'json') -> Dict[str, Any]
get_styles(*, workspace: Optional[str] = None, format: Literal['xml']) -> str
get_styles(*, workspace: Optional[str] = None, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Displays a list of all styles on the server.

Parameters:

Name Type Description Default
workspace Optional[str]

Optional. The name of the workspace.

None
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The styles.

Source code in geoserver/geoserver.py
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
def get_styles(
    self, *, workspace: Optional[str] = None, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """Displays a list of all styles on the server.

    Args:
        workspace: Optional. The name of the workspace.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The styles.
    """
    url = f"{self.service_url}/rest/styles.{format}"
    if workspace is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/styles.{format}"

    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

style_exists

style_exists(name: str, *, workspace: Optional[str] = None) -> bool

Check if a style exists.

Parameters:

Name Type Description Default
name str

The name of the style.

required
workspace Optional[str]

Optional. The name of the workspace.

None

Returns:

Type Description
bool

Success message.

Source code in geoserver/geoserver.py
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
def style_exists(self, name: str, *, workspace: Optional[str] = None) -> bool:
    """Check if a style exists.

    Args:
        name: The name of the style.
        workspace: Optional. The name of the workspace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/styles/{name}.xml"
    if workspace is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/styles/{name}.xml"

    response = self._request(method="head", url=url, ignore=[404])
    return response.status_code == 200

get_style

get_style(name: str, *, workspace: Optional[str] = None, format: Literal['json'] = 'json') -> Dict[str, Any]
get_style(name: str, *, workspace: Optional[str] = None, format: Literal['xml']) -> str
get_style(name: str, *, workspace: Optional[str] = None, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Retrieves a single style.

Parameters:

Name Type Description Default
name str

The name of the style.

required
workspace Optional[str]

Optional. The name of the workspace.

None
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

Success message.

Source code in geoserver/geoserver.py
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
def get_style(
    self, name: str, *, workspace: Optional[str] = None, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """Retrieves a single style.

    Args:
        name: The name of the style.
        workspace: Optional. The name of the workspace.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/styles/{name}.{format}"
    if workspace is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/styles/{name}.{format}"

    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

create_style

create_style(body: str, *, workspace: Optional[str] = None) -> str

Creates a new style.

Warning

This method only supports body in XML format.

Parameters:

Name Type Description Default
body str

The body of the request used to create the style.

required
workspace Optional[str]

Optional. The name of the workspace.

None

Returns:

Type Description
str

Success message.

Example
geoserver.create_style(body="<sld>...</sld>")
Source code in geoserver/geoserver.py
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
def create_style(self, body: str, *, workspace: Optional[str] = None) -> str:
    """Creates a new style.

    Warning:
        This method only supports body in XML format.

    Args:
        body: The body of the request used to create the style.
        workspace: Optional. The name of the workspace.

    Returns:
        Success message.

    Example:
        ```python
        geoserver.create_style(body="<sld>...</sld>")
        ```
    """
    url = f"{self.service_url}/rest/styles"
    if workspace is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/styles"

    self._request(method="post", url=url, body=body)
    return CREATED_MESSAGE

upload_style

upload_style(file: Union[str, Path, BufferedReader], *, name: str, workspace: Optional[str] = None, overwrite: Literal[True]) -> str
upload_style(file: Union[str, Path, BufferedReader], *, name: Optional[str] = None, workspace: Optional[str] = None, overwrite: Literal[False] = False) -> str
upload_style(file: Union[str, Path, BufferedReader], *, name: Optional[str] = None, workspace: Optional[str] = None, overwrite: bool = False) -> str

Uploads a style.

Note

The name parameter must be provided if the file argument is not a file path.

Note

If overwriting a style, you must provide the style name.

Parameters:

Name Type Description Default
file Union[str, Path, BufferedReader]

The path to the file to upload.

required
name Optional[str]

Optional. The name of the style. If not provided, it will be inferred from the filename.

None
workspace Optional[str]

Optional. The name of the workspace.

None
overwrite bool

Optional. Whether to overwrite the style if it already exists. Defaults to False.

False

Returns:

Type Description
str

Success message.

Example

To upload a style from a local SLD file:

file_path = "path/to/my_style.sld" # Or "path/to/my_style.zip"
geoserver.upload_style(file=file_path, workspace="demo")

# Open the file yourself
with open(file_path, "rb") as f:
    geoserver.upload_style(file=f, workspace="demo")

To overwrite an existing style with a new SLD file (or ZIP file):

file_path = "path/to/my_style.sld" # Or "path/to/my_style.zip"
geoserver.upload_style(file=file_path, style="my_style", workspace="demo", overwrite=True)

# Open the file yourself
with open(file_path, "rb") as f:
    geoserver.upload_style(file=f, style="my_style", workspace="demo", overwrite=True)
Source code in geoserver/geoserver.py
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
def upload_style(
    self,
    file: Union[str, Path, BufferedReader],
    *,
    name: Optional[str] = None,
    workspace: Optional[str] = None,
    overwrite: bool = False,
) -> str:
    """Uploads a style.

    Note:
        The `name` parameter must be provided if the `file` argument is not a file path.

    Note:
        If overwriting a style, you must provide the `style` name.

    Args:
        file: The path to the file to upload.
        name: Optional. The name of the style. If not provided, it will be inferred from the filename.
        workspace: Optional. The name of the workspace.
        overwrite: Optional. Whether to overwrite the style if it already exists. Defaults to False.

    Returns:
        Success message.

    Example:
        To upload a style from a local SLD file:

        ```python
        file_path = "path/to/my_style.sld" # Or "path/to/my_style.zip"
        geoserver.upload_style(file=file_path, workspace="demo")

        # Open the file yourself
        with open(file_path, "rb") as f:
            geoserver.upload_style(file=f, workspace="demo")
        ```

        To overwrite an existing style with a new SLD file (or ZIP file):

        ```python
        file_path = "path/to/my_style.sld" # Or "path/to/my_style.zip"
        geoserver.upload_style(file=file_path, style="my_style", workspace="demo", overwrite=True)

        # Open the file yourself
        with open(file_path, "rb") as f:
            geoserver.upload_style(file=f, style="my_style", workspace="demo", overwrite=True)
        ```

    """
    method: Literal["post", "put"] = "put" if overwrite else "post"
    if overwrite and name is None:
        raise ValueError("The `style` argument must be provided when overwrite is `True`")

    # Upload from a zip file
    if zipfile.is_zipfile(file):
        headers = {"Content-Type": "application/zip"}
        url = f"{self.service_url}/rest/styles"
        if overwrite:
            url = f"{self.service_url}/rest/styles/{name}.zip"

        _ = self._request(method=method, url=url, file=file, headers=headers)
        return CREATED_MESSAGE

    # Upload from a single SLD file
    if name is None and isinstance(file, (str, Path)):
        name = Path(file).stem
    if name is None:
        raise ValueError("The `style` name must be provided, either as an argument or as the filename.")

    if not overwrite:
        body = f"<style><name>{name}</name><filename>{name}.sld</filename></style>"
        _ = self.create_style(body=body, workspace=workspace)

    body = file.read().decode("utf-8") if isinstance(file, BufferedReader) else Path(file).read_text()
    _ = self.update_style(name=name, body=body, workspace=workspace)
    return CREATED_MESSAGE

update_style

update_style(name: str, body: str, *, workspace: Optional[str] = None) -> str

Updates a single style.

Warning

This method only supports body in XML format.

Parameters:

Name Type Description Default
name str

The name of the style.

required
body str

The content of the updated style, in XML format.

required
workspace Optional[str]

Optional. The name of the workspace.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
def update_style(self, name: str, body: str, *, workspace: Optional[str] = None) -> str:
    """Updates a single style.

    Warning:
        This method only supports body in XML format.

    Args:
        name: The name of the style.
        body: The content of the updated style, in XML format.
        workspace: Optional. The name of the workspace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/styles/{name}"
    if workspace is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/styles/{name}"

    # Automatically determine the content type based on the SLD version
    pattern = r'StyledLayerDescriptor[^>]*version="([^"]*)"'
    match = re.search(pattern, body)
    if not match:
        raise ValueError("The SLD version could not be determined.")

    sld_version = match.group(1)

    content_type = "application/vnd.ogc.sld+xml"
    if sld_version == "1.1.0" or sld_version == "1.1":
        content_type = "application/vnd.ogc.se+xml"

    self._request(method="put", url=url, body=body, headers={"Content-Type": content_type})
    return UPDATED_MESSAGE

download_style

download_style(name: str, *, workspace: Optional[str] = None) -> str

Downloads a single style.

Parameters:

Name Type Description Default
name str

The name of the style.

required
workspace Optional[str]

Optional. The name of the workspace.

None

Returns:

Type Description
str

The style content.

Source code in geoserver/geoserver.py
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
def download_style(self, name: str, *, workspace: Optional[str] = None) -> str:
    """Downloads a single style.

    Args:
        name: The name of the style.
        workspace: Optional. The name of the workspace.

    Returns:
        The style content.
    """
    url = f"{self.service_url}/rest/styles/{name}.sld"
    if workspace is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/styles/{name}.sld"

    response = self._request(method="get", url=url)
    return response.text

publish_style

publish_style(layer: str, style: str, *, workspace: Optional[str] = None) -> str

Publishes a style to a layer. This is equivalent to setting the default style for a layer, which will apply the style to the layer when it is rendered.

Note

This method is equivalent to updating the layer with the default style.

Parameters:

Name Type Description Default
layer str

The name of the layer.

required
style str

The name of the style.

required
workspace Optional[str]

Optional. The name of the workspace.

None

Returns:

Type Description
str

Success message.

Example

First, make sure the layer and style exist. Then, publish the style to the layer:

geoserver.publish_style(layer="my_layer", style="my_style", workspace="demo")
Source code in geoserver/geoserver.py
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
def publish_style(self, layer: str, style: str, *, workspace: Optional[str] = None) -> str:
    """Publishes a style to a layer. This is equivalent to setting the default style for a layer,
    which will apply the style to the layer when it is rendered.

    Note:
        This method is equivalent to updating the layer with the default style.

    Args:
        layer: The name of the layer.
        style: The name of the style.
        workspace: Optional. The name of the workspace.

    Returns:
        Success message.

    Example:
        First, make sure the layer and style exist.
        Then, publish the style to the layer:

        ```python
        geoserver.publish_style(layer="my_layer", style="my_style", workspace="demo")
        ```

    """
    url = f"{self.service_url}/rest/layers/{layer}"
    if workspace is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/layers/{layer}"

    body = f"<layer><defaultStyle><name>{style}</name></defaultStyle></layer>"
    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

delete_style

delete_style(name: str, *, workspace: Optional[str] = None, purge: bool = False, recurse: bool = False) -> str

Deletes a single style.

Parameters:

Name Type Description Default
name str

The name of the style.

required
workspace Optional[str]

Optional. The name of the workspace.

None
purge bool

Optional. Whether to purge the style from the catalog. Defaults to False.

False
recurse bool

Optional. Whether to delete references to the style. Defaults to False.

False

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
def delete_style(
    self, name: str, *, workspace: Optional[str] = None, purge: bool = False, recurse: bool = False
) -> str:
    """Deletes a single style.

    Args:
        name: The name of the style.
        workspace: Optional. The name of the workspace.
        purge: Optional. Whether to purge the style from the catalog. Defaults to False.
        recurse: Optional. Whether to delete references to the style. Defaults to False.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/styles/{name}"
    if workspace is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/styles/{name}"

    params = dict(purge=purge, recurse=recurse)
    self._request(method="delete", url=url, params=params)
    return DELETED_MESSAGE

get_templates

get_templates(*, workspace: Optional[str] = None, store: Optional[str] = None, format: Literal['json'] = 'json') -> Dict[str, Any]
get_templates(*, workspace: Optional[str] = None, store: Optional[str] = None, format: Literal['xml']) -> str
get_templates(*, workspace: Optional[str] = None, store: Optional[str] = None, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Displays a list of all templates on the server.

Parameters:

Name Type Description Default
workspace Optional[str]

Optional. The name of the workspace.

None
store Optional[str]

Optional. The name of the store.

None
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The templates.

Source code in geoserver/geoserver.py
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
def get_templates(
    self, *, workspace: Optional[str] = None, store: Optional[str] = None, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """Displays a list of all templates on the server.

    Args:
        workspace: Optional. The name of the workspace.
        store: Optional. The name of the store.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The templates.
    """
    if workspace is None and store is None:
        url = f"{self.service_url}/rest/templates.{format}"
    elif workspace is not None and store is None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/templates.{format}"
    elif workspace is not None and store is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/datastores/{store}/templates.{format}"
    else:
        raise ValueError("A workspace must be provided if a store is provided.")

    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

get_template

get_template(name: str, *, workspace: Optional[str] = None, data_store: Optional[str] = None, feature_type: Optional[str] = None, coverage_store: Optional[str] = None, coverage: Optional[str] = None) -> str

Displays a list of all templates on the server.

Parameters:

Name Type Description Default
name str

The name of the template.

required
workspace Optional[str]

Optional. The name of the workspace.

None
data_store Optional[str]

Optional. The name of the datastore.

None
feature_type Optional[str]

Optional. The name of the featuretype.

None
coverage_store Optional[str]

Optional. The name of the coveragestore.

None
coverage Optional[str]

Optional. The name of the coverage.

None

Returns:

Type Description
str

The templates.

Source code in geoserver/geoserver.py
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
def get_template(
    self,
    name: str,
    *,
    workspace: Optional[str] = None,
    data_store: Optional[str] = None,
    feature_type: Optional[str] = None,
    coverage_store: Optional[str] = None,
    coverage: Optional[str] = None,
) -> str:
    """Displays a list of all templates on the server.

    Args:
        name: The name of the template.
        workspace: Optional. The name of the workspace.
        data_store: Optional. The name of the datastore.
        feature_type: Optional. The name of the featuretype.
        coverage_store: Optional. The name of the coveragestore.
        coverage: Optional. The name of the coverage.

    Returns:
        The templates.
    """
    if (
        workspace is None
        and data_store is None
        and feature_type is None
        and coverage_store is None
        and coverage is None
    ):
        url = f"{self.service_url}/rest/templates/{name}.ftl"
    if (
        workspace is not None
        and data_store is None
        and feature_type is None
        and coverage_store is None
        and coverage is None
    ):
        url = f"{self.service_url}/rest/workspaces/{workspace}/templates/{name}.ftl"
    elif (
        workspace is not None
        and data_store is not None
        and feature_type is None
        and coverage_store is None
        and coverage is None
    ):
        url = f"{self.service_url}/rest/workspaces/{workspace}/datastores/{data_store}/templates/{name}.ftl"
    elif (
        workspace is not None
        and data_store is not None
        and feature_type is not None
        and coverage_store is None
        and coverage is None
    ):
        url = f"{self.service_url}/rest/workspaces/{workspace}/datastores/{data_store}/featuretypes/{feature_type}/templates/{name}.ftl"
    elif (
        workspace is not None
        and data_store is None
        and feature_type is None
        and coverage_store is not None
        and coverage is None
    ):
        url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{coverage_store}/templates/{name}.ftl"
    elif (
        workspace is not None
        and data_store is None
        and feature_type is None
        and coverage_store is not None
        and coverage is not None
    ):
        url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{coverage_store}/coverages/{coverage}/templates/{name}.ftl"
    else:
        raise ValueError(
            f"Invalid combinations of workspace, store, and featuretype. Got {workspace}, {data_store}, and {feature_type}."
        )

    response = self._request(method="get", url=url)
    return response.json()

create_template

create_template(name: str, body: str, *, workspace: Optional[str] = None, data_store: Optional[str] = None, feature_type: Optional[str] = None, coverage_store: Optional[str] = None, coverage: Optional[str] = None) -> str

Inserts or updates a single template registered for use in a workspace (example for GetFeatureInfo WMS operation). Overwrites any existing template with the same name and location.

Parameters:

Name Type Description Default
name str

The name of the template.

required
body str

The body of the request used to modify the template.

required
workspace Optional[str]

Optional. The name of the workspace.

None
data_store Optional[str]

Optional. The name of the datastore.

None
feature_type Optional[str]

Optional. The name of the featuretype.

None
coverage_store Optional[str]

Optional. The name of the coveragestore.

None
coverage Optional[str]

Optional. The name of the coverage.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
def create_template(
    self,
    name: str,
    body: str,
    *,
    workspace: Optional[str] = None,
    data_store: Optional[str] = None,
    feature_type: Optional[str] = None,
    coverage_store: Optional[str] = None,
    coverage: Optional[str] = None,
) -> str:
    """Inserts or updates a single template registered for use in a workspace (example for GetFeatureInfo WMS operation).
    Overwrites any existing template with the same name and location.

    Args:
        name: The name of the template.
        body: The body of the request used to modify the template.
        workspace: Optional. The name of the workspace.
        data_store: Optional. The name of the datastore.
        feature_type: Optional. The name of the featuretype.
        coverage_store: Optional. The name of the coveragestore.
        coverage: Optional. The name of the coverage.

    Returns:
        Success message.
    """
    if (
        workspace is None
        and data_store is None
        and feature_type is None
        and coverage_store is None
        and coverage is None
    ):
        url = f"{self.service_url}/rest/templates/{name}.ftl"
    if (
        workspace is not None
        and data_store is None
        and feature_type is None
        and coverage_store is None
        and coverage is None
    ):
        url = f"{self.service_url}/rest/workspaces/{workspace}/templates/{name}.ftl"
    elif (
        workspace is not None
        and data_store is not None
        and feature_type is None
        and coverage_store is None
        and coverage is None
    ):
        url = f"{self.service_url}/rest/workspaces/{workspace}/datastores/{data_store}/templates/{name}.ftl"
    elif (
        workspace is not None
        and data_store is not None
        and feature_type is not None
        and coverage_store is None
        and coverage is None
    ):
        url = f"{self.service_url}/rest/workspaces/{workspace}/datastores/{data_store}/featuretypes/{feature_type}/templates/{name}.ftl"
    elif (
        workspace is not None
        and data_store is None
        and feature_type is None
        and coverage_store is not None
        and coverage is None
    ):
        url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{coverage_store}/templates/{name}.ftl"
    elif (
        workspace is not None
        and data_store is None
        and feature_type is None
        and coverage_store is not None
        and coverage is not None
    ):
        url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{coverage_store}/coverages/{coverage}/templates/{name}.ftl"
    else:
        raise ValueError(
            f"Invalid combinations of workspace, store, and featuretype. Got {workspace}, {data_store}, and {feature_type}."
        )

    headers = {"Content-Type": "text/plain"}
    self._request(method="put", url=url, body=body, headers=headers)
    return CREATED_MESSAGE

delete_template

delete_template(name: str, *, workspace: Optional[str] = None, data_store: Optional[str] = None, feature_type: Optional[str] = None, coverage_store: Optional[str] = None, coverage: Optional[str] = None) -> str

Deletes a single template registered for use on the server.

Parameters:

Name Type Description Default
name str

The name of the template.

required
workspace Optional[str]

Optional. The name of the workspace.

None
data_store Optional[str]

Optional. The name of the datastore.

None
feature_type Optional[str]

Optional. The name of the featuretype.

None
coverage_store Optional[str]

Optional. The name of the coveragestore.

None
coverage Optional[str]

Optional. The name of the coverage.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
def delete_template(
    self,
    name: str,
    *,
    workspace: Optional[str] = None,
    data_store: Optional[str] = None,
    feature_type: Optional[str] = None,
    coverage_store: Optional[str] = None,
    coverage: Optional[str] = None,
) -> str:
    """Deletes a single template registered for use on the server.

    Args:
        name: The name of the template.
        workspace: Optional. The name of the workspace.
        data_store: Optional. The name of the datastore.
        feature_type: Optional. The name of the featuretype.
        coverage_store: Optional. The name of the coveragestore.
        coverage: Optional. The name of the coverage.

    Returns:
        Success message.
    """
    if (
        workspace is None
        and data_store is None
        and feature_type is None
        and coverage_store is None
        and coverage is None
    ):
        url = f"{self.service_url}/rest/templates/{name}.ftl"
    if (
        workspace is not None
        and data_store is None
        and feature_type is None
        and coverage_store is None
        and coverage is None
    ):
        url = f"{self.service_url}/rest/workspaces/{workspace}/templates/{name}.ftl"
    elif (
        workspace is not None
        and data_store is not None
        and feature_type is None
        and coverage_store is None
        and coverage is None
    ):
        url = f"{self.service_url}/rest/workspaces/{workspace}/datastores/{data_store}/templates/{name}.ftl"
    elif (
        workspace is not None
        and data_store is not None
        and feature_type is not None
        and coverage_store is None
        and coverage is None
    ):
        url = f"{self.service_url}/rest/workspaces/{workspace}/datastores/{data_store}/featuretypes/{feature_type}/templates/{name}.ftl"
    elif (
        workspace is not None
        and data_store is None
        and feature_type is None
        and coverage_store is not None
        and coverage is None
    ):
        url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{coverage_store}/templates/{name}.ftl"
    elif (
        workspace is not None
        and data_store is None
        and feature_type is None
        and coverage_store is not None
        and coverage is not None
    ):
        url = f"{self.service_url}/rest/workspaces/{workspace}/coveragestores/{coverage_store}/coverages/{coverage}/templates/{name}.ftl"
    else:
        raise ValueError(
            f"Invalid combinations of workspace, store, and featuretype. Got {workspace}, {data_store}, and {feature_type}."
        )

    self._request(method="delete", url=url)
    return DELETED_MESSAGE

get_wfs_transforms

get_wfs_transforms(*, format: Literal['json'] = 'json') -> Dict[str, Any]
get_wfs_transforms(*, format: Literal['xml']) -> str
get_wfs_transforms(*, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Displays a list of all the transforms information available on the server.

Parameters:

Name Type Description Default
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The XSLT transforms.

Example

To get the list of all the transforms available on the server, you can use the following code:

geoserver.get_transforms()
Source code in geoserver/geoserver.py
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
def get_wfs_transforms(self, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Displays a list of all the transforms information available on the server.

    Args:
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The XSLT transforms.

    Example:
        To get the list of all the transforms available on the server, you can use the following code:

        ```python
        geoserver.get_transforms()
        ```
    """
    url = f"{self.service_url}/rest/services/wfs/transforms.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

create_wfs_transform

create_wfs_transform(body: Union[str, Dict[str, Any]], *, source_format: Optional[str] = None, output_format: Optional[str] = None, output_mime_type: Optional[str] = None, file_extension: Optional[str] = None) -> str

Adds a new transform to the server. If the content type used is application/xml the server will assume a definition is being posted, and the XSLT will have to be uploaded separately using a PUT request with content type application/xslt+xml against the transformation resource. If the content type used is application/xslt+xml the server will assume the XSLT itself is being posted, and the name, sourceFormat, outputFormat, outputMimeType query parameters will be used to fill in the transform configuration instead.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to create the transform.

required

Returns:

Type Description
str

Success message.

Example

To add a new transform to the server, you can use the following code:

body = """
<transform>
    <name>test</name>
    <sourceFormat>GML2</sourceFormat>
    <outputFormat>text/xml</outputFormat>
    <outputMimeType>text/xml</outputMimeType>
    <fileExtension>xml</fileExtension>
</transform>
"""

geoserver.create_transform(body)
Source code in geoserver/geoserver.py
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
def create_wfs_transform(
    self,
    body: Union[str, Dict[str, Any]],
    *,
    source_format: Optional[str] = None,
    output_format: Optional[str] = None,
    output_mime_type: Optional[str] = None,
    file_extension: Optional[str] = None,
) -> str:
    """Adds a new transform to the server.
    If the content type used is application/xml the server will assume a definition is being posted,
    and the XSLT will have to be uploaded separately using a PUT request with content type application/xslt+xml against the transformation resource.
    If the content type used is application/xslt+xml the server will assume the XSLT itself is being posted,
    and the name, sourceFormat, outputFormat, outputMimeType query parameters will be used to fill in the transform configuration instead.

    Args:
        body: The body of the request used to create the transform.

    Returns:
        Success message.

    Example:
        To add a new transform to the server, you can use the following code:

        ```python
        body = \"\"\"
        <transform>
            <name>test</name>
            <sourceFormat>GML2</sourceFormat>
            <outputFormat>text/xml</outputFormat>
            <outputMimeType>text/xml</outputMimeType>
            <fileExtension>xml</fileExtension>
        </transform>
        \"\"\"

        geoserver.create_transform(body)
        ```
    """
    url = f"{self.service_url}/rest/services/wfs/transforms"
    params = dict(
        sourceFormat=source_format,
        outputFormat=output_format,
        outputMimeType=output_mime_type,
        fileExtension=file_extension,
    )
    self._request(method="post", url=url, body=body, params=params)
    return CREATED_MESSAGE

get_wfs_transform

get_wfs_transform(name: str, *, format: Literal['json'] = 'json') -> Dict[str, Any]
get_wfs_transform(name: str, *, format: Literal['xml']) -> str
get_wfs_transform(name: str, *, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Retrieves a single transformation.

Parameters:

Name Type Description Default
name str

The name of the transform.

required
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The transform.

Example

To get a single transformation, you can use the following code:

geoserver.get_transform(transform="test1")
Source code in geoserver/geoserver.py
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
def get_wfs_transform(self, name: str, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Retrieves a single transformation.

    Args:
        name: The name of the transform.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The transform.

    Example:
        To get a single transformation, you can use the following code:

        ```python
        geoserver.get_transform(transform="test1")
        ```
    """
    url = f"{self.service_url}/rest/services/wfs/transforms/{name}.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

update_wfs_transform

update_wfs_transform(name: str, body: Union[str, Dict[str, Any]]) -> str

Modifies a single transform.

Parameters:

Name Type Description Default
name str

The name of the transform.

required
body Union[str, Dict[str, Any]]

The body of the request used to modify the transform.

required

Returns:

Type Description
str

Success message.

Example

To update a single transformation, you can use the following code:

body = """
<transform>
    <name>test1</name>
    <sourceFormat>text/xml; subtype=gml/2.1.2</sourceFormat>
    <outputFormat>text/html</outputFormat>
    <xslt>test1.xslt</xslt>
</transform>
"""

geoserver.update_transform(transform="test1", body=body)
Source code in geoserver/geoserver.py
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
def update_wfs_transform(self, name: str, body: Union[str, Dict[str, Any]]) -> str:
    """Modifies a single transform.

    Args:
        name: The name of the transform.
        body: The body of the request used to modify the transform.

    Returns:
        Success message.

    Example:
        To update a single transformation, you can use the following code:

        ```python
        body = \"\"\"
        <transform>
            <name>test1</name>
            <sourceFormat>text/xml; subtype=gml/2.1.2</sourceFormat>
            <outputFormat>text/html</outputFormat>
            <xslt>test1.xslt</xslt>
        </transform>
        \"\"\"

        geoserver.update_transform(transform="test1", body=body)
        ```
    """
    url = f"{self.service_url}/rest/services/wfs/transforms/{name}"
    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

delete_wfs_transform

delete_wfs_transform(name: str) -> str

Deletes a single transform.

Parameters:

Name Type Description Default
name str

The name of the transform.

required

Returns:

Type Description
str

Success message.

Example

To remove a single transformation, you can use the following code:

geoserver.delete_transform(transform="test1")
Source code in geoserver/geoserver.py
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
def delete_wfs_transform(self, name: str) -> str:
    """Deletes a single transform.

    Args:
        name: The name of the transform.

    Returns:
        Success message.

    Example:
        To remove a single transformation, you can use the following code:

        ```python
        geoserver.delete_transform(transform="test1")
        ```
    """
    url = f"{self.service_url}/rest/services/wfs/transforms/{name}"
    self._request(method="delete", url=url)
    return DELETED_MESSAGE

get_wms_layers

get_wms_layers(*, workspace: str, store: Optional[str] = None, list: Optional[Literal['available']] = None, format: Literal['json'] = 'json') -> Dict[str, Any]
get_wms_layers(*, workspace: str, store: Optional[str] = None, list: Optional[Literal['available']] = None, format: Literal['xml']) -> str
get_wms_layers(*, workspace: str, store: Optional[str] = None, list: Optional[Literal['available']] = None, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Retrieves the WMS layers available on the server.

Parameters:

Name Type Description Default
workspace str

The name of the workspace.

required
store Optional[str]

Optional. Name of the wms store.

None
list Optional[Literal['available']]

Optional. Set list=available to see all possible layers in the store, not just ones currently published.

None
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The WMS layers.

Source code in geoserver/geoserver.py
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
def get_wms_layers(
    self,
    *,
    workspace: str,
    store: Optional[str] = None,
    list: Optional[Literal["available"]] = None,
    format: Literal["json", "xml"] = "json",
) -> Union[str, Dict[str, Any]]:
    """Retrieves the WMS layers available on the server.

    Args:
        workspace: The name of the workspace.
        store: Optional. Name of the wms store.
        list: Optional. Set `list=available` to see all possible layers in the store, not just ones currently published.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The WMS layers.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/wmslayers.{format}"
    if store is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/wmsstores/{store}/wmslayers.{format}"

    params = dict(list=list)
    response = self._request(method="get", url=url, params=params)
    return response.json() if format == "json" else response.text

create_wms_layer

create_wms_layer(body: Union[str, Dict[str, Any]], *, workspace: str, store: Optional[str] = None) -> str

Creates a new WMS layer.

Parameters:

Name Type Description Default
workspace str

The name of the workspace.

required
body Union[str, Dict[str, Any]]

The body of the request used to create the WMS layer.

required
store Optional[str]

Optional. Name of the wms store.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
def create_wms_layer(self, body: Union[str, Dict[str, Any]], *, workspace: str, store: Optional[str] = None) -> str:
    """Creates a new WMS layer.

    Args:
        workspace: The name of the workspace.
        body: The body of the request used to create the WMS layer.
        store: Optional. Name of the wms store.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/wmslayers"
    if store is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/wmsstores/{store}/wmslayers"

    self._request(method="post", url=url, body=body)
    return CREATED_MESSAGE

get_wms_layer

get_wms_layer(name: str, *, workspace: str, store: Optional[str] = None, quiet_on_not_found: bool = False, format: Literal['json'] = 'json') -> Dict[str, Any]
get_wms_layer(name: str, *, workspace: str, store: Optional[str] = None, quiet_on_not_found: bool = False, format: Literal['xml']) -> str
get_wms_layer(name: str, *, workspace: str, store: Optional[str] = None, quiet_on_not_found: bool = False, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Retrieves a single WMS layer.

Parameters:

Name Type Description Default
name str

The name of the wms layer.

required
workspace str

The name of the workspace.

required
store Optional[str]

Optional. Name of the wms store.

None
quiet_on_not_found bool

Optional. When set to "true", will not log an exception when the style is not present. The 404 status code will still be returned.

False
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The WMS layer.

Source code in geoserver/geoserver.py
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
def get_wms_layer(
    self,
    name: str,
    *,
    workspace: str,
    store: Optional[str] = None,
    quiet_on_not_found: bool = False,
    format: Literal["json", "xml"] = "json",
) -> Union[str, Dict[str, Any]]:
    """Retrieves a single WMS layer.

    Args:
        name: The name of the wms layer.
        workspace: The name of the workspace.
        store: Optional. Name of the wms store.
        quiet_on_not_found: Optional. When set to "true", will not log an exception when the style is not present.
            The 404 status code will still be returned.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The WMS layer.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/wmslayers/{name}.{format}"
    if store is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/wmsstores/{store}/wmslayers/{name}.{format}"

    params = dict(quietOnNotFound=quiet_on_not_found)
    response = self._request(method="get", url=url, params=params)
    return response.json() if format == "json" else response.text

update_wms_layer

update_wms_layer(name: str, body: Union[str, Dict[str, Any]], *, workspace: str, store: Optional[str] = None, calculate: Optional[List[str]] = None) -> str

Modifies a single WMS layer.

Parameters:

Name Type Description Default
name str

The name of the layer.

required
body Union[str, Dict[str, Any]]

The body of the request used to modify the WMS layer.

required
workspace str

The name of the workspace.

required
calculate Optional[List[str]]

Specifies whether to recalculate any bounding boxes for a wms layer. Some properties are automatically recalculated when necessary. In particular, the native bounding box is recalculated when the projection or projection policy are changed, and the lat/lon bounding box is recalculated when the native bounding box is recalculated, or when a new native bounding box is explicitly provided in the request. (The native and lat/lon bounding boxes are not automatically recalculated when they are explicitly included in the request.) In addition, the client may explicitly request a fixed set of fields to calculate, by including a comma-separated list of their names in the recalculate parameter. The empty parameter "recalculate=" is useful avoid slow recalculation when operating against large datasets as "recalculate=" avoids calculating any fields, regardless of any changes to projection, projection policy, etc. The nativebbox parameter "recalculate=nativebbox" is used recalculates the native bounding box, while avoiding recalculating the lat/lon bounding box. Recalculate parameters can be used in together - "recalculate=nativebbox,latlonbbox" can be used after a bulk import to recalculates both the native bounding box and the lat/lon bounding box.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
def update_wms_layer(
    self,
    name: str,
    body: Union[str, Dict[str, Any]],
    *,
    workspace: str,
    store: Optional[str] = None,
    calculate: Optional[List[str]] = None,
) -> str:
    """Modifies a single WMS layer.

    Args:
        name: The name of the layer.
        body: The body of the request used to modify the WMS layer.
        workspace: The name of the workspace.
        calculate: Specifies whether to recalculate any bounding boxes for a wms layer.
            Some properties are automatically recalculated when necessary.
            In particular, the native bounding box is recalculated when the projection or projection policy are changed,
            and the lat/lon bounding box is recalculated when the native bounding box is recalculated,
            or when a new native bounding box is explicitly provided in the request.
            (The native and lat/lon bounding boxes are not automatically recalculated when they are explicitly included in the request.)
            In addition, the client may explicitly request a fixed set of fields to calculate,
            by including a comma-separated list of their names in the recalculate parameter.
            The empty parameter "recalculate=" is useful avoid slow recalculation when operating against large datasets
            as "recalculate=" avoids calculating any fields, regardless of any changes to projection, projection policy, etc.
            The nativebbox parameter "recalculate=nativebbox" is used recalculates the native bounding box,
            while avoiding recalculating the lat/lon bounding box. Recalculate parameters can be used in together -
            "recalculate=nativebbox,latlonbbox" can be used after a bulk import to
            recalculates both the native bounding box and the lat/lon bounding box.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/wmslayers/{name}"
    if store is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/wmsstores/{store}/wmslayers/{name}"

    params = dict(calculate=calculate)
    self._request(method="put", url=url, body=body, params=params)
    return UPDATED_MESSAGE

delete_wms_layer

delete_wms_layer(name: str, *, workspace: str, store: Optional[str] = None, recurse: bool = False) -> str

Deletes a single WMS layer.

Parameters:

Name Type Description Default
name str

The name of the layer.

required
workspace str

The name of the workspace.

required
recurse bool

Recursively deletes all layers referenced by the specified wmslayer. A request with recurse=false will fail if any layers reference the wmslayer.

False

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
def delete_wms_layer(self, name: str, *, workspace: str, store: Optional[str] = None, recurse: bool = False) -> str:
    """Deletes a single WMS layer.

    Args:
        name: The name of the layer.
        workspace: The name of the workspace.
        recurse: Recursively deletes all layers referenced by the specified wmslayer.
            A request with `recurse=false` will fail if any layers reference the wmslayer.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/wmslayers/{name}"
    if store is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/wmsstores/{store}/wmslayers/{name}"

    params = dict(recurse=recurse)
    self._request(method="delete", url=url, params=params)
    return DELETED_MESSAGE

get_wms_stores

get_wms_stores(*, workspace: str, format: Literal['json'] = 'json') -> Dict[str, Any]
get_wms_stores(*, workspace: str, format: Literal['xml']) -> str
get_wms_stores(*, workspace: str, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Retrieves the WMS stores available on the server.

Parameters:

Name Type Description Default
workspace str

The name of the workspace.

required
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The WMS stores.

Source code in geoserver/geoserver.py
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
def get_wms_stores(self, *, workspace: str, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Retrieves the WMS stores available on the server.

    Args:
        workspace: The name of the workspace.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The WMS stores.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/wmsstores.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

create_wms_store

create_wms_store(body: Union[str, Dict[str, Any]], *, workspace: str) -> str

Creates a new WMS store.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to create the WMS store.

required
workspace str

The name of the workspace.

required

Returns:

Type Description
str

Success message.

Example

To add a new WMS store to the server, you can use the following code:

body = """
<wmsStore>
    <name>remote</name>
    <capabilitiesUrl>http://demo.geoserver.org/geoserver/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities</capabilitiesUrl>
</wmsStore>
"""

geoserver.create_wms_store(workspace="test", body=body)
Source code in geoserver/geoserver.py
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
def create_wms_store(self, body: Union[str, Dict[str, Any]], *, workspace: str) -> str:
    """Creates a new WMS store.

    Args:
        body: The body of the request used to create the WMS store.
        workspace: The name of the workspace.

    Returns:
        Success message.

    Example:
        To add a new WMS store to the server, you can use the following code:

        ```python
        body = \"\"\"
        <wmsStore>
            <name>remote</name>
            <capabilitiesUrl>http://demo.geoserver.org/geoserver/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities</capabilitiesUrl>
        </wmsStore>
        \"\"\"

        geoserver.create_wms_store(workspace="test", body=body)
        ```
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/wmsstores"
    self._request(method="post", url=url, body=body)
    return CREATED_MESSAGE

get_wms_store

get_wms_store(name: str, *, workspace: str, format: Literal['json'] = 'json') -> Dict[str, Any]
get_wms_store(name: str, *, workspace: str, format: Literal['xml']) -> str
get_wms_store(name: str, *, workspace: str, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Retrieves a single WMS store.

Parameters:

Name Type Description Default
name str

The name of the WMS store.

required
workspace str

The name of the workspace.

required
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The WMS store.

Source code in geoserver/geoserver.py
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
def get_wms_store(
    self, name: str, *, workspace: str, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """Retrieves a single WMS store.

    Args:
        name: The name of the WMS store.
        workspace: The name of the workspace.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The WMS store.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/wmsstores/{name}.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

update_wms_store

update_wms_store(name: str, body: Union[str, Dict[str, Any]], *, workspace: str) -> str

Modifies a single WMS store.

Parameters:

Name Type Description Default
name str

The name of the WMS store.

required
workspace str

The name of the workspace.

required
body Union[str, Dict[str, Any]]

The body of the request used to modify the WMS store.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
def update_wms_store(self, name: str, body: Union[str, Dict[str, Any]], *, workspace: str) -> str:
    """Modifies a single WMS store.

    Args:
        name: The name of the WMS store.
        workspace: The name of the workspace.
        body: The body of the request used to modify the WMS store.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/wmsstores/{name}"
    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

delete_wms_store

delete_wms_store(name: str, *, workspace: str) -> str

Deletes a single WMS store.

Parameters:

Name Type Description Default
name str

The name of the WMS store.

required
workspace str

The name of the workspace.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
def delete_wms_store(self, name: str, *, workspace: str) -> str:
    """Deletes a single WMS store.

    Args:
        name: The name of the WMS store.
        workspace: The name of the workspace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/wmsstores/{name}"
    self._request(method="delete", url=url)
    return DELETED_MESSAGE

get_wmts_layers

get_wmts_layers(*, workspace: str, store: Optional[str] = None, list: Optional[Literal['available']] = None, format: Literal['json'] = 'json') -> Dict[str, Any]
get_wmts_layers(*, workspace: str, store: Optional[str] = None, list: Optional[Literal['available']] = None, format: Literal['xml']) -> str
get_wmts_layers(*, workspace: str, store: Optional[str] = None, list: Optional[Literal['available']] = None, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Retrieves the WMTS layers available on the server.

Parameters:

Name Type Description Default
workspace str

The name of the workspace.

required
store Optional[str]

Name of the wmts store.

None
list Optional[Literal['available']]

Set list=available to see all possible layers in the store, not just ones currently published.

None
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The WMTS layers.

Source code in geoserver/geoserver.py
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
def get_wmts_layers(
    self,
    *,
    workspace: str,
    store: Optional[str] = None,
    list: Optional[Literal["available"]] = None,
    format: Literal["json", "xml"] = "json",
) -> Union[str, Dict[str, Any]]:
    """Retrieves the WMTS layers available on the server.

    Args:
        workspace: The name of the workspace.
        store: Name of the wmts store.
        list: Set `list=available` to see all possible layers in the store, not just ones currently published.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The WMTS layers.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/layers.{format}"
    if store is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/wmtsstores/{store}/layers.{format}"

    params = dict(list=list)
    response = self._request(method="get", url=url, params=params)
    return response.json() if format == "json" else response.text

wmts_layer_exists

wmts_layer_exists(name: str, *, workspace: str, store: Optional[str] = None) -> bool

Check if a WMTS layer exists.

Parameters:

Name Type Description Default
name str

The name of the layer.

required
workspace str

The name of the workspace.

required
store Optional[str]

Name of the wmts store.

None

Returns:

Type Description
bool

True if the WMTS layer exists, False otherwise.

Source code in geoserver/geoserver.py
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
def wmts_layer_exists(self, name: str, *, workspace: str, store: Optional[str] = None) -> bool:
    """Check if a WMTS layer exists.

    Args:
        name: The name of the layer.
        workspace: The name of the workspace.
        store: Name of the wmts store.

    Returns:
        True if the WMTS layer exists, False otherwise.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/layers/{name}.xml"
    if store is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/wmtsstores/{store}/layers/{name}.xml"

    response = self._request(method="head", url=url, ignore=[404])
    return response.status_code == 200

create_wmts_layer

create_wmts_layer(body: Union[str, Dict[str, Any]], *, workspace: str, store: Optional[str] = None) -> str

Creates a new WMTS layer.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to create the WMTS layer.

required
workspace str

The name of the workspace.

required
store Optional[str]

Name of the wmts store.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
def create_wmts_layer(
    self, body: Union[str, Dict[str, Any]], *, workspace: str, store: Optional[str] = None
) -> str:
    """Creates a new WMTS layer.

    Args:
        body: The body of the request used to create the WMTS layer.
        workspace: The name of the workspace.
        store: Name of the wmts store.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/layers"
    if store is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/wmtsstores/{store}/layers"

    self._request(method="post", url=url, body=body)
    return CREATED_MESSAGE

get_wmts_layer

get_wmts_layer(name: str, *, workspace: str, store: Optional[str] = None, quiet_on_not_found: bool = False, format: Literal['json'] = 'json') -> Dict[str, Any]
get_wmts_layer(name: str, *, workspace: str, store: Optional[str] = None, quiet_on_not_found: bool = False, format: Literal['xml']) -> str
get_wmts_layer(name: str, *, workspace: str, store: Optional[str] = None, quiet_on_not_found: bool = False, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Retrieves a single WMTS layer.

Parameters:

Name Type Description Default
name str

The name of the layer.

required
workspace str

The name of the workspace.

required
store Optional[str]

Optional. Name of the wmts store.

None
quiet_on_not_found bool

Optional. When set to "true", will not log an exception when the style is not present. The 404 status code will still be returned.

False
format Literal['json', 'xml']

Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The WMTS layer.

Source code in geoserver/geoserver.py
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
def get_wmts_layer(
    self,
    name: str,
    *,
    workspace: str,
    store: Optional[str] = None,
    quiet_on_not_found: bool = False,
    format: Literal["json", "xml"] = "json",
) -> Union[str, Dict[str, Any]]:
    """Retrieves a single WMTS layer.

    Args:
        name: The name of the layer.
        workspace: The name of the workspace.
        store: Optional. Name of the wmts store.
        quiet_on_not_found: Optional. When set to "true", will not log an exception when the style is not present.
            The 404 status code will still be returned.
        format: Optional. The format of the response. It can be either "json" or "xml". Defaults to "json".

    Returns:
        The WMTS layer.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/layers/{name}.{format}"
    if store is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/wmtsstores/{store}/layers/{name}.{format}"

    params = dict(quietOnNotFound=quiet_on_not_found)
    response = self._request(method="get", url=url, params=params)
    return response.json() if format == "json" else response.text

update_wmts_layer

update_wmts_layer(name: str, body: Union[str, Dict[str, Any]], *, workspace: str, store: Optional[str] = None) -> str

Modifies a single WMTS layer.

Parameters:

Name Type Description Default
name str

The name of the layer.

required
body Union[str, Dict[str, Any]]

The body of the request used to modify the WMTS layer.

required
workspace str

The name of the workspace.

required
store Optional[str]

Name of the wmts store.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
def update_wmts_layer(
    self, name: str, body: Union[str, Dict[str, Any]], *, workspace: str, store: Optional[str] = None
) -> str:
    """Modifies a single WMTS layer.

    Args:
        name: The name of the layer.
        body: The body of the request used to modify the WMTS layer.
        workspace: The name of the workspace.
        store: Name of the wmts store.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/layers/{name}"
    if store is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/wmtsstores/{store}/layers/{name}"

    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

delete_wmts_layer

delete_wmts_layer(name: str, *, workspace: str, store: Optional[str] = None, recurse: bool = False) -> str

Deletes a single WMTS layer.

Parameters:

Name Type Description Default
name str

The name of the layer.

required
workspace str

The name of the workspace.

required
store Optional[str]

Name of the wmts store.

None
recurse bool

Recursively deletes all layers referenced by the specified wmtslayer. A request with recurse=false will fail if any layers reference the wmtslayer.

False

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
def delete_wmts_layer(
    self, name: str, *, workspace: str, store: Optional[str] = None, recurse: bool = False
) -> str:
    """Deletes a single WMTS layer.

    Args:
        name: The name of the layer.
        workspace: The name of the workspace.
        store: Name of the wmts store.
        recurse: Recursively deletes all layers referenced by the specified wmtslayer.
            A request with `recurse=false` will fail if any layers reference the wmtslayer.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/layers/{name}"
    if store is not None:
        url = f"{self.service_url}/rest/workspaces/{workspace}/wmtsstores/{store}/layers/{name}"

    params = dict(recurse=recurse)
    self._request(method="delete", url=url, params=params)
    return DELETED_MESSAGE

get_wmts_stores

get_wmts_stores(*, workspace: str, format: Literal['json'] = 'json') -> Dict[str, Any]
get_wmts_stores(*, workspace: str, format: Literal['xml']) -> str
get_wmts_stores(*, workspace: str, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Retrieves the WMTS stores available on the server.

Parameters:

Name Type Description Default
workspace str

The name of the workspace.

required
format Literal['json', 'xml']

Optional. The format of the response. Can be either "json" or "xml".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The WMTS stores.

Source code in geoserver/geoserver.py
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
def get_wmts_stores(self, *, workspace: str, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Retrieves the WMTS stores available on the server.

    Args:
        workspace: The name of the workspace.
        format: Optional. The format of the response. Can be either "json" or "xml".

    Returns:
        The WMTS stores.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/wmtsstores.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

wmts_store_exists

wmts_store_exists(name: str, *, workspace: str) -> bool

Checks if a WMTS store exists on the server.

Parameters:

Name Type Description Default
name str

The name of the WMTS store.

required
workspace str

The name of the workspace.

required

Returns:

Type Description
bool

True if the WMTS store exists, False otherwise.

Source code in geoserver/geoserver.py
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
def wmts_store_exists(self, name: str, *, workspace: str) -> bool:
    """Checks if a WMTS store exists on the server.

    Args:
        name: The name of the WMTS store.
        workspace: The name of the workspace.

    Returns:
        True if the WMTS store exists, False otherwise.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/wmtsstores/{name}.xml"
    response = self._request(method="head", url=url, ignore=[404])
    return response.status_code == 200

create_wmts_store

create_wmts_store(body: Union[str, Dict[str, Any]], *, workspace: str) -> str

Creates a new WMTS store.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to create the WMTS store.

required
workspace str

The name of the workspace.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
def create_wmts_store(self, body: Union[str, Dict[str, Any]], *, workspace: str) -> str:
    """Creates a new WMTS store.

    Args:
        body: The body of the request used to create the WMTS store.
        workspace: The name of the workspace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/wmtsstores"
    self._request(method="post", url=url, body=body)
    return CREATED_MESSAGE

get_wmts_store

get_wmts_store(name: str, *, workspace: str, format: Literal['json'] = 'json') -> Dict[str, Any]
get_wmts_store(name: str, *, workspace: str, format: Literal['xml']) -> str
get_wmts_store(name: str, *, workspace: str, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Retrieves a single WMTS store.

Parameters:

Name Type Description Default
name str

The name of the WMTS store.

required
workspace str

The name of the workspace.

required
format Literal['json', 'xml']

Optional. The format of the response. Can be either "json" or "xml".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The WMTS store.

Source code in geoserver/geoserver.py
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
def get_wmts_store(
    self, name: str, *, workspace: str, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """Retrieves a single WMTS store.

    Args:
        name: The name of the WMTS store.
        workspace: The name of the workspace.
        format: Optional. The format of the response. Can be either "json" or "xml".

    Returns:
        The WMTS store.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/wmtsstores/{name}.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

update_wmts_store

update_wmts_store(name: str, body: Union[str, Dict[str, Any]], *, workspace: str) -> str

Modifies a single WMTS store.

Parameters:

Name Type Description Default
name str

The name of the WMTS store.

required
body Union[str, Dict[str, Any]]

The body of the request used to modify the WMTS store.

required
workspace str

The name of the workspace.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
def update_wmts_store(self, name: str, body: Union[str, Dict[str, Any]], *, workspace: str) -> str:
    """Modifies a single WMTS store.

    Args:
        name: The name of the WMTS store.
        body: The body of the request used to modify the WMTS store.
        workspace: The name of the workspace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/wmtsstores/{name}"
    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

delete_wmts_store

delete_wmts_store(name: str, *, workspace: str) -> str

Deletes a single WMTS store.

Parameters:

Name Type Description Default
name str

The name of the WMTS store.

required
workspace str

The name of the workspace.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
def delete_wmts_store(self, name: str, *, workspace: str) -> str:
    """Deletes a single WMTS store.

    Args:
        name: The name of the WMTS store.
        workspace: The name of the workspace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/workspaces/{workspace}/wmtsstores/{name}"
    self._request(method="delete", url=url)
    return DELETED_MESSAGE

get_workspaces

get_workspaces(*, format: Literal['json'] = 'json') -> Dict[str, Any]
get_workspaces(*, format: Literal['xml']) -> str
get_workspaces(*, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Displays a list of all workspaces on the server.

Parameters:

Name Type Description Default
format Literal['json', 'xml']

Optional. The format of the response. Can be either "json" or "xml".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The workspaces.

Source code in geoserver/geoserver.py
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
def get_workspaces(self, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Displays a list of all workspaces on the server.

    Args:
        format: Optional. The format of the response. Can be either "json" or "xml".

    Returns:
        The workspaces.
    """
    url = f"{self.service_url}/rest/workspaces.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

workspace_exists

workspace_exists(name: str) -> bool

Checks if a workspace exists on the server.

Parameters:

Name Type Description Default
name str

The name of the workspace.

required

Returns:

Type Description
bool

True if the workspace exists, False otherwise.

Source code in geoserver/geoserver.py
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
def workspace_exists(self, name: str) -> bool:
    """Checks if a workspace exists on the server.

    Args:
        name: The name of the workspace.

    Returns:
        True if the workspace exists, False otherwise.
    """
    url = f"{self.service_url}/rest/workspaces/{name}.xml"
    response = self._request(method="head", url=url, ignore=[404])
    return response.status_code == 200

create_workspace

create_workspace(body: Union[str, Dict[str, Any]]) -> str

Creates a new workspace.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to create the workspace.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
def create_workspace(self, body: Union[str, Dict[str, Any]]) -> str:
    """Creates a new workspace.

    Args:
        body: The body of the request used to create the workspace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/workspaces"
    self._request(method="post", url=url, body=body)
    return CREATED_MESSAGE

create_workspace_from_name

create_workspace_from_name(name: str) -> str

Shortcut to create a new workspace from a name.

Parameters:

Name Type Description Default
name str

The name of the workspace.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
def create_workspace_from_name(self, name: str) -> str:
    """Shortcut to create a new workspace from a name.

    Args:
        name: The name of the workspace.

    Returns:
        Success message.
    """
    body = {"workspace": {"name": name}}
    return self.create_workspace(body=body)

get_workspace

get_workspace(name: str, *, format: Literal['json'] = 'json') -> Dict[str, Any]
get_workspace(name: str, *, format: Literal['xml']) -> str
get_workspace(name: str, *, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Displays a single workspace on the server.

Parameters:

Name Type Description Default
name str

The name of the workspace.

required
format Literal['json', 'xml']

Optional. The format of the response. Can be either "json" or "xml".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The workspace.

Source code in geoserver/geoserver.py
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
def get_workspace(self, name: str, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Displays a single workspace on the server.

    Args:
        name: The name of the workspace.
        format: Optional. The format of the response. Can be either "json" or "xml".

    Returns:
        The workspace.
    """
    url = f"{self.service_url}/rest/workspaces/{name}.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

update_workspace

update_workspace(name: str, body: Union[str, Dict[str, Any]]) -> str

Modifies a single workspace.

Parameters:

Name Type Description Default
name str

The name of the workspace.

required
body Union[str, Dict[str, Any]]

The body of the request used to modify the workspace.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
def update_workspace(self, name: str, body: Union[str, Dict[str, Any]]) -> str:
    """Modifies a single workspace.

    Args:
        name: The name of the workspace.
        body: The body of the request used to modify the workspace.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/workspaces/{name}"
    self._request(method="put", url=url, body=body)
    return UPDATED_MESSAGE

delete_workspace

delete_workspace(name: str, *, recurse: bool = False) -> str

Deletes a single workspace.

Parameters:

Name Type Description Default
name str

The name of the workspace.

required
recurse bool

Optional. Recursively deletes all resources in the workspace. Defaults to False.

False

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
def delete_workspace(self, name: str, *, recurse: bool = False) -> str:
    """Deletes a single workspace.

    Args:
        name: The name of the workspace.
        recurse: Optional. Recursively deletes all resources in the workspace. Defaults to False.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/workspaces/{name}"
    params = dict(recurse=recurse)
    self._request(method="delete", url=url, params=params)
    return DELETED_MESSAGE

get_users

get_users(*, service: Optional[str] = None, group: Optional[str] = None, format: Literal['json'] = 'json') -> Dict[str, Any]
get_users(*, service: Optional[str] = None, group: Optional[str] = None, format: Literal['xml']) -> str
get_users(*, service: Optional[str] = None, group: Optional[str] = None, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Query all users in the default user/group service.

Parameters:

Name Type Description Default
service Optional[str]

Optional. The name of the user/group service.

None
group Optional[str]

Optional. The name of the group.

None
format Literal['json', 'xml']

Optional. The format of the response. Can be either "json" or "xml".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The users.

Source code in geoserver/geoserver.py
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
def get_users(
    self, *, service: Optional[str] = None, group: Optional[str] = None, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """Query all users in the default user/group service.

    Args:
        service: Optional. The name of the user/group service.
        group: Optional. The name of the group.
        format: Optional. The format of the response. Can be either "json" or "xml".

    Returns:
        The users.
    """
    if service is None and group is None:
        url = f"{self.service_url}/rest/security/usergroup/users.{format}"
    elif service is not None and group is None:
        url = f"{self.service_url}/rest/security/usergroup/service/{service}/users.{format}"
    elif service is None and group is not None:
        url = f"{self.service_url}/rest/security/usergroup/group/{group}/users.{format}"
    else:
        raise ValueError("Invalid combination of service and group.")

    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

create_user

create_user(body: Union[str, Dict[str, Any]], *, service: Optional[str] = None) -> str

Add a new user to the default user/group service.

Parameters:

Name Type Description Default
body Union[str, Dict[str, Any]]

The body of the request used to create the user.

required

Returns:

Type Description
str

Success message.

Example

To add a new user to the default user/group service, you can use the following code:

body = {
    "userName": "user",
    "password": "password",
    "enabled": "true",
}
geoserver.create_user(body=body)
Source code in geoserver/geoserver.py
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
def create_user(self, body: Union[str, Dict[str, Any]], *, service: Optional[str] = None) -> str:
    """Add a new user to the default user/group service.

    Args:
        body: The body of the request used to create the user.

    Returns:
        Success message.

    Example:
        To add a new user to the default user/group service, you can use the following code:

        ```python
        body = {
            "userName": "user",
            "password": "password",
            "enabled": "true",
        }
        geoserver.create_user(body=body)
        ```
    """
    url = f"{self.service_url}/rest/security/usergroup/users"
    if service is not None:
        url = f"{self.service_url}/rest/security/usergroup/service/{service}/users"

    self._request(method="post", url=url, body=body)
    return CREATED_MESSAGE

update_user

update_user(name: str, body: Union[str, Dict[str, Any]], *, service: Optional[str] = None) -> str

Update an existing user in the default user/group service.

Parameters:

Name Type Description Default
name str

The name of the user.

required
body Union[str, Dict[str, Any]]

The body of the request used to modify the user.

required
service Optional[str]

The name of the user/group service.

None

Returns:

Type Description
str

Success message.

Example

To update an existing user in the default user/group service, you can use the following code:

body = """
<user>
    <userName>user</userName>
    <password>password</password>
    <enabled>true</enabled>
</user>
"""

geoserver.update_user("my_user", body=body)
Source code in geoserver/geoserver.py
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
def update_user(self, name: str, body: Union[str, Dict[str, Any]], *, service: Optional[str] = None) -> str:
    """Update an existing user in the default user/group service.

    Args:
        name: The name of the user.
        body: The body of the request used to modify the user.
        service: The name of the user/group service.

    Returns:
        Success message.

    Example:
        To update an existing user in the default user/group service, you can use the following code:

        ```python
        body = \"\"\"
        <user>
            <userName>user</userName>
            <password>password</password>
            <enabled>true</enabled>
        </user>
        \"\"\"

        geoserver.update_user("my_user", body=body)
        ```
    """
    url = f"{self.service_url}/rest/security/usergroup/user/{name}"
    if service is not None:
        url = f"{self.service_url}/rest/security/usergroup/service/{service}/user/{name}"

    self._request(method="post", url=url, body=body)
    return UPDATED_MESSAGE

delete_user

delete_user(name: str, *, service: Optional[str] = None) -> str

Remove an existing user from the default user/group service.

Parameters:

Name Type Description Default
name str

The name of the user.

required
service Optional[str]

The name of the user/group service.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
def delete_user(self, name: str, *, service: Optional[str] = None) -> str:
    """Remove an existing user from the default user/group service.

    Args:
        name: The name of the user.
        service: The name of the user/group service.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/security/usergroup/user/{name}"
    if service is not None:
        url = f"{self.service_url}/rest/security/usergroup/service/{service}/user/{name}"

    self._request(method="delete", url=url)
    return DELETED_MESSAGE

get_user_groups

get_user_groups(*, user: str, service: Optional[str] = None, format: Literal['json'] = 'json') -> Dict[str, Any]
get_user_groups(*, user: str, service: Optional[str] = None, format: Literal['xml']) -> str
get_user_groups(*, user: str, service: Optional[str] = None, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Query all groups in the default user/group service.

Parameters:

Name Type Description Default
user str

The name of the user.

required
service Optional[str]

Optional. The name of the user/group service.

None
format Literal['json', 'xml']

Optional. The format of the response. Can be either "json" or "xml".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The groups.

Source code in geoserver/geoserver.py
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
def get_user_groups(
    self, *, user: str, service: Optional[str] = None, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """Query all groups in the default user/group service.

    Args:
        user: The name of the user.
        service: Optional. The name of the user/group service.
        format: Optional. The format of the response. Can be either "json" or "xml".

    Returns:
        The groups.
    """
    url = f"{self.service_url}/rest/security/usergroup/user/{user}/groups.{format}"
    if service is not None:
        url = f"{self.service_url}/rest/security/usergroup/service/{service}/user/{user}/groups.{format}"

    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

associate_user

associate_user(user: str, group: str, *, service: Optional[str] = None) -> str

Associate a user with a group in the default user/group service.

Parameters:

Name Type Description Default
user str

The name of the user.

required
group str

The name of the group.

required
service Optional[str]

The name of the user/group service.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
def associate_user(self, user: str, group: str, *, service: Optional[str] = None) -> str:
    """Associate a user with a group in the default user/group service.

    Args:
        user: The name of the user.
        group: The name of the group.
        service: The name of the user/group service.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/security/usergroup/user/{user}/group/{group}"
    if service is not None:
        url = f"{self.service_url}/rest/security/usergroup/service/{service}/user/{user}/group/{group}"

    self._request(method="post", url=url)
    return OK_MESSAGE

disassociate_user

disassociate_user(user: str, group: str, *, service: Optional[str] = None) -> str

Remove a user from a group in the default user/group service.

Parameters:

Name Type Description Default
user str

The name of the user.

required
group str

The name of the group.

required
service Optional[str]

The name of the user/group service.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
def disassociate_user(self, user: str, group: str, *, service: Optional[str] = None) -> str:
    """Remove a user from a group in the default user/group service.

    Args:
        user: The name of the user.
        group: The name of the group.
        service: The name of the user/group service.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/security/usergroup/user/{user}/group/{group}"
    if service is not None:
        url = f"{self.service_url}/rest/security/usergroup/service/{service}/user/{user}/group/{group}"

    self._request(method="delete", url=url)
    return OK_MESSAGE

create_user_group

create_user_group(name: str, *, service: Optional[str] = None) -> str

Add a new group to the default user/group service.

Parameters:

Name Type Description Default
name str

The name of the group.

required
service Optional[str]

The name of the user/group service.

None

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
def create_user_group(self, name: str, *, service: Optional[str] = None) -> str:
    """Add a new group to the default user/group service.

    Args:
        name: The name of the group.
        service: The name of the user/group service.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/security/usergroup/group/{name}"
    if service is not None:
        url = f"{self.service_url}/rest/security/usergroup/service/{service}/group/{name}"

    self._request(method="post", url=url)
    return OK_MESSAGE

delete_user_group

delete_user_group(name: str, *, service: Optional[str] = None) -> str

Remove a group from the default user/group service.

Parameters:

Name Type Description Default
name str

The name of the group.

required
service Optional[str]

The name of the user/group service.

None

Returns:

Type Description
str

Success message.

Example

To remove a group from the default user/group service, you can use the following code:

geoserver.delete_group(group="group")
Source code in geoserver/geoserver.py
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
def delete_user_group(self, name: str, *, service: Optional[str] = None) -> str:
    """Remove a group from the default user/group service.

    Args:
        name: The name of the group.
        service: The name of the user/group service.

    Returns:
        Success message.

    Example:
        To remove a group from the default user/group service, you can use the following code:

        ```python
        geoserver.delete_group(group="group")
        ```
    """
    url = f"{self.service_url}/rest/security/usergroup/group/{name}"
    if service is not None:
        url = f"{self.service_url}/rest/security/usergroup/service/{service}/group/{name}"

    self._request(method="delete", url=url)
    return OK_MESSAGE

get_roles

get_roles(*, service: Optional[str] = None, group: Optional[str] = None, user: Optional[str] = None, format: Literal['json'] = 'json') -> Dict[str, Any]
get_roles(*, service: Optional[str] = None, group: Optional[str] = None, user: Optional[str] = None, format: Literal['xml']) -> str
get_roles(*, service: Optional[str] = None, group: Optional[str] = None, user: Optional[str] = None, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Query all roles in the default user/group service.

Parameters:

Name Type Description Default
service Optional[str]

Optional. The name of the user/group service.

None
group Optional[str]

Optional. The name of the group.

None
user Optional[str]

Optional. The name of the user.

None
format Literal['json', 'xml']

Optional. The format of the response. Can be either "json" or "xml".

'json'

Returns:

Type Description
Union[str, Dict[str, Any]]

The roles.

Example

To get all roles in the default user/group service, you can use the following code:

geoserver.get_roles()
Source code in geoserver/geoserver.py
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
def get_roles(
    self,
    *,
    service: Optional[str] = None,
    group: Optional[str] = None,
    user: Optional[str] = None,
    format: Literal["json", "xml"] = "json",
) -> Union[str, Dict[str, Any]]:
    """Query all roles in the default user/group service.

    Args:
        service: Optional. The name of the user/group service.
        group: Optional. The name of the group.
        user: Optional. The name of the user.
        format: Optional. The format of the response. Can be either "json" or "xml".

    Returns:
        The roles.

    Example:
        To get all roles in the default user/group service, you can use the following code:

        ```python
        geoserver.get_roles()
        ```
    """
    if service is None and group is None and user is None:
        url = f"{self.service_url}/rest/security/roles.{format}"
    elif service is not None and group is None and user is None:
        url = f"{self.service_url}/rest/security/roles/service/{service}.{format}"
    elif service is None and group is not None and user is None:
        url = f"{self.service_url}/rest/security/roles/group/{group}.{format}"
    elif service is not None and group is not None and user is None:
        url = f"{self.service_url}/rest/security/roles/service/{service}/group/{group}.{format}"
    elif service is not None and group is None and user is not None:
        url = f"{self.service_url}/rest/security/roles/service/{service}/user/{user}.{format}"
    else:
        raise ValueError("Invalid combination of service, group and user.")

    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

create_role

create_role(name: str) -> str

Add a new role to the default user/group service.

Parameters:

Name Type Description Default
name str

The name of the role.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
def create_role(self, name: str) -> str:
    """Add a new role to the default user/group service.

    Args:
        name: The name of the role.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/security/roles/role/{name}"

    self._request(method="post", url=url)
    return CREATED_MESSAGE

delete_role

delete_role(name: str) -> str

Remove a role from the default user/group service.

Parameters:

Name Type Description Default
name str

The name of the role.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geoserver.py
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
def delete_role(self, name: str) -> str:
    """Remove a role from the default user/group service.

    Args:
        name: The name of the role.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/rest/security/roles/role/{name}"

    self._request(method="delete", url=url)
    return DELETED_MESSAGE

associate_role

associate_role(role: str, *, service: Optional[str] = None, group: Optional[str] = None, user: Optional[str] = None) -> str

Associate a user with a role in the default user/group service.

Parameters:

Name Type Description Default
role str

The name of the role.

required
service Optional[str]

The name of the user/group service.

None
group Optional[str]

The name of the group.

None
user Optional[str]

The name of the user.

None

Returns:

Type Description
str

Success message.

Example

To associate a user with a role in the default user/group service, you can use the following code:

geoserver.associate_role(role="ROLE_ADMIN", user="admin")
Source code in geoserver/geoserver.py
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
def associate_role(
    self, role: str, *, service: Optional[str] = None, group: Optional[str] = None, user: Optional[str] = None
) -> str:
    """Associate a user with a role in the default user/group service.

    Args:
        role: The name of the role.
        service: The name of the user/group service.
        group: The name of the group.
        user: The name of the user.

    Returns:
        Success message.

    Example:
        To associate a user with a role in the default user/group service, you can use the following code:

        ```python
        geoserver.associate_role(role="ROLE_ADMIN", user="admin")
        ```
    """
    if service is not None and group is None and user is None:
        url = f"{self.service_url}/rest/security/roles/service/{service}/role/{role}"
    elif service is None and group is None and user is not None:
        url = f"{self.service_url}/rest/security/roles/role/{role}/user/{user}"
    elif service is None and group is not None and user is None:
        url = f"{self.service_url}/rest/security/roles/role/{role}/group/{group}"
    elif service is not None and group is None and user is not None:
        url = f"{self.service_url}/rest/security/roles/service/{service}/role/{role}/user/{user}"
    elif service is not None and group is not None and user is None:
        url = f"{self.service_url}/rest/security/roles/service/{service}/role/{role}/group/{group}"
    else:
        raise ValueError("Invalid combination of service, group and user.")

    self._request(method="post", url=url)
    return OK_MESSAGE

disassociate_role

disassociate_role(role: str, *, service: Optional[str] = None, group: Optional[str] = None, user: Optional[str] = None) -> str

Disassociate a user with a role in the default user/group service.

Parameters:

Name Type Description Default
role str

The name of the role.

required
service Optional[str]

The name of the user/group service.

None
group Optional[str]

The name of the group.

None
user Optional[str]

The name of the user.

None

Returns:

Type Description
str

Success message.

Example

To disassociate a user from a role in the default user/group service, you can use the following code:

geoserver.disassociate_role(role="ROLE_ADMIN", user="admin")
Source code in geoserver/geoserver.py
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
def disassociate_role(
    self, role: str, *, service: Optional[str] = None, group: Optional[str] = None, user: Optional[str] = None
) -> str:
    """Disassociate a user with a role in the default user/group service.

    Args:
        role: The name of the role.
        service: The name of the user/group service.
        group: The name of the group.
        user: The name of the user.

    Returns:
        Success message.

    Example:
        To disassociate a user from a role in the default user/group service, you can use the following code:

        ```python
        geoserver.disassociate_role(role="ROLE_ADMIN", user="admin")
        ```
    """
    if service is not None and group is None and user is None:
        url = f"{self.service_url}/rest/security/roles/service/{service}/role/{role}"
    elif service is None and group is None and user is not None:
        url = f"{self.service_url}/rest/security/roles/role/{role}/user/{user}"
    elif service is None and group is not None and user is None:
        url = f"{self.service_url}/rest/security/roles/role/{role}/group/{group}"
    elif service is not None and group is None and user is not None:
        url = f"{self.service_url}/rest/security/roles/service/{service}/role/{role}/user/{user}"
    elif service is not None and group is not None and user is None:
        url = f"{self.service_url}/rest/security/roles/service/{service}/role/{role}/group/{group}"
    else:
        raise ValueError("Invalid combination of service, group and user.")

    self._request(method="delete", url=url)
    return OK_MESSAGE