.. _rest.diskquota: Disk Quota REST API =================== The REST API for Disk Quota management provides a RESTful interface through which clients can configure the disk usage limits and expiration policies for a GeoWebCache instance through simple HTTP calls. Operations ---------- ``/diskquota.`` .. list-table:: :header-rows: 1 * - Method - Action - Return Code - Formats * - GET - Return the global disk quota configuration - 200 - XML, JSON * - POST - - 405 - * - PUT - Modify the global disk quota configuration - 200 - XML, JSON * - DELETE - - 405 - *Representations*: - :download:`XML ` - :download:`JSON ` Disk quota 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. Getting the current Disk Quota configuration ++++++++++++++++++++++++++++++++++++++++++++ The following obtains the current disk quota configuration in XML format: .. code-block:: bash curl -u geowebcache:secured -v -XGET http://localhost:8080/geowebcache/rest/diskquota.xml The response should look like:: < HTTP/1.1 200 OK < Date: Mon, 21 Mar 2011 13:50:49 GMT < Server: Noelios-Restlet-Engine/1.0..8 < Content-Type: text/xml; charset=ISO-8859-1 < Content-Length: 422 < true 5 SECONDS 5 LRU 100 MiB The following obtains the current disk quota configuration in JSON format: .. code-block:: bash curl -u geowebcache:secured -v -XGET http://localhost:8080/geowebcache/rest/diskquota.json The response should look like:: < HTTP/1.1 200 OK < Date: Mon, 21 Mar 2011 13:53:42 GMT < Server: Noelios-Restlet-Engine/1.0..8 < Content-Type: application/json; charset=ISO-8859-1 < Content-Length: 241 < * Connection #0 to host localhost left intact * Closing connection #0 {"gwcQuotaConfiguration":{"maxConcurrentCleanUps":5,"cacheCleanUpFrequency":5,"globalExpirationPolicyName":"LRU","globalQuota":{"value":"100","units":"MiB"},"cacheCleanUpUnits":"SECONDS"}} Changing Disk Quota configuration +++++++++++++++++++++++++++++++++ Request body for PUT can contain only the desired properties to be modified, and a diff will be applied to the current configuration. For example: The following will only change the maxConcurrentCleanups property in XML format: 2 The following will only change the enabled and globalQuota properties in JSON format: {"gwcQuotaConfiguration":{"enabled":true,"globalQuota":{"value":"100","units":"MiB"}} (valid values for "units" are ) Invalid XML request: ^^^^^^^^^^^^^^^^^^^^ Invalid parameter (here maxConcurrentCleanUps must be > 0) produce a 400 response code and contains the error message as plain text: .. code-block:: bash curl -v -u geowebcache:secured "http://localhost:8090/geowebcache/rest/diskquota.xml" -X PUT -d "-1" :: < HTTP/1.1 400 Bad Request < Date: Fri, 18 Mar 2011 20:53:26 GMT < Server: Noelios-Restlet-Engine/1.0..8 < Content-Type: text/plain; charset=ISO-8859-1 < Content-Length: 53 < * Connection #0 to host localhost left intact * Closing connection #0 maxConcurrentCleanUps shall be a positive integer: -1 Invalid JSON request: ^^^^^^^^^^^^^^^^^^^^^ .. code-block:: bash curl -v -u geowebcache:secured "http://localhost:8090/geowebcache/rest/diskquota.json" -X PUT -d "{"gwcQuotaConfiguration":{"globalQuota":{"value":"100","units":"ZZiB"}}}" :: < HTTP/1.1 400 Bad Request < Date: Fri, 18 Mar 2011 20:56:23 GMT < Server: Noelios-Restlet-Engine/1.0..8 < Content-Type: text/plain; charset=ISO-8859-1 < Content-Length: 601 < No enum const class org.geowebcache.diskquota.storage.StorageUnit.ZZiB : No enum const class org.geowebcache.diskquota.storage.StorageUnit.ZZiB ---- Debugging information ---- message : No enum const class org.geowebcache.diskquota.storage.StorageUnit.ZZiB cause-exception : java.lang.IllegalArgumentException cause-message : No enum const class org.geowebcache.diskquota.storage.StorageUnit.ZZiB class : org.geowebcache.diskquota.DiskQuotaConfig required-type : org.geowebcache.diskquota.storage.Quota line number : -1 * Connection #0 to host localhost left intact * Closing connection #0 Valid XML requests: ^^^^^^^^^^^^^^^^^^^ (note upon successfully applying the changes the full config in the given format is returned) Change enabled and globalQuota in XML format: .. code-block:: bash curl -v -u geowebcache:secured "http://localhost:8090/geowebcache/rest/diskquota.xml" -X PUT -d "true100GiB" :: < HTTP/1.1 200 OK < Date: Fri, 18 Mar 2011 20:59:31 GMT < Server: Noelios-Restlet-Engine/1.0..8 < Content-Type: text/xml; charset=ISO-8859-1 < Content-Length: 422 < true 5 SECONDS 5 LFU 100 GiB Valid JSON request: ^^^^^^^^^^^^^^^^^^^ Change globalQuota and expirationPolicyName in JSON format: .. code-block:: bash curl -v -u geowebcache:secured "http://localhost:8090/geowebcache/rest/diskquota.json" -X PUT -d "{"gwcQuotaConfiguration":{"globalQuota":{"value":"100","units":"MiB"},"globalExpirationPolicyName":"LRU"}}" :: < HTTP/1.1 200 OK < Date: Fri, 18 Mar 2011 21:02:20 GMT < Server: Noelios-Restlet-Engine/1.0..8 < Content-Type: application/json; charset=ISO-8859-1 < Content-Length: 241 < * Connection #0 to host localhost left intact * Closing connection #0 {"gwcQuotaConfiguration":{"maxConcurrentCleanUps":5,"cacheCleanUpFrequency":5,"globalExpirationPolicyName":"LRU","globalQuota":{"value":"100","units":"MiB"},"cacheCleanUpUnits":"SECONDS","layerQuotas":[]}}