mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-11 00:11:25 +00:00
298 lines
11 KiB
HTML
298 lines
11 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>GHApp.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">GHApp.java</span></div><h1>GHApp.java</h1><pre class="source lang-java linenums">package org.kohsuke.github;
|
|
|
|
import org.kohsuke.github.internal.EnumUtils;
|
|
|
|
import java.io.IOException;
|
|
import java.net.URL;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
|
|
import static org.kohsuke.github.internal.Previews.MACHINE_MAN;
|
|
|
|
/**
|
|
* A Github App.
|
|
*
|
|
* @author Paulo Miguel Almeida
|
|
* @see GitHub#getApp() GitHub#getApp()
|
|
*/
|
|
<span class="fc" id="L19">public class GHApp extends GHObject {</span>
|
|
|
|
private GHUser owner;
|
|
private String name;
|
|
private String description;
|
|
private String externalUrl;
|
|
private Map<String, String> permissions;
|
|
private List<String> events;
|
|
private long installationsCount;
|
|
private String htmlUrl;
|
|
|
|
/**
|
|
* Gets owner.
|
|
*
|
|
* @return the owner
|
|
*/
|
|
public GHUser getOwner() {
|
|
<span class="fc" id="L36"> return owner;</span>
|
|
}
|
|
|
|
/**
|
|
* Sets owner.
|
|
*
|
|
* @param owner
|
|
* the owner
|
|
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
|
*/
|
|
@Deprecated
|
|
public void setOwner(GHUser owner) {
|
|
<span class="nc" id="L48"> this.owner = owner;</span>
|
|
<span class="nc" id="L49"> }</span>
|
|
|
|
/**
|
|
* Gets name.
|
|
*
|
|
* @return the name
|
|
*/
|
|
public String getName() {
|
|
<span class="fc" id="L57"> return name;</span>
|
|
}
|
|
|
|
/**
|
|
* Sets name.
|
|
*
|
|
* @param name
|
|
* the name
|
|
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
|
*/
|
|
@Deprecated
|
|
public void setName(String name) {
|
|
<span class="nc" id="L69"> this.name = name;</span>
|
|
<span class="nc" id="L70"> }</span>
|
|
|
|
/**
|
|
* Gets description.
|
|
*
|
|
* @return the description
|
|
*/
|
|
public String getDescription() {
|
|
<span class="fc" id="L78"> return description;</span>
|
|
}
|
|
|
|
/**
|
|
* Sets description.
|
|
*
|
|
* @param description
|
|
* the description
|
|
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
|
*/
|
|
@Deprecated
|
|
public void setDescription(String description) {
|
|
<span class="nc" id="L90"> this.description = description;</span>
|
|
<span class="nc" id="L91"> }</span>
|
|
|
|
/**
|
|
* Gets external url.
|
|
*
|
|
* @return the external url
|
|
*/
|
|
public String getExternalUrl() {
|
|
<span class="fc" id="L99"> return externalUrl;</span>
|
|
}
|
|
|
|
/**
|
|
* Sets external url.
|
|
*
|
|
* @param externalUrl
|
|
* the external url
|
|
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
|
*/
|
|
@Deprecated
|
|
public void setExternalUrl(String externalUrl) {
|
|
<span class="nc" id="L111"> this.externalUrl = externalUrl;</span>
|
|
<span class="nc" id="L112"> }</span>
|
|
|
|
/**
|
|
* Gets events.
|
|
*
|
|
* @return the events
|
|
*/
|
|
public List<GHEvent> getEvents() {
|
|
<span class="fc" id="L120"> return events.stream()</span>
|
|
<span class="fc" id="L121"> .map(e -> EnumUtils.getEnumOrDefault(GHEvent.class, e, GHEvent.UNKNOWN))</span>
|
|
<span class="fc" id="L122"> .collect(Collectors.toList());</span>
|
|
}
|
|
|
|
/**
|
|
* Sets events.
|
|
*
|
|
* @param events
|
|
* the events
|
|
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
|
*/
|
|
@Deprecated
|
|
public void setEvents(List<GHEvent> events) {
|
|
<span class="nc" id="L134"> this.events = events.stream().map(GHEvent::symbol).collect(Collectors.toList());</span>
|
|
<span class="nc" id="L135"> }</span>
|
|
|
|
/**
|
|
* Gets installations count.
|
|
*
|
|
* @return the installations count
|
|
*/
|
|
public long getInstallationsCount() {
|
|
<span class="fc" id="L143"> return installationsCount;</span>
|
|
}
|
|
|
|
/**
|
|
* Sets installations count.
|
|
*
|
|
* @param installationsCount
|
|
* the installations count
|
|
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
|
*/
|
|
@Deprecated
|
|
public void setInstallationsCount(long installationsCount) {
|
|
<span class="nc" id="L155"> this.installationsCount = installationsCount;</span>
|
|
<span class="nc" id="L156"> }</span>
|
|
|
|
public URL getHtmlUrl() {
|
|
<span class="fc" id="L159"> return GitHubClient.parseURL(htmlUrl);</span>
|
|
}
|
|
|
|
/**
|
|
* Gets permissions.
|
|
*
|
|
* @return the permissions
|
|
*/
|
|
public Map<String, String> getPermissions() {
|
|
<span class="fc" id="L168"> return permissions;</span>
|
|
}
|
|
|
|
/**
|
|
* Sets permissions.
|
|
*
|
|
* @param permissions
|
|
* the permissions
|
|
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
|
*/
|
|
@Deprecated
|
|
public void setPermissions(Map<String, String> permissions) {
|
|
<span class="nc" id="L180"> this.permissions = permissions;</span>
|
|
<span class="nc" id="L181"> }</span>
|
|
|
|
GHApp wrapUp(GitHub root) {
|
|
<span class="fc" id="L184"> this.root = root;</span>
|
|
<span class="fc" id="L185"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Obtains all the installations associated with this app.
|
|
* <p>
|
|
* You must use a JWT to access this endpoint.
|
|
*
|
|
* @return a list of App installations
|
|
* @see <a href="https://developer.github.com/v3/apps/#list-installations">List installations</a>
|
|
*/
|
|
@Preview(MACHINE_MAN)
|
|
@Deprecated
|
|
public PagedIterable<GHAppInstallation> listInstallations() {
|
|
<span class="fc" id="L199"> return root.createRequest()</span>
|
|
<span class="fc" id="L200"> .withPreview(MACHINE_MAN)</span>
|
|
<span class="fc" id="L201"> .withUrlPath("/app/installations")</span>
|
|
<span class="fc" id="L202"> .toIterable(GHAppInstallation[].class, item -> item.wrapUp(root));</span>
|
|
}
|
|
|
|
/**
|
|
* Obtain an installation associated with this app.
|
|
* <p>
|
|
* You must use a JWT to access this endpoint.
|
|
*
|
|
* @param id
|
|
* Installation Id
|
|
* @return a GHAppInstallation
|
|
* @throws IOException
|
|
* on error
|
|
* @see <a href="https://developer.github.com/v3/apps/#get-an-installation">Get an installation</a>
|
|
*/
|
|
@Preview(MACHINE_MAN)
|
|
@Deprecated
|
|
public GHAppInstallation getInstallationById(long id) throws IOException {
|
|
<span class="fc" id="L220"> return root.createRequest()</span>
|
|
<span class="fc" id="L221"> .withPreview(MACHINE_MAN)</span>
|
|
<span class="fc" id="L222"> .withUrlPath(String.format("/app/installations/%d", id))</span>
|
|
<span class="fc" id="L223"> .fetch(GHAppInstallation.class)</span>
|
|
<span class="fc" id="L224"> .wrapUp(root);</span>
|
|
}
|
|
|
|
/**
|
|
* Obtain an organization installation associated with this app.
|
|
* <p>
|
|
* You must use a JWT to access this endpoint.
|
|
*
|
|
* @param name
|
|
* Organization name
|
|
* @return a GHAppInstallation
|
|
* @throws IOException
|
|
* on error
|
|
* @see <a href="https://developer.github.com/v3/apps/#get-an-organization-installation">Get an organization
|
|
* installation</a>
|
|
*/
|
|
@Preview(MACHINE_MAN)
|
|
@Deprecated
|
|
public GHAppInstallation getInstallationByOrganization(String name) throws IOException {
|
|
<span class="fc" id="L243"> return root.createRequest()</span>
|
|
<span class="fc" id="L244"> .withPreview(MACHINE_MAN)</span>
|
|
<span class="fc" id="L245"> .withUrlPath(String.format("/orgs/%s/installation", name))</span>
|
|
<span class="fc" id="L246"> .fetch(GHAppInstallation.class)</span>
|
|
<span class="fc" id="L247"> .wrapUp(root);</span>
|
|
}
|
|
|
|
/**
|
|
* Obtain an repository installation associated with this app.
|
|
* <p>
|
|
* You must use a JWT to access this endpoint.
|
|
*
|
|
* @param ownerName
|
|
* Organization or user name
|
|
* @param repositoryName
|
|
* Repository name
|
|
* @return a GHAppInstallation
|
|
* @throws IOException
|
|
* on error
|
|
* @see <a href="https://developer.github.com/v3/apps/#get-a-repository-installation">Get a repository
|
|
* installation</a>
|
|
*/
|
|
@Preview(MACHINE_MAN)
|
|
@Deprecated
|
|
public GHAppInstallation getInstallationByRepository(String ownerName, String repositoryName) throws IOException {
|
|
<span class="fc" id="L268"> return root.createRequest()</span>
|
|
<span class="fc" id="L269"> .withPreview(MACHINE_MAN)</span>
|
|
<span class="fc" id="L270"> .withUrlPath(String.format("/repos/%s/%s/installation", ownerName, repositoryName))</span>
|
|
<span class="fc" id="L271"> .fetch(GHAppInstallation.class)</span>
|
|
<span class="fc" id="L272"> .wrapUp(root);</span>
|
|
}
|
|
|
|
/**
|
|
* Obtain a user installation associated with this app.
|
|
* <p>
|
|
* You must use a JWT to access this endpoint.
|
|
*
|
|
* @param name
|
|
* user name
|
|
* @return a GHAppInstallation
|
|
* @throws IOException
|
|
* on error
|
|
* @see <a href="https://developer.github.com/v3/apps/#get-a-user-installation">Get a user installation</a>
|
|
*/
|
|
@Preview(MACHINE_MAN)
|
|
@Deprecated
|
|
public GHAppInstallation getInstallationByUser(String name) throws IOException {
|
|
<span class="fc" id="L290"> return root.createRequest()</span>
|
|
<span class="fc" id="L291"> .withPreview(MACHINE_MAN)</span>
|
|
<span class="fc" id="L292"> .withUrlPath(String.format("/users/%s/installation", name))</span>
|
|
<span class="fc" id="L293"> .fetch(GHAppInstallation.class)</span>
|
|
<span class="fc" id="L294"> .wrapUp(root);</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> |