Viktar Donich | bc8088e | 2018-04-23 15:29:57 -0700 | [diff] [blame] | 1 | = Gerrit Code Review - Repo admin customization API |
| 2 | |
| 3 | This API is provided by link:pg-plugin-dev.html#plugin-rest-api[plugin.restApi()] |
| 4 | and provides interface for Gerrit REST API. |
| 5 | |
| 6 | == getLoggedIn |
| 7 | `repoApi.getLoggedIn()` |
| 8 | |
| 9 | Get user logged in status. |
| 10 | |
| 11 | .Params |
| 12 | - None |
| 13 | |
| 14 | .Returns |
| 15 | - Promise<boolean> |
| 16 | |
| 17 | == getVersion |
| 18 | `repoApi.getVersion()` |
| 19 | |
| 20 | Get server version. |
| 21 | |
| 22 | .Params |
| 23 | - None |
| 24 | |
| 25 | .Returns |
| 26 | - Promise<string> |
| 27 | |
Thomas Draebing | 996639a | 2019-10-24 17:09:28 +0200 | [diff] [blame] | 28 | == getConfig |
| 29 | `repoApi.getConfig()` |
| 30 | |
| 31 | Get server config. |
| 32 | |
| 33 | .Params |
| 34 | - None |
| 35 | |
| 36 | .Returns |
| 37 | - Promise<Object> |
| 38 | |
Viktar Donich | bc8088e | 2018-04-23 15:29:57 -0700 | [diff] [blame] | 39 | == get |
| 40 | `repoApi.get(url)` |
| 41 | |
| 42 | Issues a GET REST API call to the URL, returns Promise that is resolved to |
| 43 | parsed response on success. Returned Promise is rejected on network error. |
| 44 | |
| 45 | .Params |
| 46 | - *url* String URL without base path or plugin prefix. |
| 47 | |
| 48 | .Returns |
| 49 | - Promise<Object> Parsed response. |
| 50 | |
| 51 | == post |
| 52 | `repoApi.post(url, opt_payload)` |
| 53 | |
| 54 | Issues a POST REST API call to the URL, returns Promise that is resolved to |
| 55 | parsed response on success. Returned Promise is rejected on network error. |
| 56 | |
| 57 | .Params |
| 58 | - *url* String URL without base path or plugin prefix. |
| 59 | - *opt_payload* (optional) Object Payload to be sent with the request. |
| 60 | |
| 61 | .Returns |
| 62 | - Promise<Object> Parsed response. |
| 63 | |
| 64 | == put |
| 65 | `repoApi.put(url, opt_payload)` |
| 66 | |
| 67 | Issues a PUT REST API call to the URL, returns Promise that is resolved to |
| 68 | parsed response on success. Returned Promise is rejected on network error. |
| 69 | |
| 70 | .Params |
| 71 | - *url* String URL without base path or plugin prefix. |
| 72 | - *opt_payload* (optional) Object Payload to be sent with the request. |
| 73 | |
| 74 | .Returns |
| 75 | - Promise<Object> Parsed response. |
| 76 | |
| 77 | == delete |
| 78 | `repoApi.delete(url)` |
| 79 | |
| 80 | Issues a DELETE REST API call to the URL, returns Promise that is resolved to |
| 81 | parsed response on HTTP 204, and rejected otherwise. |
| 82 | |
| 83 | .Params |
| 84 | - *url* String URL without base path or plugin prefix. |
| 85 | |
| 86 | .Returns |
| 87 | - Promise<Response> Fetch API's Response object. |
| 88 | |
| 89 | == send |
| 90 | `repoApi.send(method, url, opt_payload)` |
| 91 | |
| 92 | Send payload and parse the response, if request succeeds. Returned Promise is |
| 93 | rejected with detailed message or HTTP error code on network error. |
| 94 | |
| 95 | .Params |
| 96 | - *method* String HTTP method. |
| 97 | - *url* String URL without base path or plugin prefix. |
| 98 | - *opt_payload* (optional) Object Respected for POST and PUT only. |
| 99 | |
| 100 | .Returns |
| 101 | - Promise<Object> Parsed response. |
| 102 | |
| 103 | == fetch |
| 104 | `repoApi.fetch(method, url, opt_payload)` |
| 105 | |
| 106 | Send payload and return native Response. This method is for low-level access, to |
| 107 | implement custom error handling and parsing. |
| 108 | |
| 109 | .Params |
| 110 | - *method* String HTTP method. |
| 111 | - *url* String URL without base path or plugin prefix. |
| 112 | - *opt_payload* (optional) Object Respected for POST and PUT only. |
| 113 | |
| 114 | .Returns |
| 115 | - Promise<Response> Fetch API's Response object. |