mirror of
https://github.com/jlengrand/github-api.git
synced 2026-04-15 15:51:15 +00:00
647 lines
26 KiB
HTML
647 lines
26 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>GHOrganization.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">GitHub API for Java</a> > <a href="index.source.html" class="el_package">org.kohsuke.github</a> > <span class="el_source">GHOrganization.java</span></div><h1>GHOrganization.java</h1><pre class="source lang-java linenums">package org.kohsuke.github;
|
||
|
||
import java.io.IOException;
|
||
import java.net.URL;
|
||
import java.util.ArrayList;
|
||
import java.util.Arrays;
|
||
import java.util.Collection;
|
||
import java.util.Collections;
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
import java.util.TreeMap;
|
||
|
||
import static org.kohsuke.github.Previews.INERTIA;
|
||
|
||
/**
|
||
* The type GHOrganization.
|
||
*
|
||
* @author Kohsuke Kawaguchi
|
||
*/
|
||
<span class="fc" id="L20">public class GHOrganization extends GHPerson {</span>
|
||
GHOrganization wrapUp(GitHub root) {
|
||
<span class="fc" id="L22"> return (GHOrganization) super.wrapUp(root);</span>
|
||
}
|
||
|
||
/**
|
||
* Creates a new repository.
|
||
*
|
||
* @param name
|
||
* the name
|
||
* @param description
|
||
* the description
|
||
* @param homepage
|
||
* the homepage
|
||
* @param team
|
||
* the team
|
||
* @param isPublic
|
||
* the is public
|
||
* @return Newly created repository.
|
||
* @throws IOException
|
||
* the io exception
|
||
* @deprecated Use {@link #createRepository(String)} that uses a builder pattern to let you control every aspect.
|
||
*/
|
||
@Deprecated
|
||
public GHRepository createRepository(String name,
|
||
String description,
|
||
String homepage,
|
||
String team,
|
||
boolean isPublic) throws IOException {
|
||
<span class="fc" id="L49"> GHTeam t = getTeams().get(team);</span>
|
||
<span class="pc bpc" id="L50" title="1 of 2 branches missed."> if (t == null)</span>
|
||
<span class="nc" id="L51"> throw new IllegalArgumentException("No such team: " + team);</span>
|
||
<span class="fc" id="L52"> return createRepository(name, description, homepage, t, isPublic);</span>
|
||
}
|
||
|
||
/**
|
||
* Create repository gh repository.
|
||
*
|
||
* @param name
|
||
* the name
|
||
* @param description
|
||
* the description
|
||
* @param homepage
|
||
* the homepage
|
||
* @param team
|
||
* the team
|
||
* @param isPublic
|
||
* the is public
|
||
* @return the gh repository
|
||
* @throws IOException
|
||
* the io exception
|
||
* @deprecated Use {@link #createRepository(String)} that uses a builder pattern to let you control every aspect.
|
||
*/
|
||
@Deprecated
|
||
public GHRepository createRepository(String name,
|
||
String description,
|
||
String homepage,
|
||
GHTeam team,
|
||
boolean isPublic) throws IOException {
|
||
<span class="pc bpc" id="L79" title="1 of 2 branches missed."> if (team == null)</span>
|
||
<span class="nc" id="L80"> throw new IllegalArgumentException("Invalid team");</span>
|
||
<span class="fc" id="L81"> return createRepository(name).description(description)</span>
|
||
<span class="pc bpc" id="L82" title="1 of 2 branches missed."> .homepage(homepage)</span>
|
||
<span class="fc" id="L83"> .private_(!isPublic)</span>
|
||
<span class="fc" id="L84"> .team(team)</span>
|
||
<span class="fc" id="L85"> .create();</span>
|
||
}
|
||
|
||
/**
|
||
* Starts a builder that creates a new repository.
|
||
*
|
||
* <p>
|
||
* You use the returned builder to set various properties, then call {@link GHCreateRepositoryBuilder#create()} to
|
||
* finally create a repository.
|
||
*
|
||
* @param name
|
||
* the name
|
||
* @return the gh create repository builder
|
||
*/
|
||
public GHCreateRepositoryBuilder createRepository(String name) {
|
||
<span class="fc" id="L100"> return new GHCreateRepositoryBuilder(root, "/orgs/" + login + "/repos", name);</span>
|
||
}
|
||
|
||
/**
|
||
* Teams by their names.
|
||
*
|
||
* @return the teams
|
||
* @throws IOException
|
||
* the io exception
|
||
*/
|
||
public Map<String, GHTeam> getTeams() throws IOException {
|
||
<span class="fc" id="L111"> Map<String, GHTeam> r = new TreeMap<String, GHTeam>();</span>
|
||
<span class="fc bfc" id="L112" title="All 2 branches covered."> for (GHTeam t : listTeams()) {</span>
|
||
<span class="fc" id="L113"> r.put(t.getName(), t);</span>
|
||
<span class="fc" id="L114"> }</span>
|
||
<span class="fc" id="L115"> return r;</span>
|
||
}
|
||
|
||
/**
|
||
* List up all the teams.
|
||
*
|
||
* @return the paged iterable
|
||
* @throws IOException
|
||
* the io exception
|
||
*/
|
||
public PagedIterable<GHTeam> listTeams() throws IOException {
|
||
<span class="fc" id="L126"> return root.createRequest()</span>
|
||
<span class="fc" id="L127"> .withUrlPath(String.format("/orgs/%s/teams", login))</span>
|
||
<span class="fc" id="L128"> .toIterable(GHTeam[].class, item -> item.wrapUp(this));</span>
|
||
}
|
||
|
||
/**
|
||
* Gets a single team by ID.
|
||
*
|
||
* @param teamId
|
||
* id of the team that we want to query for
|
||
* @return the team
|
||
* @throws IOException
|
||
* the io exception
|
||
*
|
||
* @see <a href= "https://developer.github.com/v3/teams/#get-team-by-name">documentation</a>
|
||
*/
|
||
public GHTeam getTeam(int teamId) throws IOException {
|
||
<span class="fc" id="L143"> return root.createRequest()</span>
|
||
<span class="fc" id="L144"> .withUrlPath(String.format("/organizations/%d/team/%d", id, teamId))</span>
|
||
<span class="fc" id="L145"> .fetch(GHTeam.class)</span>
|
||
<span class="fc" id="L146"> .wrapUp(this);</span>
|
||
}
|
||
|
||
/**
|
||
* Finds a team that has the given name in its {@link GHTeam#getName()}
|
||
*
|
||
* @param name
|
||
* the name
|
||
* @return the team by name
|
||
* @throws IOException
|
||
* the io exception
|
||
*/
|
||
public GHTeam getTeamByName(String name) throws IOException {
|
||
<span class="pc bpc" id="L159" title="1 of 2 branches missed."> for (GHTeam t : listTeams()) {</span>
|
||
<span class="fc bfc" id="L160" title="All 2 branches covered."> if (t.getName().equals(name))</span>
|
||
<span class="fc" id="L161"> return t;</span>
|
||
<span class="fc" id="L162"> }</span>
|
||
<span class="nc" id="L163"> return null;</span>
|
||
}
|
||
|
||
/**
|
||
* Finds a team that has the given slug in its {@link GHTeam#getSlug()}
|
||
*
|
||
* @param slug
|
||
* the slug
|
||
* @return the team by slug
|
||
* @throws IOException
|
||
* the io exception
|
||
* @see <a href= "https://developer.github.com/v3/teams/#get-team-by-name">documentation</a>
|
||
*/
|
||
public GHTeam getTeamBySlug(String slug) throws IOException {
|
||
<span class="fc" id="L177"> return root.createRequest()</span>
|
||
<span class="fc" id="L178"> .withUrlPath(String.format("/orgs/%s/teams/%s", login, slug))</span>
|
||
<span class="fc" id="L179"> .fetch(GHTeam.class)</span>
|
||
<span class="fc" id="L180"> .wrapUp(this);</span>
|
||
}
|
||
|
||
/**
|
||
* Member's role in an organization
|
||
*/
|
||
<span class="fc" id="L186"> public enum Role {</span>
|
||
<span class="fc" id="L187"> ADMIN,</span>
|
||
/** The user is an owner of the organization. */
|
||
<span class="fc" id="L189"> MEMBER /** The user is a non-owner member of the organization. */</span>
|
||
}
|
||
|
||
/**
|
||
* Adds (invites) a user to the organization.
|
||
*
|
||
* @param user
|
||
* the user
|
||
* @param role
|
||
* the role
|
||
* @throws IOException
|
||
* the io exception
|
||
* @see <a href=
|
||
* "https://developer.github.com/v3/orgs/members/#add-or-update-organization-membership">documentation</a>
|
||
*/
|
||
public void add(GHUser user, Role role) throws IOException {
|
||
<span class="fc" id="L205"> root.createRequest()</span>
|
||
<span class="fc" id="L206"> .method("PUT")</span>
|
||
<span class="fc" id="L207"> .with("role", role.name().toLowerCase())</span>
|
||
<span class="fc" id="L208"> .withUrlPath("/orgs/" + login + "/memberships/" + user.getLogin())</span>
|
||
<span class="fc" id="L209"> .send();</span>
|
||
<span class="fc" id="L210"> }</span>
|
||
|
||
/**
|
||
* Checks if this organization has the specified user as a member.
|
||
*
|
||
* @param user
|
||
* the user
|
||
* @return the boolean
|
||
*/
|
||
public boolean hasMember(GHUser user) {
|
||
try {
|
||
<span class="fc" id="L221"> root.createRequest().withUrlPath("/orgs/" + login + "/members/" + user.getLogin()).send();</span>
|
||
<span class="fc" id="L222"> return true;</span>
|
||
<span class="fc" id="L223"> } catch (IOException ignore) {</span>
|
||
<span class="fc" id="L224"> return false;</span>
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Remove a member of the organisation - which will remove them from all teams, and remove their access to the
|
||
* organization’s repositories.
|
||
*
|
||
* @param user
|
||
* the user
|
||
* @throws IOException
|
||
* the io exception
|
||
*/
|
||
public void remove(GHUser user) throws IOException {
|
||
<span class="nc" id="L238"> root.createRequest().method("DELETE").withUrlPath("/orgs/" + login + "/members/" + user.getLogin()).send();</span>
|
||
<span class="nc" id="L239"> }</span>
|
||
|
||
/**
|
||
* Checks if this organization has the specified user as a public member.
|
||
*
|
||
* @param user
|
||
* the user
|
||
* @return the boolean
|
||
*/
|
||
public boolean hasPublicMember(GHUser user) {
|
||
try {
|
||
<span class="fc" id="L250"> root.createRequest().withUrlPath("/orgs/" + login + "/public_members/" + user.getLogin()).send();</span>
|
||
<span class="fc" id="L251"> return true;</span>
|
||
<span class="fc" id="L252"> } catch (IOException ignore) {</span>
|
||
<span class="fc" id="L253"> return false;</span>
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Publicizes the membership.
|
||
*
|
||
* @param u
|
||
* the u
|
||
* @throws IOException
|
||
* the io exception
|
||
*/
|
||
public void publicize(GHUser u) throws IOException {
|
||
<span class="nc" id="L266"> root.createRequest().method("PUT").withUrlPath("/orgs/" + login + "/public_members/" + u.getLogin()).send();</span>
|
||
<span class="nc" id="L267"> }</span>
|
||
|
||
/**
|
||
* Gets members.
|
||
*
|
||
* @return the members
|
||
* @throws IOException
|
||
* the io exception
|
||
* @deprecated use {@link #listMembers()}
|
||
*/
|
||
public List<GHUser> getMembers() throws IOException {
|
||
<span class="nc" id="L278"> return listMembers().toList();</span>
|
||
}
|
||
|
||
/**
|
||
* All the members of this organization.
|
||
*
|
||
* @return the paged iterable
|
||
* @throws IOException
|
||
* the io exception
|
||
*/
|
||
public PagedIterable<GHUser> listMembers() throws IOException {
|
||
<span class="nc" id="L289"> return listMembers("members");</span>
|
||
}
|
||
|
||
/**
|
||
* All the public members of this organization.
|
||
*
|
||
* @return the paged iterable
|
||
* @throws IOException
|
||
* the io exception
|
||
*/
|
||
public PagedIterable<GHUser> listPublicMembers() throws IOException {
|
||
<span class="nc" id="L300"> return listMembers("public_members");</span>
|
||
}
|
||
|
||
private PagedIterable<GHUser> listMembers(String suffix) throws IOException {
|
||
<span class="nc" id="L304"> return listMembers(suffix, null, null);</span>
|
||
}
|
||
|
||
/**
|
||
* List members with filter paged iterable.
|
||
*
|
||
* @param filter
|
||
* the filter
|
||
* @return the paged iterable
|
||
* @throws IOException
|
||
* the io exception
|
||
*/
|
||
public PagedIterable<GHUser> listMembersWithFilter(String filter) throws IOException {
|
||
<span class="fc" id="L317"> return listMembers("members", filter, null);</span>
|
||
}
|
||
|
||
/**
|
||
* List members with specified role paged iterable.
|
||
*
|
||
* @param role
|
||
* the role
|
||
* @return the paged iterable
|
||
* @throws IOException
|
||
* the io exception
|
||
*/
|
||
public PagedIterable<GHUser> listMembersWithRole(String role) throws IOException {
|
||
<span class="fc" id="L330"> return listMembers("members", null, role);</span>
|
||
}
|
||
|
||
private PagedIterable<GHUser> listMembers(final String suffix, final String filter, String role)
|
||
throws IOException {
|
||
<span class="fc" id="L335"> return root.createRequest()</span>
|
||
<span class="fc" id="L336"> .withUrlPath(String.format("/orgs/%s/%s", login, suffix))</span>
|
||
<span class="fc" id="L337"> .with("filter", filter)</span>
|
||
<span class="fc" id="L338"> .with("role", role)</span>
|
||
<span class="fc" id="L339"> .toIterable(GHUser[].class, item -> item.wrapUp(root));</span>
|
||
}
|
||
|
||
/**
|
||
* Conceals the membership.
|
||
*
|
||
* @param u
|
||
* the u
|
||
* @throws IOException
|
||
* the io exception
|
||
*/
|
||
public void conceal(GHUser u) throws IOException {
|
||
<span class="nc" id="L351"> root.createRequest().method("DELETE").withUrlPath("/orgs/" + login + "/public_members/" + u.getLogin()).send();</span>
|
||
<span class="nc" id="L352"> }</span>
|
||
|
||
/**
|
||
* Returns the projects for this organization.
|
||
*
|
||
* @param status
|
||
* The status filter (all, open or closed).
|
||
* @return the paged iterable
|
||
* @throws IOException
|
||
* the io exception
|
||
*/
|
||
public PagedIterable<GHProject> listProjects(final GHProject.ProjectStateFilter status) throws IOException {
|
||
<span class="nc" id="L364"> return root.createRequest()</span>
|
||
<span class="nc" id="L365"> .withPreview(INERTIA)</span>
|
||
<span class="nc" id="L366"> .with("state", status)</span>
|
||
<span class="nc" id="L367"> .withUrlPath(String.format("/orgs/%s/projects", login))</span>
|
||
<span class="nc" id="L368"> .toIterable(GHProject[].class, item -> item.wrap(root));</span>
|
||
}
|
||
|
||
/**
|
||
* Returns all open projects for the organization.
|
||
*
|
||
* @return the paged iterable
|
||
* @throws IOException
|
||
* the io exception
|
||
*/
|
||
public PagedIterable<GHProject> listProjects() throws IOException {
|
||
<span class="nc" id="L379"> return listProjects(GHProject.ProjectStateFilter.OPEN);</span>
|
||
}
|
||
|
||
/**
|
||
* Creates a project for the organization.
|
||
*
|
||
* @param name
|
||
* the name
|
||
* @param body
|
||
* the body
|
||
* @return the gh project
|
||
* @throws IOException
|
||
* the io exception
|
||
*/
|
||
public GHProject createProject(String name, String body) throws IOException {
|
||
<span class="fc" id="L394"> return root.createRequest()</span>
|
||
<span class="fc" id="L395"> .method("POST")</span>
|
||
<span class="fc" id="L396"> .withPreview(INERTIA)</span>
|
||
<span class="fc" id="L397"> .with("name", name)</span>
|
||
<span class="fc" id="L398"> .with("body", body)</span>
|
||
<span class="fc" id="L399"> .withUrlPath(String.format("/orgs/%s/projects", login))</span>
|
||
<span class="fc" id="L400"> .fetch(GHProject.class)</span>
|
||
<span class="fc" id="L401"> .wrap(root);</span>
|
||
}
|
||
|
||
/**
|
||
* The enum Permission.
|
||
*/
|
||
<span class="fc" id="L407"> public enum Permission {</span>
|
||
<span class="fc" id="L408"> ADMIN, PUSH, PULL</span>
|
||
}
|
||
|
||
/**
|
||
* Creates a new team and assigns the repositories.
|
||
*
|
||
* @param name
|
||
* the name
|
||
* @param p
|
||
* the p
|
||
* @param repositories
|
||
* the repositories
|
||
* @return the gh team
|
||
* @throws IOException
|
||
* the io exception
|
||
* @deprecated https://developer.github.com/v3/teams/#create-team deprecates permission field use
|
||
* {@link #createTeam(String)}
|
||
*/
|
||
@Deprecated
|
||
public GHTeam createTeam(String name, Permission p, Collection<GHRepository> repositories) throws IOException {
|
||
<span class="fc" id="L428"> Requester post = root.createRequest().method("POST").with("name", name).with("permission", p);</span>
|
||
<span class="fc" id="L429"> List<String> repo_names = new ArrayList<String>();</span>
|
||
<span class="fc bfc" id="L430" title="All 2 branches covered."> for (GHRepository r : repositories) {</span>
|
||
<span class="fc" id="L431"> repo_names.add(login + "/" + r.getName());</span>
|
||
<span class="fc" id="L432"> }</span>
|
||
<span class="fc" id="L433"> post.with("repo_names", repo_names);</span>
|
||
<span class="fc" id="L434"> return post.withUrlPath("/orgs/" + login + "/teams").fetch(GHTeam.class).wrapUp(this);</span>
|
||
}
|
||
|
||
/**
|
||
* Create team gh team.
|
||
*
|
||
* @param name
|
||
* the name
|
||
* @param p
|
||
* the p
|
||
* @param repositories
|
||
* the repositories
|
||
* @return the gh team
|
||
* @throws IOException
|
||
* the io exception
|
||
* @deprecated https://developer.github.com/v3/teams/#create-team deprecates permission field use
|
||
* {@link #createTeam(String)}
|
||
*/
|
||
@Deprecated
|
||
public GHTeam createTeam(String name, Permission p, GHRepository... repositories) throws IOException {
|
||
<span class="fc" id="L454"> return createTeam(name, p, Arrays.asList(repositories));</span>
|
||
}
|
||
|
||
/**
|
||
* Creates a new team and assigns the repositories.
|
||
*
|
||
* @param name
|
||
* the name
|
||
* @param repositories
|
||
* the repositories
|
||
* @return the gh team
|
||
* @throws IOException
|
||
* the io exception
|
||
* @deprecated Use {@link #createTeam(String)} that uses a builder pattern to let you control every aspect.
|
||
*/
|
||
@Deprecated
|
||
public GHTeam createTeam(String name, Collection<GHRepository> repositories) throws IOException {
|
||
<span class="fc" id="L471"> Requester post = root.createRequest().method("POST").with("name", name);</span>
|
||
<span class="fc" id="L472"> List<String> repo_names = new ArrayList<String>();</span>
|
||
<span class="fc bfc" id="L473" title="All 2 branches covered."> for (GHRepository r : repositories) {</span>
|
||
<span class="fc" id="L474"> repo_names.add(login + "/" + r.getName());</span>
|
||
<span class="fc" id="L475"> }</span>
|
||
<span class="fc" id="L476"> post.with("repo_names", repo_names);</span>
|
||
<span class="fc" id="L477"> return post.withUrlPath("/orgs/" + login + "/teams").fetch(GHTeam.class).wrapUp(this);</span>
|
||
}
|
||
|
||
/**
|
||
* Create team gh team.
|
||
*
|
||
* @param name
|
||
* the name
|
||
* @param repositories
|
||
* the repositories
|
||
* @return the gh team
|
||
* @throws IOException
|
||
* the io exception
|
||
* @deprecated Use {@link #createTeam(String)} that uses a builder pattern to let you control every aspect.
|
||
*/
|
||
@Deprecated
|
||
public GHTeam createTeam(String name, GHRepository... repositories) throws IOException {
|
||
<span class="fc" id="L494"> return createTeam(name, Arrays.asList(repositories));</span>
|
||
}
|
||
|
||
/**
|
||
* Starts a builder that creates a new team.
|
||
*
|
||
* <p>
|
||
* You use the returned builder to set various properties, then call {@link GHTeamBuilder#create()} to finally
|
||
* create a team.
|
||
*
|
||
* @param name
|
||
* the name
|
||
* @return the gh create repository builder
|
||
*/
|
||
public GHTeamBuilder createTeam(String name) {
|
||
<span class="fc" id="L509"> return new GHTeamBuilder(root, login, name);</span>
|
||
}
|
||
|
||
/**
|
||
* List up repositories that has some open pull requests.
|
||
* <p>
|
||
* This used to be an efficient method that didn't involve traversing every repository, but now it doesn't do any
|
||
* optimization.
|
||
*
|
||
* @return the repositories with open pull requests
|
||
* @throws IOException
|
||
* the io exception
|
||
*/
|
||
public List<GHRepository> getRepositoriesWithOpenPullRequests() throws IOException {
|
||
<span class="nc" id="L523"> List<GHRepository> r = new ArrayList<GHRepository>();</span>
|
||
<span class="nc bnc" id="L524" title="All 2 branches missed."> for (GHRepository repository : listRepositories(100)) {</span>
|
||
<span class="nc" id="L525"> repository.wrap(root);</span>
|
||
<span class="nc" id="L526"> List<GHPullRequest> pullRequests = repository.getPullRequests(GHIssueState.OPEN);</span>
|
||
<span class="nc bnc" id="L527" title="All 2 branches missed."> if (pullRequests.size() > 0) {</span>
|
||
<span class="nc" id="L528"> r.add(repository);</span>
|
||
}
|
||
<span class="nc" id="L530"> }</span>
|
||
<span class="nc" id="L531"> return r;</span>
|
||
}
|
||
|
||
/**
|
||
* Gets all the open pull requests in this organizataion.
|
||
*
|
||
* @return the pull requests
|
||
* @throws IOException
|
||
* the io exception
|
||
*/
|
||
public List<GHPullRequest> getPullRequests() throws IOException {
|
||
<span class="nc" id="L542"> List<GHPullRequest> all = new ArrayList<GHPullRequest>();</span>
|
||
<span class="nc bnc" id="L543" title="All 2 branches missed."> for (GHRepository r : getRepositoriesWithOpenPullRequests()) {</span>
|
||
<span class="nc" id="L544"> all.addAll(r.getPullRequests(GHIssueState.OPEN));</span>
|
||
<span class="nc" id="L545"> }</span>
|
||
<span class="nc" id="L546"> return all;</span>
|
||
}
|
||
|
||
/**
|
||
* Lists events performed by a user (this includes private events if the caller is authenticated.
|
||
*/
|
||
public PagedIterable<GHEventInfo> listEvents() throws IOException {
|
||
<span class="nc" id="L553"> return root.createRequest()</span>
|
||
<span class="nc" id="L554"> .withUrlPath(String.format("/orgs/%s/events", login))</span>
|
||
<span class="nc" id="L555"> .toIterable(GHEventInfo[].class, item -> item.wrapUp(root));</span>
|
||
}
|
||
|
||
/**
|
||
* Lists up all the repositories using the specified page size.
|
||
*
|
||
* @param pageSize
|
||
* size for each page of items returned by GitHub. Maximum page size is 100.
|
||
*
|
||
* Unlike {@link #getRepositories()}, this does not wait until all the repositories are returned.
|
||
*/
|
||
@Override
|
||
public PagedIterable<GHRepository> listRepositories(final int pageSize) {
|
||
<span class="fc" id="L568"> return root.createRequest()</span>
|
||
<span class="fc" id="L569"> .withUrlPath("/orgs/" + login + "/repos")</span>
|
||
<span class="fc" id="L570"> .toIterable(GHRepository[].class, item -> item.wrap(root))</span>
|
||
<span class="fc" id="L571"> .withPageSize(pageSize);</span>
|
||
}
|
||
|
||
/**
|
||
* Retrieves the currently configured hooks.
|
||
*
|
||
* @return the hooks
|
||
* @throws IOException
|
||
* the io exception
|
||
*/
|
||
public List<GHHook> getHooks() throws IOException {
|
||
<span class="nc" id="L582"> return GHHooks.orgContext(this).getHooks();</span>
|
||
}
|
||
|
||
/**
|
||
* Gets hook.
|
||
*
|
||
* @param id
|
||
* the id
|
||
* @return the hook
|
||
* @throws IOException
|
||
* the io exception
|
||
*/
|
||
public GHHook getHook(int id) throws IOException {
|
||
<span class="nc" id="L595"> return GHHooks.orgContext(this).getHook(id);</span>
|
||
}
|
||
|
||
/**
|
||
* See https://api.github.com/hooks for possible names and their configuration scheme. TODO: produce type-safe
|
||
* binding
|
||
*
|
||
* @param name
|
||
* Type of the hook to be created. See https://api.github.com/hooks for possible names.
|
||
* @param config
|
||
* The configuration hash.
|
||
* @param events
|
||
* Can be null. Types of events to hook into.
|
||
* @param active
|
||
* the active
|
||
* @return the gh hook
|
||
* @throws IOException
|
||
* the io exception
|
||
*/
|
||
public GHHook createHook(String name, Map<String, String> config, Collection<GHEvent> events, boolean active)
|
||
throws IOException {
|
||
<span class="nc" id="L616"> return GHHooks.orgContext(this).createHook(name, config, events, active);</span>
|
||
}
|
||
|
||
/**
|
||
* Create web hook gh hook.
|
||
*
|
||
* @param url
|
||
* the url
|
||
* @param events
|
||
* the events
|
||
* @return the gh hook
|
||
* @throws IOException
|
||
* the io exception
|
||
*/
|
||
public GHHook createWebHook(URL url, Collection<GHEvent> events) throws IOException {
|
||
<span class="nc" id="L631"> return createHook("web", Collections.singletonMap("url", url.toExternalForm()), events, true);</span>
|
||
}
|
||
|
||
/**
|
||
* Create web hook gh hook.
|
||
*
|
||
* @param url
|
||
* the url
|
||
* @return the gh hook
|
||
* @throws IOException
|
||
* the io exception
|
||
*/
|
||
public GHHook createWebHook(URL url) throws IOException {
|
||
<span class="nc" id="L644"> return createWebHook(url, null);</span>
|
||
}
|
||
}
|
||
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.5.201910111838</span></div></body></html> |