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