Support listing of cache names via REST

Change-Id: Ibab22bfa1e69f87a5918b2f250e22f0bcce132d9
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
diff --git a/Documentation/rest-api-config.txt b/Documentation/rest-api-config.txt
index 3639551..8a980e2 100644
--- a/Documentation/rest-api-config.txt
+++ b/Documentation/rest-api-config.txt
@@ -263,6 +263,82 @@
   }
 ----
 
+It is possible to get different output formats by specifying the
+`format` option:
+
+* `LIST`:
++
+Returns the cache names as JSON list.
++
+The cache names are alphabetically sorted.
++
+.Request
+----
+  GET /config/server/caches/?format=LIST HTTP/1.0
+----
++
+.Response
+----
+  HTTP/1.1 200 OK
+  Content-Type: application/json;charset=UTF-8
+
+  )]}'
+  [
+    "accounts",
+    "accounts_byemail",
+    "accounts_byname",
+    "adv_bases",
+    "change_kind",
+    "changes",
+    "conflicts",
+    "diff",
+    "diff_intraline",
+    "git_tags",
+    "groups",
+    "groups_byinclude",
+    "groups_byname",
+    "groups_byuuid",
+    "groups_external",
+    "groups_members",
+    "permission_sort",
+    "plugin_resources",
+    "project_list",
+    "projects",
+    "quota-repo_size",
+    "sshkeys",
+    "web_sessions"
+  ]
+----
+
+* `TEXT_LIST`:
++
+Returns the cache names as a UTF-8 list that is base64 encoded. The
+cache names are delimited by '\n'.
++
+The cache names are lexicographically sorted.
++
+.Request
+----
+  GET /config/server/caches/?format=TEXT_LIST HTTP/1.0
+----
++
+.Response
+----
+  HTTP/1.1 200 OK
+  Content-Type: text/plain;charset=UTF-8
+
+  YWNjb3VudHMKYW...ViX3Nlc3Npb25z
+----
++
+E.g. this could be used to flush all caches:
++
+----
+  for c in $(curl --digest --user jdoe:TNAuLkXsIV7w http://gerrit/a/config/server/caches/?format=TEXT_LIST | base64 -D)
+  do
+    curl --digest --user jdoe:TNAuLkXsIV7w -X POST http://gerrit/a/config/server/caches/$c/flush
+  done
+----
+
 [[get-cache]]
 === Get Cache
 --