REST API /accounts/self/capabilities

This JSON end point can be used by a client to determine global
server capabilities for the user, for example common names like
"createProject" or "createGroup".

The q parameter can be used to filter the set of capabilities to be
smaller than the set recognized by this version of Gerrit. Filtering
may decrease response time by avoiding looking at every possible
alternative for the caller.

Most results are boolean, and a field is only present when its
value is true. queryLimit is a range and is presented as a nested
JSON object with min and max members.

$ curl --user $USER --digest 'http://localhost:8080/a/accounts/self/capabilities?format=JSON'
)]}'
{
  "administrateServer": true,
  "queryLimit": {
    "min": 0,
    "max": 500
  },
  "createAccount": true,
  "createGroup": true,
  "createProject": true,
  "killTask": true,
  "viewCaches": true,
  "flushCaches": true,
  "viewConnections": true,
  "viewQueue": true,
  "startReplication": true
}

Change-Id: I4052ade1da986ee409cc0d532e872211b4301f2d
This commit is contained in:
Shawn O. Pearce
2012-04-05 11:03:56 -07:00
parent 805a6f0b17
commit e016933846
7 changed files with 321 additions and 18 deletions

View File

@@ -55,8 +55,53 @@ save on network transfer time for larger responses.
Endpoints
---------
List Projects: /projects/
~~~~~~~~~~~~~~~~~~~~~~~~~
[[accounts_self_capabilities]]
/accounts/self/capabilities (Account Capabilities)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Returns the global capabilities (such as createProject or
createGroup) that are enabled for the calling user. This can be used
by UI tools to discover if administrative features are available
to the caller, so they can hide (or show) relevant UI actions.
----
GET /accounts/self/capabilities?format=JSON HTTP/1.0
)]}'
{
"queryLimit": {
"min": 0,
"max": 500
}
}
----
Administrator that has authenticated with digest authentication:
----
GET /a/accounts/self/capabilities?format=JSON HTTP/1.0
Authorization: Digest username="admin", realm="Gerrit Code Review", nonce="...
)]}'
{
"administrateServer": true,
"queryLimit": {
"min": 0,
"max": 500
},
"createAccount": true,
"createGroup": true,
"createProject": true,
"killTask": true,
"viewCaches": true,
"flushCaches": true,
"viewConnections": true,
"viewQueue": true,
"startReplication": true
}
----
[[projects]]
/projects/ (List Projects)
~~~~~~~~~~~~~~~~~~~~~~~~~~
Lists the projects accessible by the caller. This is the same as
using the link:cmd-ls-projects.html[ls-projects] command over SSH,
and accepts the same options as query parameters.