summaryrefslogtreecommitdiffstats
path: root/Documentation/pg-plugin-rest-api.txt
blob: 70487ef584dcde0bb22b6950aa071e6199053ef0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
= Gerrit Code Review - Repo admin customization API

This API is provided by link:pg-plugin-dev.html#plugin-rest-api[plugin.restApi()]
and provides interface for Gerrit REST API.

== getLoggedIn
`repoApi.getLoggedIn()`

Get user logged in status.

.Params
- None

.Returns
- Promise<boolean>

== getVersion
`repoApi.getVersion()`

Get server version.

.Params
- None

.Returns
- Promise<string>

== get
`repoApi.get(url)`

Issues a GET REST API call to the URL, returns Promise that is resolved to
parsed response on success. Returned Promise is rejected on network error.

.Params
- *url* String URL without base path or plugin prefix.

.Returns
- Promise<Object> Parsed response.

== post
`repoApi.post(url, opt_payload)`

Issues a POST REST API call to the URL, returns Promise that is resolved to
parsed response on success. Returned Promise is rejected on network error.

.Params
- *url* String URL without base path or plugin prefix.
- *opt_payload* (optional) Object Payload to be sent with the request.

.Returns
- Promise<Object> Parsed response.

== put
`repoApi.put(url, opt_payload)`

Issues a PUT REST API call to the URL, returns Promise that is resolved to
parsed response on success. Returned Promise is rejected on network error.

.Params
- *url* String URL without base path or plugin prefix.
- *opt_payload* (optional) Object Payload to be sent with the request.

.Returns
- Promise<Object> Parsed response.

== delete
`repoApi.delete(url)`

Issues a DELETE REST API call to the URL, returns Promise that is resolved to
parsed response on HTTP 204, and rejected otherwise.

.Params
- *url* String URL without base path or plugin prefix.

.Returns
- Promise<Response> Fetch API's Response object.

== send
`repoApi.send(method, url, opt_payload)`

Send payload and parse the response, if request succeeds. Returned Promise is
rejected with detailed message or HTTP error code on network error.

.Params
- *method* String HTTP method.
- *url* String URL without base path or plugin prefix.
- *opt_payload* (optional) Object Respected for POST and PUT only.

.Returns
- Promise<Object> Parsed response.

== fetch
`repoApi.fetch(method, url, opt_payload)`

Send payload and return native Response. This method is for low-level access, to
implement custom error handling and parsing.

.Params
- *method* String HTTP method.
- *url* String URL without base path or plugin prefix.
- *opt_payload* (optional) Object Respected for POST and PUT only.

.Returns
- Promise<Response> Fetch API's Response object.