Permalink
Browse files

closes #108: docuement adding, modifying, and deleting layers through…

… the REST API
  • Loading branch information...
1 parent c7f055c commit f80835456c735b4be6c9e5100718557059e9ec3b @groldan committed Apr 26, 2012
@@ -63,7 +63,8 @@ document. These codes are described in detail by the `http specification <http:/
.. toctree::
:maxdepth: 1
-
+
+ layers.rst
seed.rst
diskquota.rst
@@ -0,0 +1,128 @@
+.. _rest.layers:
+
+Managing Layers through the REST API
+====================================
+
+The REST API for Layer management provides a RESTful interface through which clients can
+programatically add, modify, or remove cached Layers.
+
+Operations
+----------
+
+``/rest/seed/layers/<layer>.xml``
+
+.. list-table::
+ :header-rows: 1
+
+ * - Method
+ - Action
+ - Return Code
+ - Formats
+ * - GET
+ - Return the XML representation of the Layer
+ - 200
+ - XML
+ * - POST
+ - Modify the definition/configuration of a Layer
+ - 200
+ - XML
+ * - PUT
+ - Add a new Layer
+ - 200
+ - XML
+ * - DELETE
+ - Delete a Layer
+ - 200
+ -
+
+*Representations*:
+
+- :download:`XML minimal <representations/wmslayer_minimal.xml.txt>`
+- :download:`XML <representations/wmslayer.xml.txt>`
+
+Note: JSON representation is intentionally left aside as the library used for JSON marshaling has issues with multi-valued properties such as `parameterFilters`.
+
+REST API for Layers, cURL Examples
+----------------------------------
+
+The examples in this section use the `cURL <http://curl.haxx.se/>`_
+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 Layer
++++++++++
+
+Sample request:
+
+Given a `layer.xml` file as the following:
+
+.. code-block:: xml
+
+ <wmsLayer>
+ <name>layer1</name>
+ <mimeFormats>
+ <string>image/png</string>
+ </mimeFormats>
+ <gridSubsets>
+ <gridSubset>
+ <gridSetName>EPSG:900913</gridSetName>
+ </gridSubset>
+ </gridSubsets>
+ <wmsUrl>
+ <string>http://localhost:8080/geoserver/wms</string>
+ </wmsUrl>
+ <wmsLayers>topp:states</wmsLayers>
+ </wmsLayer>
+
+.. code-block:: xml
+
+ curl -v -u geowebcache:secured -XPUT -H "Content-type: text/xml" -d @layer.xml "http://localhost:8080/geowebcache/rest/layers/layer1.xml"
+
+Note that the addressed resource ``layer1.xml``, without the ``.xml`` extension, must match the name of the layer in the xml representation.
+
+
+Modify Layer
+++++++++++++
+
+Now, make some modifications to the layer definition on the `layer.xml` file:
+
+
+.. code-block:: xml
+
+ <wmsLayer>
+ <name>layer1</name>
+ <mimeFormats>
+ <string>image/png</string>
+ <string>image/jpeg</string>
+ <string>image/gif</string>
+ </mimeFormats>
+ <gridSubsets>
+ <gridSubset>
+ <gridSetName>EPSG:900913</gridSetName>
+ </gridSubset>
+ <gridSubset>
+ <gridSetName>EPSG:4326</gridSetName>
+ </gridSubset>
+ </gridSubsets>
+ <wmsUrl>
+ <string>http://localhost:8080/geoserver/wms</string>
+ </wmsUrl>
+ <wmsLayers>topp:states,nurc:Img_Sample</wmsLayers>
+ </wmsLayer>
+
+And use the HTTP POST method instead:
+
+.. code-block:: xml
+
+ curl -v -u geowebcache:secured -XPOST -H "Content-type: text/xml" -d @layer.xml "http://localhost:8080/geowebcache/rest/layers/layer1.xml"
+
+Delete Layer
+++++++++++++
+
+Finally, to delete a layer, use the HTTP DELETE method against the layer resource:
+
+.. code-block:: xml
+
+ curl -v -u geowebcache:secured -XDELETE "http://localhost:8080/geowebcache/rest/layers/layer1.xml"
+
@@ -0,0 +1,38 @@
+<wmsLayer>
+ <name>img states</name>
+ <metaInformation>
+ <title>Nicer title for Image States</title>
+ <description>This is a description. Fascinating.</description>
+ </metaInformation>
+ <mimeFormats>
+ <string>image/gif</string>
+ <string>image/jpeg</string>
+ <string>image/png</string>
+ <string>image/png8</string>
+ </mimeFormats>
+ <gridSubsets>
+ <gridSubset>
+ <gridSetName>EPSG:4326</gridSetName>
+ <extent>
+ <coords>
+ <double>-129.6</double>
+ <double>3.45</double>
+ <double>-62.1</double>
+ <double>70.9</double>
+ </coords>
+ </extent>
+ </gridSubset>
+ </gridSubsets>
+ <expireCacheList>
+ <expirationRule minZoom="0" expiration="60" />
+ </expireCacheList>
+ <expireClientsList>
+ <expirationRule minZoom="0" expiration="500" />
+ </expireClientsList>
+ <wmsUrl>
+ <string>http://demo.opengeo.org/geoserver/wms</string>
+ </wmsUrl>
+ <wmsLayers>nurc:Img_Sample,topp:states</wmsLayers>
+ <transparent>false</transparent>
+ <bgColor>0x0066FF</bgColor>
+</wmsLayer>
@@ -0,0 +1,15 @@
+<wmsLayer>
+ <name>layer1</name>
+ <mimeFormats>
+ <string>image/png</string>
+ </mimeFormats>
+ <gridSubsets>
+ <gridSubset>
+ <gridSetName>EPSG:900913</gridSetName>
+ </gridSubset>
+ </gridSubsets>
+ <wmsUrl>
+ <string>http://localhost:8080/geoserver/wms</string>
+ </wmsUrl>
+ <wmsLayers>topp:states</wmsLayers>
+</wmsLayer>

0 comments on commit f808354

Please sign in to comment.