/**
* Returns a specific release from the specified repository.
*
* @param owner the repository's owner
* @param repo the repository's name
* @param id the id of the release to retrieve
* @return An {@link Optional} that contains the specified release if it could be found.
* @throws IOException if an IO error occurs while communicating with GitHub.
* @throws URISyntaxException if the crafted URI is incorrect.
*/
public Optional<GithubRelease> getRelease(String owner, String repo, String id) throws IOException, URISyntaxException {
URIBuilder requestUrl = new URIBuilder()
.setScheme(URL_PROTOCOL)
.setHost(GITHUB_API_HOSTNAME)
.setPath("/repos/" + owner + "/" + repo + "/releases/" + id);
logger.debug(() -> "requestUrl = " + requestUrl);
HttpGet httpget = new HttpGet(requestUrl.build());
return Optional.ofNullable(httpClient.execute(httpget, new AbstractResponseHandler<GithubRelease>() {
@Override
public GithubRelease handleEntity(HttpEntity entity) throws IOException {
return gson.fromJson(EntityUtils.toString(entity), GithubRelease.class);
}
}));
}
GithubApi.java 文件源码
java
阅读 22
收藏 0
点赞 0
评论 0
项目:binjr
作者:
评论列表
文章目录