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); }
@Override public Status createStatus(String owner, String repository, String sha, StatusRequest body) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("owner", owner); uriVariables.put("repository", repository); uriVariables.put("sha", sha); URI uri = new UriTemplate(buildUriString("/repos/{owner}/{repository}/statuses/{sha}")).expand(uriVariables); RequestEntity<StatusRequest> entity = RequestEntity.post(uri).contentType(MediaType.APPLICATION_JSON) .body(body); ResponseEntity<Status> responseEntity = getRestTemplate().exchange(entity, Status.class); return responseEntity.getBody(); }
private String buildRepoUri(final String path, Map<String, Object> uriVariables) { return buildUri("repos/{user}/{repo}" + path, uriVariables).toString(); }
private void initialize() { userOperations = new UserTemplate(getRestTemplate(), isAuthorized()); repositoryOperations = new RepositoryTemplate(getRestTemplate(), isAuthorized()); authorizationOperations = new AuthorizationTemplate(getRestTemplate(), isAuthorized()); organizationOperations = new OrganizationTemplate(getRestTemplate(), isAuthorized()); }
private String buildRepoUri(final String path) { return buildUri("repos/{user}/{repo}" + path).toString(); }
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(); }
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)); }
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; }
@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); }
@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)); }
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}")); }
@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); }
@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)); }
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); }