mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-21 15:50:49 +00:00
695 lines
28 KiB
HTML
695 lines
28 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.internal.Previews.INERTIA;
|
||
|
||
/**
|
||
* The type GHOrganization.
|
||
*
|
||
* @author Kohsuke Kawaguchi
|
||
*/
|
||
<span class="fc" id="L20">public class GHOrganization extends GHPerson {</span>
|
||
|
||
private boolean has_organization_projects;
|
||
|
||
GHOrganization wrapUp(GitHub root) {
|
||
<span class="fc" id="L25"> 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="nc" id="L52"> GHTeam t = getTeams().get(team);</span>
|
||
<span class="nc bnc" id="L53" title="All 2 branches missed."> if (t == null)</span>
|
||
<span class="nc" id="L54"> throw new IllegalArgumentException("No such team: " + team);</span>
|
||
<span class="nc" id="L55"> 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="nc bnc" id="L82" title="All 2 branches missed."> if (team == null)</span>
|
||
<span class="nc" id="L83"> throw new IllegalArgumentException("Invalid team");</span>
|
||
<span class="nc" id="L84"> return createRepository(name).description(description)</span>
|
||
<span class="nc bnc" id="L85" title="All 2 branches missed."> .homepage(homepage)</span>
|
||
<span class="nc" id="L86"> .private_(!isPublic)</span>
|
||
<span class="nc" id="L87"> .team(team)</span>
|
||
<span class="nc" id="L88"> .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="L103"> return new GHCreateRepositoryBuilder(name, root, "/orgs/" + login + "/repos");</span>
|
||
}
|
||
|
||
/**
|
||
* Teams by their names.
|
||
*
|
||
* @return the teams
|
||
* @throws IOException
|
||
* the io exception
|
||
*/
|
||
public Map<String, GHTeam> getTeams() throws IOException {
|
||
<span class="fc" id="L114"> Map<String, GHTeam> r = new TreeMap<String, GHTeam>();</span>
|
||
<span class="fc bfc" id="L115" title="All 2 branches covered."> for (GHTeam t : listTeams()) {</span>
|
||
<span class="fc" id="L116"> r.put(t.getName(), t);</span>
|
||
<span class="fc" id="L117"> }</span>
|
||
<span class="fc" id="L118"> 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="L129"> return root.createRequest()</span>
|
||
<span class="fc" id="L130"> .withUrlPath(String.format("/orgs/%s/teams", login))</span>
|
||
<span class="fc" id="L131"> .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
|
||
*
|
||
* @deprecated Use {@link GHOrganization#getTeam(long)}
|
||
*/
|
||
@Deprecated
|
||
public GHTeam getTeam(int teamId) throws IOException {
|
||
<span class="nc" id="L147"> return getTeam((long) teamId);</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(long teamId) throws IOException {
|
||
<span class="fc" id="L162"> return root.createRequest()</span>
|
||
<span class="fc" id="L163"> .withUrlPath(String.format("/organizations/%d/team/%d", getId(), teamId))</span>
|
||
<span class="fc" id="L164"> .fetch(GHTeam.class)</span>
|
||
<span class="fc" id="L165"> .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="L178" title="1 of 2 branches missed."> for (GHTeam t : listTeams()) {</span>
|
||
<span class="fc bfc" id="L179" title="All 2 branches covered."> if (t.getName().equals(name))</span>
|
||
<span class="fc" id="L180"> return t;</span>
|
||
<span class="fc" id="L181"> }</span>
|
||
<span class="nc" id="L182"> 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="L196"> return root.createRequest()</span>
|
||
<span class="fc" id="L197"> .withUrlPath(String.format("/orgs/%s/teams/%s", login, slug))</span>
|
||
<span class="fc" id="L198"> .fetch(GHTeam.class)</span>
|
||
<span class="fc" id="L199"> .wrapUp(this);</span>
|
||
}
|
||
|
||
/**
|
||
* Member's role in an organization
|
||
*/
|
||
<span class="fc" id="L205"> public enum Role {</span>
|
||
<span class="fc" id="L206"> ADMIN,</span>
|
||
/** The user is an owner of the organization. */
|
||
<span class="fc" id="L208"> 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="L224"> root.createRequest()</span>
|
||
<span class="fc" id="L225"> .method("PUT")</span>
|
||
<span class="fc" id="L226"> .with("role", role.name().toLowerCase())</span>
|
||
<span class="fc" id="L227"> .withUrlPath("/orgs/" + login + "/memberships/" + user.getLogin())</span>
|
||
<span class="fc" id="L228"> .send();</span>
|
||
<span class="fc" id="L229"> }</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="L240"> root.createRequest().withUrlPath("/orgs/" + login + "/members/" + user.getLogin()).send();</span>
|
||
<span class="fc" id="L241"> return true;</span>
|
||
<span class="fc" id="L242"> } catch (IOException ignore) {</span>
|
||
<span class="fc" id="L243"> 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="L257"> root.createRequest().method("DELETE").withUrlPath("/orgs/" + login + "/members/" + user.getLogin()).send();</span>
|
||
<span class="nc" id="L258"> }</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="L269"> root.createRequest().withUrlPath("/orgs/" + login + "/public_members/" + user.getLogin()).send();</span>
|
||
<span class="fc" id="L270"> return true;</span>
|
||
<span class="fc" id="L271"> } catch (IOException ignore) {</span>
|
||
<span class="fc" id="L272"> 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="L285"> root.createRequest().method("PUT").withUrlPath("/orgs/" + login + "/public_members/" + u.getLogin()).send();</span>
|
||
<span class="nc" id="L286"> }</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="L297"> 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="L308"> 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="L319"> return listMembers("public_members");</span>
|
||
}
|
||
|
||
private PagedIterable<GHUser> listMembers(String suffix) throws IOException {
|
||
<span class="nc" id="L323"> 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="L336"> 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="L349"> return listMembers("members", null, role);</span>
|
||
}
|
||
|
||
private PagedIterable<GHUser> listMembers(final String suffix, final String filter, String role)
|
||
throws IOException {
|
||
<span class="fc" id="L354"> return root.createRequest()</span>
|
||
<span class="fc" id="L355"> .withUrlPath(String.format("/orgs/%s/%s", login, suffix))</span>
|
||
<span class="fc" id="L356"> .with("filter", filter)</span>
|
||
<span class="fc" id="L357"> .with("role", role)</span>
|
||
<span class="fc" id="L358"> .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="L370"> root.createRequest().method("DELETE").withUrlPath("/orgs/" + login + "/public_members/" + u.getLogin()).send();</span>
|
||
<span class="nc" id="L371"> }</span>
|
||
|
||
/**
|
||
* Are projects enabled for organization boolean.
|
||
*
|
||
* @return the boolean
|
||
*/
|
||
public boolean areOrganizationProjectsEnabled() {
|
||
<span class="fc" id="L379"> return has_organization_projects;</span>
|
||
}
|
||
|
||
/**
|
||
* Sets organization projects enabled status boolean
|
||
*
|
||
* @param newStatus
|
||
* enable status
|
||
* @throws IOException
|
||
* the io exception
|
||
*/
|
||
public void enableOrganizationProjects(boolean newStatus) throws IOException {
|
||
<span class="fc" id="L391"> edit("has_organization_projects", newStatus);</span>
|
||
<span class="fc" id="L392"> }</span>
|
||
|
||
private void edit(String key, Object value) throws IOException {
|
||
<span class="fc" id="L395"> root.createRequest()</span>
|
||
<span class="fc" id="L396"> .withUrlPath(String.format("/orgs/%s", login))</span>
|
||
<span class="fc" id="L397"> .method("PATCH")</span>
|
||
<span class="fc" id="L398"> .with(key, value)</span>
|
||
<span class="fc" id="L399"> .fetchInto(this);</span>
|
||
<span class="fc" id="L400"> }</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="L412"> return root.createRequest()</span>
|
||
<span class="nc" id="L413"> .withPreview(INERTIA)</span>
|
||
<span class="nc" id="L414"> .with("state", status)</span>
|
||
<span class="nc" id="L415"> .withUrlPath(String.format("/orgs/%s/projects", login))</span>
|
||
<span class="nc" id="L416"> .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="L427"> 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="L442"> return root.createRequest()</span>
|
||
<span class="fc" id="L443"> .method("POST")</span>
|
||
<span class="fc" id="L444"> .withPreview(INERTIA)</span>
|
||
<span class="fc" id="L445"> .with("name", name)</span>
|
||
<span class="fc" id="L446"> .with("body", body)</span>
|
||
<span class="fc" id="L447"> .withUrlPath(String.format("/orgs/%s/projects", login))</span>
|
||
<span class="fc" id="L448"> .fetch(GHProject.class)</span>
|
||
<span class="fc" id="L449"> .wrap(root);</span>
|
||
}
|
||
|
||
/**
|
||
* The enum Permission.
|
||
*/
|
||
<span class="fc" id="L455"> public enum Permission {</span>
|
||
<span class="fc" id="L456"> ADMIN, MAINTAIN, PUSH, TRIAGE, 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="L476"> Requester post = root.createRequest().method("POST").with("name", name).with("permission", p);</span>
|
||
<span class="fc" id="L477"> List<String> repo_names = new ArrayList<String>();</span>
|
||
<span class="fc bfc" id="L478" title="All 2 branches covered."> for (GHRepository r : repositories) {</span>
|
||
<span class="fc" id="L479"> repo_names.add(login + "/" + r.getName());</span>
|
||
<span class="fc" id="L480"> }</span>
|
||
<span class="fc" id="L481"> post.with("repo_names", repo_names);</span>
|
||
<span class="fc" id="L482"> 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="L502"> 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="L519"> Requester post = root.createRequest().method("POST").with("name", name);</span>
|
||
<span class="fc" id="L520"> List<String> repo_names = new ArrayList<String>();</span>
|
||
<span class="fc bfc" id="L521" title="All 2 branches covered."> for (GHRepository r : repositories) {</span>
|
||
<span class="fc" id="L522"> repo_names.add(login + "/" + r.getName());</span>
|
||
<span class="fc" id="L523"> }</span>
|
||
<span class="fc" id="L524"> post.with("repo_names", repo_names);</span>
|
||
<span class="fc" id="L525"> 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="L542"> 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="L557"> 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="L571"> List<GHRepository> r = new ArrayList<GHRepository>();</span>
|
||
<span class="nc bnc" id="L572" title="All 2 branches missed."> for (GHRepository repository : listRepositories(100)) {</span>
|
||
<span class="nc" id="L573"> repository.wrap(root);</span>
|
||
<span class="nc" id="L574"> List<GHPullRequest> pullRequests = repository.getPullRequests(GHIssueState.OPEN);</span>
|
||
<span class="nc bnc" id="L575" title="All 2 branches missed."> if (pullRequests.size() > 0) {</span>
|
||
<span class="nc" id="L576"> r.add(repository);</span>
|
||
}
|
||
<span class="nc" id="L578"> }</span>
|
||
<span class="nc" id="L579"> 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="L590"> List<GHPullRequest> all = new ArrayList<GHPullRequest>();</span>
|
||
<span class="nc bnc" id="L591" title="All 2 branches missed."> for (GHRepository r : getRepositoriesWithOpenPullRequests()) {</span>
|
||
<span class="nc" id="L592"> all.addAll(r.getPullRequests(GHIssueState.OPEN));</span>
|
||
<span class="nc" id="L593"> }</span>
|
||
<span class="nc" id="L594"> 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="L601"> return root.createRequest()</span>
|
||
<span class="nc" id="L602"> .withUrlPath(String.format("/orgs/%s/events", login))</span>
|
||
<span class="nc" id="L603"> .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="L616"> return root.createRequest()</span>
|
||
<span class="fc" id="L617"> .withUrlPath("/orgs/" + login + "/repos")</span>
|
||
<span class="fc" id="L618"> .toIterable(GHRepository[].class, item -> item.wrap(root))</span>
|
||
<span class="fc" id="L619"> .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="L630"> 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="fc" id="L643"> 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="fc" id="L664"> 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="fc" id="L679"> 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="fc" id="L692"> 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.7.202105040129</span></div></body></html> |