• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java GitHubRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.egit.github.core.client.GitHubRequest的典型用法代码示例。如果您正苦于以下问题:Java GitHubRequest类的具体用法?Java GitHubRequest怎么用?Java GitHubRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GitHubRequest类属于org.eclipse.egit.github.core.client包,在下文中一共展示了GitHubRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: head

import org.eclipse.egit.github.core.client.GitHubRequest; //导入依赖的package包/类
/**
 * Gets a pair of HTTP connection and corresponding response from a header-only API call
 *
 * @param request for the API call
 * @return a pair of HTTP connection and response for the API call
 * @throws IOException
 */
public ImmutablePair<HttpURLConnection, GitHubResponse> head(GitHubRequest request) throws IOException {
    HttpURLConnection httpRequest = createHead(request.generateUri());
    String accept = request.getResponseContentType();
    if (accept != null) {
        httpRequest.setRequestProperty(HEADER_ACCEPT, accept);
    }
    logger.info(String.format("Requesting: %s %s",
                              httpRequest.getRequestMethod(), httpRequest.getURL().getFile()));

    final int code = httpRequest.getResponseCode();
    updateRateLimits(httpRequest);

    logger.info(String.format("%s responded with %d %s",
                              httpRequest.getURL().getPath(), code, httpRequest.getResponseMessage()));
    if (isOk(code) || code == HttpURLConnection.HTTP_NOT_MODIFIED || isEmpty(code)) {
        return new ImmutablePair<>(httpRequest, new GitHubResponse(httpRequest, null));
    }

    throw createException(getStream(httpRequest), code,
                          httpRequest.getResponseMessage());
}
 
开发者ID:HubTurbo,项目名称:HubTurbo,代码行数:29,代码来源:GitHubClientEx.java


示例2: getPagedEtags

import org.eclipse.egit.github.core.client.GitHubRequest; //导入依赖的package包/类
/**
 * Gets a list of ETags for all pages returned from an API request and
 * also return the connection used to get the ETags so that their last check time
 * can be recorded elsewhere
 *
 * @param request
 * @param client
 * @return a Optional list of ETags for all pages returned from an API request and
 * corresponding HTTP connection or an empty Optional if an error occurs
 */
private Optional<ImmutablePair<List<String>, HttpURLConnection>> getPagedEtags(
        GitHubRequest request, GitHubClientEx client) {

    PageHeaderIterator iter = new PageHeaderIterator(request, client, "ETag");
    List<String> etags = new ArrayList<>();
    HttpURLConnection connection = null;

    while (iter.hasNext()) {
        try {
            etags.add(Utility.stripQuotes(iter.next()));
            if (connection == null) {
                connection = iter.getLastConnection();
            }
        } catch (NoSuchPageException e) {
            logger.error("No such page exception at " + iter.getRequest().generateUri());
            return Optional.empty();
        }
    }

    return Optional.of(new ImmutablePair<>(etags, connection));
}
 
开发者ID:HubTurbo,项目名称:HubTurbo,代码行数:32,代码来源:UpdateService.java


示例3: get

import org.eclipse.egit.github.core.client.GitHubRequest; //导入依赖的package包/类
/**
 * Get response from URI and bind to specified type
 *
 * @param request
 * @return response
 * @throws java.io.IOException
 */
