This API is provided by plugin.restApi() and provides interface for Gerrit REST API.
getLoggedIn
repoApi.getLoggedIn()
Get user logged in status.
-
None
-
Promise<boolean>
getVersion
repoApi.getVersion()
Get server version.
-
None
-
Promise<string>
getConfig
repoApi.getConfig()
Returns the host config as a ServerInfo object.
-
None
-
Promise<ServerInfo>
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.
-
url String URL without base path or plugin prefix.
-
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.
-
url String URL without base path or plugin prefix.
-
opt_payload (optional) Object Payload to be sent with the request.
-
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.
-
url String URL without base path or plugin prefix.
-
opt_payload (optional) Object Payload to be sent with the request.
-
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.
-
url String URL without base path or plugin prefix.
-
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.
-
method String HTTP method.
-
url String URL without base path or plugin prefix.
-
opt_payload (optional) Object Respected for POST and PUT only.
-
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.
-
method String HTTP method.
-
url String URL without base path or plugin prefix.
-
opt_payload (optional) Object Respected for POST and PUT only.
-
Promise<Response> Fetch API’s Response object.