public static StatusRequest failureStatusRequest() { return new StatusRequest("failure"); } }
private String buildRepoUri(final String path, Map<String, Object> uriVariables) { return buildUri("repos/{user}/{repo}" + path, uriVariables).toString(); }
public GitHubDeployKey addDeployKey(final String owner, final String repo, final String title, final String key) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("user", owner); uriVariables.put("repo", repo); AddDeployKeyRequest request = new AddDeployKeyRequest(title, key); return getRestTemplate().postForObject(buildRepoUri("/keys", uriVariables), request, GitHubDeployKey.class); }
public GitHubDeployKey getDeployKey(final String user, final String repo, final int id) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("user", user); uriVariables.put("repo", repo); uriVariables.put("id", id); return getRestTemplate().getForObject(buildRepoUri("/keys/{id}", uriVariables), GitHubDeployKey.class); }
/** * 'ref' can be SHA, branch or tag. */ @Override public CombinedStatus getCombinedStatus(String owner, String repository, String ref) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("owner", owner); uriVariables.put("repository", repository); uriVariables.put("ref", ref); return getRestTemplate().exchange(buildUri("/repos/{owner}/{repository}/commits/{ref}/status", uriVariables), HttpMethod.GET, null, CombinedStatus.class).getBody(); }
private void initialize() { userOperations = new UserTemplate(getRestTemplate(), isAuthorized(), this.apiBaseUrl); repositoryOperations = new RepositoryTemplate(getRestTemplate(), isAuthorized(), this.apiBaseUrl); authorizationOperations = new AuthorizationTemplate(getRestTemplate(), isAuthorized(), this.apiBaseUrl); organizationOperations = new OrganizationTemplate(getRestTemplate(), isAuthorized(), this.apiBaseUrl); }
public GitHubRepo getRepository(final String user, final String repo) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("user", user); uriVariables.put("repo", repo); return getRestTemplate().getForObject(buildRepoUri("", uriVariables), GitHubRepo.class); }
@Override public List<Status> listStatuses(String owner, String repository, String ref) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("owner", owner); uriVariables.put("repository", repository); uriVariables.put("ref", ref); return getRestTemplate().exchange(buildUri("/repos/{owner}/{repository}/commits/{ref}/statuses", uriVariables), HttpMethod.GET, null, statusListTypeRef).getBody(); }
private void initialize() { userOperations = new UserTemplate(getRestTemplate(), isAuthorized()); repositoryOperations = new RepositoryTemplate(getRestTemplate(), isAuthorized()); authorizationOperations = new AuthorizationTemplate(getRestTemplate(), isAuthorized()); organizationOperations = new OrganizationTemplate(getRestTemplate(), isAuthorized()); }
public static StatusRequest pendingStatusRequest() { return new StatusRequest("pending"); }
private String buildRepoUri(final String path) { return buildUri("repos/{user}/{repo}" + path).toString(); }
@Override public GitHubWebhook getWebhook(final String user, final String repo, final String id) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("user", user); uriVariables.put("repo", repo); uriVariables.put("id", id); return getRestTemplate().getForObject(buildRepoUri("/hooks/{id}", uriVariables), GitHubWebhook.class); }
public List<GitHubRepo> getRepositories(final String user) { // RequestEntity<?> requestEntity = new // RequestEntity<>(getDefaultHeaders(), HttpMethod.GET, // buildUri("user/repos?per_page=100")); // ResponseEntity<GitHubRepo[]> repositoriesEntity = // getRestTemplate().exchange(requestEntity, GitHubRepo[].class); List<GitHubRepo> result = new ArrayList<GitHubRepo>(); Iterator<List<GitHubRepo>> iter = new PagingIterator<>(getRestTemplate(), buildUri("user/repos?per_page=100"), repoListTypeRef); while (iter.hasNext()) { result.addAll(iter.next()); } // buildUri("user/repos?per_page=100"), HttpMethod.GET, entity, // GitHubRepo[].class, // new HashMap<String, Object>()); // log.info("LINK_HEADER : {}", // repositoriesEntity.getHeaders().get("Link")); // return asList(repositoriesEntity.getBody()); return result; }
public static StatusRequest successStatusRequest() { return new StatusRequest("success"); }
public void deleteDeployKey(final String owner, final String repo, final int id) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("user", owner); uriVariables.put("repo", repo); uriVariables.put("id", id); getRestTemplate().delete(buildRepoUri("/keys/{id}")); }
public static StatusRequest errorStatusRequest() { return new StatusRequest("error"); }
@Override public GitHubWebhook addWebhook(final String user, final String repo, final Object request) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("user", user); uriVariables.put("repo", repo); return getRestTemplate().postForObject(buildRepoUri("/hooks", uriVariables), request, GitHubWebhook.class); }
public List<GitHubDeployKey> getDeployKeys(final String user, final String repo) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("user", user); uriVariables.put("repo", repo); return asList(getRestTemplate().getForObject(buildRepoUri("/keys", uriVariables), GitHubDeployKey[].class)); }
@Override public void deleteWebhook(final String user, final String repo, final String id) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("user", user); uriVariables.put("repo", repo); uriVariables.put("id", id); getRestTemplate().delete(buildRepoUri("/hooks/{id}", uriVariables)); }
@Override public List<GitHubWebhook> getWebhooks(final String user, final String repo) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("user", user); uriVariables.put("repo", repo); return asList(getRestTemplate().getForObject(buildRepoUri("/hooks", uriVariables), GitHubWebhook[].class)); }