@Override
public GitHubResponse get(GitHubRequest request) throws IOException {
    HttpURLConnection httpRequest = createGet(request.generateUri());
    try {
        String accept = request.getResponseContentType();
        if (accept != null)
            httpRequest.setRequestProperty(HEADER_ACCEPT, accept);
        final int code = httpRequest.getResponseCode();
        updateRateLimits(httpRequest);
        if (isOk(code))
            return new GitHubResponse(httpRequest, getBody(request,
                    getStream(httpRequest)));
        if (isEmpty(code))
            return new GitHubResponse(httpRequest, null);
        throw createException(getStream(httpRequest), code,
                httpRequest.getResponseMessage());
    } catch (IOException e) {
        throw checkTwoFactorAuthError(httpRequest, e);
    }
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:28,代码来源:TwoFactorAuthClient.java


示例4: getMembership

import org.eclipse.egit.github.core.client.GitHubRequest; //导入依赖的package包/类
public TeamMembership getMembership(int id, String user) throws IOException {
	if (user == null)
		throw new IllegalArgumentException("User cannot be null"); //$NON-NLS-1$
	if (user.length() == 0)
		throw new IllegalArgumentException("User cannot be empty"); //$NON-NLS-1$

	StringBuilder uri = new StringBuilder(SEGMENT_TEAMS);
	uri.append('/').append(id);
	uri.append(SEGMENT_MEMBERSHIPS);
	uri.append('/').append(user);

	GitHubRequest request = createRequest();
	request.setUri(uri);
	request.setType(TeamMembership.class);
	return (TeamMembership) client.get(request).getBody();
}
 
开发者ID:tsangiotis,项目名称:JekyllForAndroid,代码行数:17,代码来源:TeamService.java


示例5: getCommit

import org.eclipse.egit.github.core.client.GitHubRequest; //导入依赖的package包/类
/**
 * Get commit with given SHA-1 from given repository
 *
 * @param repository
 * @param sha
 * @return repository commit
 * @throws IOException
 */
public RepositoryCommit getCommit(IRepositoryIdProvider repository,
		String sha) throws IOException {
	String id = getId(repository);
	if (sha == null)
		throw new IllegalArgumentException("Sha cannot be null"); //$NON-NLS-1$
	if (sha.length() == 0)
		throw new IllegalArgumentException("Sha cannot be empty"); //$NON-NLS-1$

	StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
	uri.append('/').append(id);
	uri.append(SEGMENT_COMMITS);
	uri.append('/').append(sha);
	GitHubRequest request = createRequest();
	request.setUri(uri);
	request.setType(RepositoryCommit.class);
	return (RepositoryCommit) client.get(request).getBody();
}
 
开发者ID:tsangiotis,项目名称:JekyllForAndroid,代码行数:26,代码来源:CommitService.java


示例6: compare

import org.eclipse.egit.github.core.client.GitHubRequest; //导入依赖的package包/类
/**
 * Compare base and head commits
 *
 * @param repository
 * @param base
 * @param head
 * @return commit compare
 * @throws IOException
 */
public RepositoryCommitCompare compare(IRepositoryIdProvider repository,
		String base, String head) throws IOException {
	String id = getId(repository);
	if (base == null)
		throw new IllegalArgumentException("Base cannot be null"); //$NON-NLS-1$
	if (base.length() == 0)
		throw new IllegalArgumentException("Base cannot be empty"); //$NON-NLS-1$

	if (head == null)
		throw new IllegalArgumentException("Head cannot be null"); //$NON-NLS-1$
	if (head.length() == 0)
		throw new IllegalArgumentException("Head cannot be empty"); //$NON-NLS-1$

	StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
	uri.append('/').append(id);
	uri.append(SEGMENT_COMPARE);
	uri.append('/').append(base).append("...").append(head); //$NON-NLS-1$
	GitHubRequest request = createRequest();
	request.setType(RepositoryCommitCompare.class);
	request.setUri(uri);
	return (RepositoryCommitCompare) client.get(request).getBody();
}
 
开发者ID:tsangiotis,项目名称:JekyllForAndroid,代码行数:32,代码来源:CommitService.java


示例7: getIssue

import org.eclipse.egit.github.core.client.GitHubRequest; //导入依赖的package包/类
private Issue getIssue(String repoId, String issueNumber)
		throws IOException {
	if (issueNumber == null)
		throw new IllegalArgumentException("Issue number cannot be null"); //$NON-NLS-1$
	if (issueNumber.length() == 0)
		throw new IllegalArgumentException("Issue number cannot be empty"); //$NON-NLS-1$

	StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
	uri.append('/').append(repoId);
	uri.append(SEGMENT_ISSUES);
	uri.append('/').append(issueNumber);
	GitHubRequest request = createRequest();
	request.setUri(uri);
	request.setType(Issue.class);
	return (Issue) client.get(request).getBody();
}
 
开发者ID:tsangiotis,项目名称:JekyllForAndroid,代码行数:17,代码来源:IssueService.java


示例8: getBlob

import org.eclipse.egit.github.core.client.GitHubRequest; //导入依赖的package包/类
/**
 * Get blob for given SHA-1
 *
 * @param repository
 * @param sha
 * @return blob
 * @throws IOException
 */
public Blob getBlob(IRepositoryIdProvider repository, String sha)
		throws IOException {
	final String id = getId(repository);
	if (sha == null)
		throw new IllegalArgumentException("SHA-1 cannot be null"); //$NON-NLS-1$
	if (sha.length() == 0)
		throw new IllegalArgumentException("SHA-1 cannot be empty"); //$NON-NLS-1$

	StringBuilder uri = new StringBuilder();
	uri.append(SEGMENT_REPOS);
	uri.append('/').append(id);
	uri.append(SEGMENT_GIT);
	uri.append(SEGMENT_BLOBS);
	uri.append('/').append(sha);
	GitHubRequest request = createRequest();
	request.setType(Blob.class);
	request.setUri(uri);
	return (Blob) client.get(request).getBody();
}
 
开发者ID:tsangiotis,项目名称:JekyllForAndroid,代码行数:28,代码来源:DataService.java


示例9: getTree

import org.eclipse.egit.github.core.client.GitHubRequest; //导入依赖的package包/类
/**
 * Get tree with given SHA-1
 *
 * @param repository
 * @param sha
 * @param recursive
 * @return tree
 * @throws IOException
 */
public Tree getTree(IRepositoryIdProvider repository, String sha,
		boolean recursive) throws IOException {
	final String id = getId(repository);
	if (sha == null)
		throw new IllegalArgumentException("SHA-1 cannot be null"); //$NON-NLS-1$
	if (sha.length() == 0)
		throw new IllegalArgumentException("SHA-1 cannot be empty"); //$NON-NLS-1$

	StringBuilder uri = new StringBuilder();
	uri.append(SEGMENT_REPOS);
	uri.append('/').append(id);
	uri.append(SEGMENT_GIT);
	uri.append(SEGMENT_TREES);
	uri.append('/').append(sha);
	GitHubRequest request = createRequest();
	request.setType(Tree.class);
	request.setUri(uri);
	if (recursive)
		request.setParams(Collections.singletonMap("recursive", "1")); //$NON-NLS-1$ //$NON-NLS-2$
	return (Tree) client.get(request).getBody();
}
 
开发者ID:tsangiotis,项目名称:JekyllForAndroid,代码行数:31,代码来源:DataService.java


示例10: createTree

import org.eclipse.egit.github.core.client.GitHubRequest; //导入依赖的package包/类
/**
 * Create tree
 *
 * @param repository
 * @param entries
 * @param baseTree
 * @return created tree
 * @throws IOException
 */
public Tree createTree(IRepositoryIdProvider repository,
		Collection<TreeEntry> entries, String baseTree) throws IOException {
	final String id = getId(repository);

	StringBuilder uri = new StringBuilder();
	uri.append(SEGMENT_REPOS);
	uri.append('/').append(id);
	uri.append(SEGMENT_GIT);
	uri.append(SEGMENT_TREES);
	GitHubRequest request = createRequest();
	request.setType(Tree.class);
	request.setUri(uri);
	Map<String, Object> params = new HashMap<String, Object>();
	if (entries != null)
		params.put("tree", entries.toArray()); //$NON-NLS-1$
	if (baseTree != null)
		params.put("base_tree", baseTree); //$NON-NLS-1$
	return client.post(uri.toString(), params, Tree.class);
}
 
开发者ID:tsangiotis,项目名称:JekyllForAndroid,代码行数:29,代码来源:DataService.java


示例11: getReference

import org.eclipse.egit.github.core.client.GitHubRequest; //导入依赖的package包/类
/**
 * Get reference with given name
 *
 * @param repository
 * @param name
 * @return reference
 * @throws IOException
 */
public Reference getReference(IRepositoryIdProvider repository, String name)
		throws IOException {
	final String id = getId(repository);
	if (name == null)
		throw new IllegalArgumentException("Name cannot be null"); //$NON-NLS-1$
	if (name.length() == 0)
		throw new IllegalArgumentException("Name cannot be empty"); //$NON-NLS-1$

	StringBuilder uri = new StringBuilder();
	uri.append(SEGMENT_REPOS);
	uri.append('/').append(id);
	uri.append(SEGMENT_GIT);
	if (!name.startsWith("refs/")) //$NON-NLS-1$
		uri.append(SEGMENT_REFS);
	uri.append('/').append(name);
	GitHubRequest request = createRequest();
	request.setType(Reference.class);
	request.setUri(uri);
	return (Reference) client.get(request).getBody();
}
 
开发者ID:tsangiotis,项目名称:JekyllForAndroid,代码行数:29,代码来源:DataService.java


示例12: getCommit

import org.eclipse.egit.github.core.client.GitHubRequest; //导入依赖的package包/类
/**
 * Get commit for given SHA-1
 *
 * @param repository
 * @param sha
 * @return commit
 * @throws IOException
 */
public Commit getCommit(IRepositoryIdProvider repository, String sha)
		throws IOException {
	final String id = getId(repository);
	if (sha == null)
		throw new IllegalArgumentException("SHA-1 cannot be null"); //$NON-NLS-1$
	if (sha.length() == 0)
		throw new IllegalArgumentException("SHA-1 cannot be empty"); //$NON-NLS-1$

	StringBuilder uri = new StringBuilder();
	uri.append(SEGMENT_REPOS);
	uri.append('/').append(id);
	uri.append(SEGMENT_GIT);
	uri.append(SEGMENT_COMMITS);
	uri.append('/').append(sha);
	GitHubRequest request = createRequest();
	request.setType(Commit.class);
	request.setUri(uri);
	return (Commit) client.get(request).getBody();
}
 
开发者ID:tsangiotis,项目名称:JekyllForAndroid,代码行数:28,代码来源:DataService.java


示例13: getTag

import org.eclipse.egit.github.core.client.GitHubRequest; //导入依赖的package包/类
/**
 * Get tag for given SHA-1
 *
 * @param repository
 * @param sha
 * @return tag
 * @throws IOException
 */
public Tag getTag(IRepositoryIdProvider repository, String sha)
		throws IOException {
	final String id = getId(repository);
	if (sha == null)
		throw new IllegalArgumentException("SHA-1 cannot be null"); //$NON-NLS-1$
	if (sha.length() == 0)
		throw new IllegalArgumentException("SHA-1 cannot be empty"); //$NON-NLS-1$

	StringBuilder uri = new StringBuilder();
	uri.append(SEGMENT_REPOS);
	uri.append('/').append(id);
	uri.append(SEGMENT_GIT);
	uri.append(SEGMENT_TAGS);
	uri.append('/').append(sha);
	GitHubRequest request = createRequest();
	request.setType(Tag.class);
	request.setUri(uri);
	return (Tag) client.get(request).getBody();
}
 
开发者ID:tsangiotis,项目名称:JekyllForAndroid,代码行数:28,代码来源:DataService.java


示例14: checkVerifedEmail

import org.eclipse.egit.github.core.client.GitHubRequest; //导入依赖的package包/类
public boolean checkVerifedEmail(String accessToken) throws Exception
{
	RawGitHubClient client=new RawGitHubClient();
	client.setOAuth2Token(accessToken);
	GitHubRequest request=new GitHubRequest();
	request.setType(List.class);
	request.setUri("/user/emails");
	String result=FileUtils.dumpInputStreamIntoString(client.getStream(request),GitHubConstants.UTF8ENCODING);
	System.out.println(result);
	if(result.contains("\"verified\":true"))
	{
		return true;
	}
	else
	{
		return false;
	}
}
 
开发者ID:GitHubPager,项目名称:GitHubPager,代码行数:19,代码来源:PageManager.java


示例15: getRawBlobAsStream

import org.eclipse.egit.github.core.client.GitHubRequest; //导入依赖的package包/类
public InputStream getRawBlobAsStream(IRepositoryIdProvider repository, String sha)
		throws IOException {
	final String id = getId(repository);
	if (sha == null)
		throw new IllegalArgumentException("SHA-1 cannot be null"); //$NON-NLS-1$
	if (sha.length() == 0)
		throw new IllegalArgumentException("SHA-1 cannot be empty"); //$NON-NLS-1$

	StringBuilder uri = new StringBuilder();
	uri.append(SEGMENT_REPOS);
	uri.append('/').append(id);
	uri.append(SEGMENT_GIT);
	uri.append(SEGMENT_BLOBS);
	uri.append('/').append(sha);
	GitHubRequest request = createRequest();
	request.setUri(uri);
	return client.getStream(request);
}
 
开发者ID:GitHubPager,项目名称:GitHubPager,代码行数:19,代码来源:RawDataService.java


示例16: getRawFileAsStream

import org.eclipse.egit.github.core.client.GitHubRequest; //导入依赖的package包/类
public InputStream getRawFileAsStream(Repository repo, String path, String ref) throws Exception
  {
  	String id = repo.generateId();
StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
uri.append('/').append(id);
uri.append(SEGMENT_CONTENTS);
if (path != null && path.length() > 0) {
	if (path.charAt(0) != '/')
		uri.append('/');
	uri.append(path);
}
GitHubRequest request = createRequest();
request.setUri(uri);
if (ref != null && ref.length() > 0)
	request.setParams(Collections.singletonMap("ref", ref));
return client.getStream(request);
  }
 
开发者ID:GitHubPager,项目名称:GitHubPager,代码行数:18,代码来源:RawContentsService.java


示例17: getPullRequest

import org.eclipse.egit.github.core.client.GitHubRequest; //导入依赖的package包/类
@Override
public ExtendedPullRequest getPullRequest(final IRepositoryIdProvider repository, final int id) throws IOException {
    String repoId = this.getId(repository);
    StringBuilder uri = new StringBuilder("/repos");
    uri.append('/').append(repoId);
    uri.append("/pulls");
    uri.append('/').append(id);
    GitHubRequest request = this.createRequest();
    request.setUri(uri);
    request.setType(ExtendedPullRequest.class);
    return (ExtendedPullRequest) getClient().get(request).getBody();
}
 
开发者ID:aaronjwhiteside,项目名称:pipeline-github,代码行数:13,代码来源:ExtendedPullRequestService.java


示例18: getRateLimit

import org.eclipse.egit.github.core.client.GitHubRequest; //导入依赖的package包/类
public RateLimit getRateLimit()
{
    GitHubRequest request = new GitHubRequest().setUri(RATE_LIMIT_URI);
    try
    {
        GitHubResponse response = get(request);
        return new RateLimit(getRequestLimit(), getRemainingRequests(), parseLong(response.getHeader("X-RateLimit-Reset")));
    }
    catch (IOException e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:14,代码来源:GithubClientWithTimeout.java


示例19: PageHeaderIterator

import org.eclipse.egit.github.core.client.GitHubRequest; //导入依赖的package包/类
public PageHeaderIterator(GitHubRequest request, GitHubClientEx client,
                          String headerField) {
    this.request = request;
    this.client = client;
    this.headerField = headerField;

    next = request.getUri();
    nextPage = parsePageNumber(next);
}
 
开发者ID:HubTurbo,项目名称:HubTurbo,代码行数:10,代码来源:PageHeaderIterator.java


示例20: getIssueEvents

import org.eclipse.egit.github.core.client.GitHubRequest; //导入依赖的package包/类
/**
 * Retrieves a list of issue events together with the new ETag if the events are updated,
 * and an empty list with the current ETag if there are no new events.
 *
 * @param repository The repository from which to retrieve the issue
 * @param issueId    The numeric ID of the issue
 * @param eTag       The eTag to be added to the request header
 * @return list of issue events
 * @throws IOException
 */
public GitHubEventsResponse getIssueEvents(IRepositoryIdProvider repository, int issueId, String eTag)
        throws IOException {
    GitHubRequest request = createRequest();
    StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
    uri.append('/').append(repository.generateId())
            .append(SEGMENT_ISSUES).append('/').append(issueId)
            .append(SEGMENT_EVENTS);
    request.setUri(uri);
    request.setType(IssueEvent[].class);
    return ghClient.getEvent(request, eTag);
}
 
开发者ID:HubTurbo,项目名称:HubTurbo,代码行数:22,代码来源:IssueServiceEx.java



注:本文中的org.eclipse.egit.github.core.client.GitHubRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TableInputMeta类代码示例发布时间:2022-05-23
下一篇:
Java InstantiationUtil类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap