| Edwin Kempin | d0a6392 | 2013-01-23 16:32:59 +0100 | [diff] [blame] | 1 | Gerrit Code Review - '/projects/' REST API |
| 2 | ========================================== |
| 3 | |
| 4 | This page describes the project related REST endpoints. |
| 5 | Please also take note of the general information on the |
| 6 | link:rest-api.html[REST API]. |
| 7 | |
| 8 | Endpoints |
| 9 | --------- |
| 10 | |
| Edwin Kempin | 82d3037 | 2013-02-04 08:49:34 +0100 | [diff] [blame] | 11 | GET /projects/ (List Projects) |
| 12 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| Edwin Kempin | d0a6392 | 2013-01-23 16:32:59 +0100 | [diff] [blame] | 13 | Lists the projects accessible by the caller. This is the same as |
| 14 | using the link:cmd-ls-projects.html[ls-projects] command over SSH, |
| 15 | and accepts the same options as query parameters. |
| 16 | |
| Edwin Kempin | 51a6dc9 | 2013-02-04 15:43:59 +0100 | [diff] [blame^] | 17 | As result a map is returned that maps the project names to |
| 18 | link:#project-info[ProjectInfo] entries. The entries in the map are sorted |
| 19 | by project name. |
| 20 | |
| Edwin Kempin | d0a6392 | 2013-01-23 16:32:59 +0100 | [diff] [blame] | 21 | ---- |
| 22 | GET /projects/?d HTTP/1.0 |
| 23 | |
| 24 | HTTP/1.1 200 OK |
| 25 | Content-Disposition: attachment |
| 26 | Content-Type: application/json;charset=UTF-8 |
| 27 | |
| 28 | )]}' |
| 29 | { |
| 30 | "external/bison": { |
| 31 | "kind": "gerritcodereview#project", |
| 32 | "id": "external%2Fbison", |
| 33 | "description": "GNU parser generator" |
| 34 | }, |
| 35 | "external/gcc": { |
| 36 | "kind": "gerritcodereview#project", |
| 37 | "id": "external%2Fgcc", |
| 38 | }, |
| 39 | "external/openssl": { |
| 40 | "kind": "gerritcodereview#project", |
| 41 | "id": "external%2Fopenssl", |
| 42 | "description": "encryption\ncrypto routines" |
| 43 | }, |
| 44 | "test": { |
| 45 | "kind": "gerritcodereview#project", |
| 46 | "id": "test", |
| 47 | "description": "\u003chtml\u003e is escaped" |
| 48 | } |
| 49 | } |
| 50 | ---- |
| 51 | |
| Edwin Kempin | a64c4b9 | 2013-01-23 11:30:40 +0100 | [diff] [blame] | 52 | .Get all projects with their description |
| 53 | **** |
| 54 | get::/projects/?d |
| 55 | **** |
| 56 | |
| Edwin Kempin | d0a6392 | 2013-01-23 16:32:59 +0100 | [diff] [blame] | 57 | [[suggest-projects]] |
| 58 | The `/projects/` URL also accepts a prefix string in the `p` parameter. |
| 59 | This limits the results to those projects that start with the specified |
| 60 | prefix. |
| 61 | List all projects that start with `platform/`: |
| 62 | ---- |
| 63 | GET /projects/?p=platform%2F HTTP/1.0 |
| 64 | |
| 65 | HTTP/1.1 200 OK |
| 66 | Content-Disposition: attachment |
| 67 | Content-Type: application/json;charset=UTF-8 |
| 68 | |
| 69 | )]}' |
| 70 | { |
| 71 | "platform/drivers": { |
| 72 | "kind": "gerritcodereview#project", |
| 73 | "id": "platform%2Fdrivers", |
| 74 | }, |
| 75 | "platform/tools": { |
| 76 | "kind": "gerritcodereview#project", |
| 77 | "id": "platform%2Ftools", |
| 78 | } |
| 79 | } |
| 80 | ---- |
| 81 | E.g. this feature can be used by suggestion client UI's to limit results. |
| 82 | |
| Edwin Kempin | 82d3037 | 2013-02-04 08:49:34 +0100 | [diff] [blame] | 83 | GET /projects/*/dashboards/ (List Dashboards) |
| 84 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| Edwin Kempin | d0a6392 | 2013-01-23 16:32:59 +0100 | [diff] [blame] | 85 | List custom dashboards for a project. |
| 86 | |
| 87 | The `/projects/{name}/dashboards/` URL expects the a URL encoded |
| 88 | project name as part of the URL. If name contains / the correct |
| 89 | encoding is to use `%2F`. |
| 90 | |
| 91 | List all dashboards for the `work/my-project` project: |
| 92 | ---- |
| 93 | GET /projects/work%2Fmy-project/dashboards/ HTTP/1.0 |
| 94 | |
| 95 | HTTP/1.1 200 OK |
| 96 | Content-Disposition: attachment |
| 97 | Content-Type: application/json;charset=UTF-8 |
| 98 | |
| 99 | )]}' |
| 100 | [ |
| 101 | { |
| 102 | "kind": "gerritcodereview#dashboard", |
| 103 | "id": "main:closed", |
| 104 | "ref": "main", |
| 105 | "path": "closed", |
| 106 | "description": "Merged and abandoned changes in last 7 weeks", |
| 107 | "url": "/dashboard/?title\u003dClosed+changes\u0026Merged\u003dstatus:merged+age:7w\u0026Abandoned\u003dstatus:abandoned+age:7w", |
| 108 | "default": true, |
| 109 | "title": "Closed changes", |
| 110 | "sections": [ |
| 111 | { |
| 112 | "name": "Merged", |
| 113 | "query": "status:merged age:7w" |
| 114 | }, |
| 115 | { |
| 116 | "name": "Abandoned", |
| 117 | "query": "status:abandoned age:7w" |
| 118 | } |
| 119 | ] |
| 120 | } |
| 121 | ] |
| 122 | ---- |
| 123 | |
| Edwin Kempin | a64c4b9 | 2013-01-23 11:30:40 +0100 | [diff] [blame] | 124 | .Get all dashboards of the 'All-Projects' project |
| 125 | **** |
| 126 | get::/projects/All-Projects/dashboards/ |
| 127 | **** |
| 128 | |
| Edwin Kempin | d0a6392 | 2013-01-23 16:32:59 +0100 | [diff] [blame] | 129 | To retrieve only the default dashboard, add `default` to the URL: |
| 130 | ---- |
| 131 | GET /projects/work%2Fmy-project/dashboards/default HTTP/1.0 |
| 132 | |
| 133 | HTTP/1.1 200 OK |
| 134 | Content-Disposition: attachment |
| 135 | Content-Type: application/json;charset=UTF-8 |
| 136 | |
| 137 | )]}' |
| 138 | { |
| 139 | "kind": "gerritcodereview#dashboard", |
| 140 | "id": "main:closed", |
| 141 | "ref": "main", |
| 142 | "path": "closed", |
| 143 | "default": true, |
| 144 | ... |
| 145 | } |
| 146 | ---- |
| 147 | |
| Edwin Kempin | 51a6dc9 | 2013-02-04 15:43:59 +0100 | [diff] [blame^] | 148 | [[json-entities]] |
| 149 | JSON Entities |
| 150 | ------------- |
| 151 | |
| 152 | [[project-info]] |
| 153 | ProjectInfo |
| 154 | ~~~~~~~~~~~ |
| 155 | The `ProjectInfo` entity contains information about a project. |
| 156 | |
| 157 | [options="header",width="50%",cols="1,^2,4"] |
| 158 | |=========================== |
| 159 | |Field Name ||Description |
| 160 | |`kind` ||`gerritcodereview#project` |
| 161 | |`id` ||The URL encoded project name. |
| 162 | |`name` | |
| 163 | not set if returned in a map where the project name is used as map key| |
| 164 | The name of the project. |
| 165 | |`parent` |optional, + |
| 166 | not set for the root project| |
| 167 | The name of the parent project. + |
| 168 | `?-<n>` if the parent project is not visible (`<n>` is a number which |
| 169 | is increased for each non-visible project). |
| 170 | |`description` |optional|The description of the project. |
| 171 | |`branches` |optional|Map of branch names to HEAD revisions. |
| 172 | |=========================== |
| 173 | |
| Edwin Kempin | d0a6392 | 2013-01-23 16:32:59 +0100 | [diff] [blame] | 174 | |
| 175 | GERRIT |
| 176 | ------ |
| 177 | Part of link:index.html[Gerrit Code Review] |