Skip to content

GeoWebCache

Bases: Base

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_blob_stores

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

Retrieves the blob stores available on the server.

Parameters:

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

Optional. The format of the response.

'json'

Returns:

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

The blob stores.

Source code in geoserver/geowebcache.py
14
15
16
17
18
19
20
21
22
23
24
25
def get_blob_stores(self, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Retrieves the blob stores available on the server.

    Args:
        format: Optional. The format of the response.

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

get_blob_store

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

Retrieves a single blob store.

Parameters:

Name Type Description Default
name str

The name of the blob store.

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

Optional. The format of the response.

'json'

Returns:

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

The blob store.

Source code in geoserver/geowebcache.py
33
34
35
36
37
38
39
40
41
42
43
44
45
def get_blob_store(self, name: str, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Retrieves a single blob store.

    Args:
        name: The name of the blob store.
        format: Optional. The format of the response.

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

insert_blob_store

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

Creates a new blob store.

Parameters:

Name Type Description Default
name str

The name of the blob store.

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

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

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geowebcache.py
47
48
49
50
51
52
53
54
55
56
57
58
59
def insert_blob_store(self, name: str, body: Union[str, Dict[str, Any]]) -> str:
    """Creates a new blob store.

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

    Returns:
        Success message.
    """
    url = f"{self.service_url}/gwc/rest/blobstores/{name}.json"
    self._request(method="post", url=url, body=body)
    return CREATED_MESSAGE

delete_blob_store

delete_blob_store(name: str) -> str

Deletes a single blob store.

Parameters:

Name Type Description Default
name str

The name of the blob store.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geowebcache.py
61
62
63
64
65
66
67
68
69
70
71
72
def delete_blob_store(self, name: str) -> str:
    """Deletes a single blob store.

    Args:
        name: The name of the blob store.

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

get_layer_bounds

get_layer_bounds(layer: str, srs: str, type: str, *, format: Literal['json'] = 'json') -> Dict[str, Any]
get_layer_bounds(layer: str, srs: str, type: str, *, format: Literal['xml']) -> str
get_layer_bounds(layer: str, srs: str, type: str, *, format: Literal['json', 'xml'] = 'json') -> Union[str, Dict[str, Any]]

Retrieves the bounds for a layer.

Parameters:

Name Type Description Default
layer str

The name of the layer.

required
srs str

The srs projection used against the layer to find the bounds such as EPSG:4326.

required
type str

Accepts java as an extension.

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

Optional. The format of the response.

'json'

Returns:

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

The bounds.

Source code in geoserver/geowebcache.py
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
def get_layer_bounds(
    self, layer: str, srs: str, type: str, *, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """Retrieves the bounds for a layer.

    Args:
        layer: The name of the layer.
        srs: The srs projection used against the layer to find the bounds such as EPSG:4326.
        type: Accepts java as an extension.
        format: Optional. The format of the response.

    Returns:
        The bounds.
    """
    url = f"{self.service_url}/gwc/rest/bounds/{layer}/{srs}/{type}.{format}"
    response = self._request(method="get", url=url)
    return response.json() if format == "json" else response.text

get_diskquota

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

Retrieves the disk quota settings.

Parameters:

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

Optional. The format of the response.

'json'

Returns:

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

The disk quota settings.

Source code in geoserver/geowebcache.py
110
111
112
113
114
115
116
117
118
119
120
121
def get_diskquota(self, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Retrieves the disk quota settings.

    Args:
        format: Optional. The format of the response.

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

update_diskquota

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

Modifies the disk quota settings.

Parameters:

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

The body of the request used to modify the disk quota settings.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geowebcache.py
123
124
125
126
127
128
129
130
131
132
133
134
def update_diskquota(self, body: Union[str, Dict[str, Any]]) -> str:
    """Modifies the disk quota settings.

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

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

filter_update

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

Restfully updates the given filter with parameters provided in the xml or zip.

Parameters:

Name Type Description Default
filter str

The filter to use for the update.

required
update str

The update to apply.

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

Optional. The format of the response.

'json'

Returns:

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

The response.

Source code in geoserver/geowebcache.py
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
def filter_update(
    self, filter: str, update: str, *, format: Literal["json", "xml"] = "json"
) -> Union[str, Dict[str, Any]]:
    """Restfully updates the given filter with parameters provided in the xml or zip.

    Args:
        filter: The filter to use for the update.
        update: The update to apply.
        format: Optional. The format of the response.

    Returns:
        The response.
    """
    url = f"{self.service_url}/gwc/rest/filter/{filter}/update/{update}.{format}"
    response = self._request(method="post", url=url)
    return response.json() if format == "json" else response.text

get_global_settings

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

Retrieves the global settings.

Parameters:

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

Optional. The format of the response.

'json'

Returns:

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

The global settings.

Source code in geoserver/geowebcache.py
165
166
167
168
169
170
171
172
173
174
175
176
def get_global_settings(self, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Retrieves the global settings.

    Args:
        format: Optional. The format of the response.

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

update_global_settings

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

Modifies the global settings.

Parameters:

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

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

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geowebcache.py
178
179
180
181
182
183
184
185
186
187
188
189
def update_global_settings(self, body: Union[str, Dict[str, Any]]) -> str:
    """Modifies the global settings.

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

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

get_gridsets

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

Retrieves the gridsets available on the server.

Parameters:

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

Optional. The format of the response.

'json'

Returns:

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

The gridsets.

Source code in geoserver/geowebcache.py
199
200
201
202
203
204
205
206
207
208
209
210
def get_gridsets(self, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Retrieves the gridsets available on the server.

    Args:
        format: Optional. The format of the response.

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

get_gridset

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

Retrieves a single gridset.

Parameters:

Name Type Description Default
name str

The name of the gridset.

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

Optional. The format of the response.

'json'

Returns:

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

The gridset.

Source code in geoserver/geowebcache.py
218
219
220
221
222
223
224
225
226
227
228
229
230
def get_gridset(self, name: str, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Retrieves a single gridset.

    Args:
        name: The name of the gridset.
        format: Optional. The format of the response.

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

insert_gridset

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

Creates a new configured gridset on the server, or modifies an existing gridset.

Parameters:

Name Type Description Default
name str

The name of the gridset.

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

The body of the request used to modify the gridset.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geowebcache.py
232
233
234
235
236
237
238
239
240
241
242
243
244
def insert_gridset(self, name: str, body: Union[str, Dict[str, Any]]) -> str:
    """Creates a new configured gridset on the server, or modifies an existing gridset.

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

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

delete_gridset

delete_gridset(name: str) -> str

Deletes a single gridset.

Parameters:

Name Type Description Default
name str

The name of the gridset.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geowebcache.py
246
247
248
249
250
251
252
253
254
255
256
257
def delete_gridset(self, name: str) -> str:
    """Deletes a single gridset.

    Args:
        name: The name of the gridset.

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

get_layers

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

Retrieves the layers available on the server.

Parameters:

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

Optional. The format of the response.

'json'

Returns:

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

The layers.

Source code in geoserver/geowebcache.py
267
268
269
270
271
272
273
274
275
276
277
278
def get_layers(self, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Retrieves the layers available on the server.

    Args:
        format: Optional. The format of the response.

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

get_layer

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

Retrieves a single layer.

Parameters:

Name Type Description Default
name str

The name of the layer.

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

Optional. The format of the response.

'json'

Returns:

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

The layer.

Source code in geoserver/geowebcache.py
286
287
288
289
290
291
292
293
294
295
296
297
298
def get_layer(self, name: str, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Retrieves a single layer.

    Args:
        name: The name of the layer.
        format: Optional. The format of the response.

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

insert_layer

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

Creates a new layer on the server, or modifies an existing 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

Returns:

Type Description
Dict[str, Any]

Success message.

Source code in geoserver/geowebcache.py
300
301
302
303
304
305
306
307
308
309
310
311
312
def insert_layer(self, name: str, body: Union[str, Dict[str, Any]]) -> Dict[str, Any]:
    """Creates a new layer on the server, or modifies an existing layer.

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

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

delete_layer

delete_layer(name: str) -> str

Deletes a single layer.

Parameters:

Name Type Description Default
name str

The name of the layer.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geowebcache.py
314
315
316
317
318
319
320
321
322
323
324
325
def delete_layer(self, name: str) -> str:
    """Deletes a single layer.

    Args:
        name: The name of the layer.

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

get_masstruncate

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

Returns xml containing the request type capabilities for mass truncation.

Parameters:

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

Optional. The format of the response.

'json'

Returns:

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

The mass truncate settings.

Source code in geoserver/geowebcache.py
335
336
337
338
339
340
341
342
343
344
345
346
347
def get_masstruncate(self, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Returns xml containing the request type capabilities for mass truncation.

    Args:
        format: Optional. The format of the response.

    Returns:
        The mass truncate settings.
    """
    url = f"{self.service_url}/gwc/rest/masstruncate.{format}"
    headers = {"Accept": "application/xml"}
    response = self._request(method="get", url=url, headers=headers)
    return response.json() if format == "json" else response.text

create_masstruncate

create_masstruncate(*, request_type: str, layer: str) -> str

Issues a mass truncate request based on the request type parameter. truncateLayer, will clear all caches associated with a named layer, including all permutations of gridset, parameter filter values, and image formats.

Parameters:

Name Type Description Default
request_type str

The type of request.

required
layer str

The name of the layer.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geowebcache.py
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
def create_masstruncate(self, *, request_type: str, layer: str) -> str:
    """Issues a mass truncate request based on the request type parameter.
    truncateLayer, will clear all caches associated with a named layer, including all permutations of gridset,
    parameter filter values, and image formats.

    Args:
        request_type: The type of request.
        layer: The name of the layer.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/gwc/rest/masstruncate"
    params = dict(requestType=request_type, layer=layer)
    response = self._request(method="post", url=url, params=params)
    return response.text

get_statistics

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

Retrieves the statistics for a layer or gridset.

Parameters:

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

Optional. The format of the response.

'json'

Returns:

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

The statistics.

Source code in geoserver/geowebcache.py
374
375
376
377
378
379
380
381
382
383
384
385
def get_statistics(self, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Retrieves the statistics for a layer or gridset.

    Args:
        format: Optional. The format of the response.

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

reload

reload(body: str) -> str

Reloads the GeoWebCache settings after making changes to the configuration.

Parameters:

Name Type Description Default
body str

The string value of the configuration ie. reload_configuration=1.

required

Returns:

Type Description
str

Success message.

Source code in geoserver/geowebcache.py
389
390
391
392
393
394
395
396
397
398
399
400
401
def reload(self, body: str) -> str:
    """Reloads the GeoWebCache settings after making changes to the configuration.

    Args:
        body: The string value of the configuration ie. `reload_configuration=1`.

    Returns:
        Success message.
    """
    url = f"{self.service_url}/gwc/rest/reload"
    headers = {"Content-Type": "text/plain"}
    response = self._request(method="post", url=url, data=body, headers=headers)
    return response.text

get_seed

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

Query's and returns a json array of the status for all currently running task. The array contains a set of long in the following order: [tiles processed, total number of tiles to process, number of remaining tiles, Task ID, Task status]. The returned task status will be one of -1 = ABORTED, 0 = PENDING, 1 = RUNNING, 2 = DONE

Parameters:

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

Optional. The format of the response.

'json'

Returns:

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

The seed settings.

Source code in geoserver/geowebcache.py
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
def get_seed(self, *, format: Literal["json", "xml"] = "json") -> Union[str, Dict[str, Any]]:
    """Query's and returns a json array of the status for all currently running task.
    The array contains a set of long in the following order:
    [tiles processed, total number of tiles to process, number of remaining tiles, Task ID, Task status].
    The returned task status will be one of -1 = ABORTED, 0 = PENDING, 1 = RUNNING, 2 = DONE

    Args:
        format: Optional. The format of the response.

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