.. _rest.gridsets:
Managing GridSets through the REST API
======================================
The REST API for GridSet management provides a RESTful interface through which clients can
programatically add, modify, or remove GridSets.
GridSets list
-------------
``/rest/gridsets.xml``
.. list-table::
:header-rows: 1
* - Method
- Action
- Return Code
- Formats
* - GET
- Return the list of available gridsets
- 200
- XML, JSON
* - POST
-
- 405
-
* - PUT
-
- 405
-
* - DELETE
-
- 400
-
Sample request:
.. code-block:: xml
curl -u geowebcache:secured "http://localhost:8080/geowebcache/rest/gridsets"
Sample response:
.. code-block:: xml
EPSG:2163
GlobalCRS84Pixel
EPSG:4326
GoogleCRS84Quad
EPSG:900913
GlobalCRS84Scale
GridSet Operations
------------------
``/rest/gridsets/gridset.xml``
.. list-table::
:header-rows: 1
* - Method
- Action
- Return Code
- Formats
* - GET
- Return the XML representation of the GridSet
- 200
- XML, JSON
* - POST
-
- 405
-
* - PUT
- Add a new GridSet or modify the definition of a GridSet.
- 200
- XML, JSON
* - DELETE
- Delete a GridSet
- 200
-
*Representations*:
- :download:`XML `
- :download:`JSON `
REST API for GridSets, cURL Examples
--------------------------------------
The examples in this section use the `cURL `_
utility, which is a handy command line tool for executing HTTP requests and
transferring files. Though cURL is used the examples apply to any HTTP-capable
tool or library.
Add GridSet
+++++++++++
Given a `gridset.xml` file as the following:
.. code-block:: xml
EPSG:2163
2163
-2495667.977678598
-2223677.196231552
3291070.6104286816
959189.3312465074
false
2.5E7
1000000.0
100000.0
25000.0
1.0
2.8E-4
EPSG:2163:0
EPSG:2163:1
EPSG:2163:2
EPSG:2163:3
200
200
false
.. code-block:: xml
curl -v -u geowebcache:secured -XPUT -H "Content-type: application/xml" -d @gridset.xml "http://localhost:8080/geowebcache/rest/gridsets/gridSet1.xml"
Or if using the GeoServer integrated version of GeoWebCache:
.. code-block:: xml
curl -v -u user:password -XPUT -H "Content-type: application/xml" -d @gridset.xml "http://localhost:8080/geoserver/gwc/rest/gridsets/gridSet1.xml"
Modify GridSet
++++++++++++++
Now, make some modifications to the gridset definition on the `gridset.xml` file:
.. code-block:: xml
EPSG:2163
2163
-2495667.977678598
-2223677.196231552
3291070.6104286816
959189.3312465074
false
2.5E7
1000000.0
100000.0
25000.0
5000.0
1000.0
1.0
2.8E-4
EPSG:2163:0
EPSG:2163:1
EPSG:2163:2
EPSG:2163:3
EPSG:2163:4
EPSG:2163:5
256
256
false
.. code-block:: xml
curl -v -u geowebcache:secured -XPUT -H "Content-type: application/xml" -d @gridset.xml "http://localhost:8080/geowebcache/rest/gridsets/gridSet1.xml"
Delete GridSet
++++++++++++++
Finally, to delete a gridset, use the HTTP DELETE method against the gridset configuration:
.. code-block:: xml
curl -v -u geowebcache:secured -XDELETE "http://localhost:8080/geoserver/gwc/rest/gridsets/gridSet1.xml"