mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-11 08:21:23 +00:00
373 lines
13 KiB
HTML
373 lines
13 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>GHAppInstallation.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">GHAppInstallation.java</span></div><h1>GHAppInstallation.java</h1><pre class="source lang-java linenums">package org.kohsuke.github;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
import org.kohsuke.github.internal.EnumUtils;
|
|
|
|
import java.io.IOException;
|
|
import java.net.MalformedURLException;
|
|
import java.net.URL;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
|
|
import static org.kohsuke.github.internal.Previews.GAMBIT;
|
|
import static org.kohsuke.github.internal.Previews.MACHINE_MAN;
|
|
|
|
/**
|
|
* A Github App Installation.
|
|
*
|
|
* @author Paulo Miguel Almeida
|
|
* @see GHApp#listInstallations() GHApp#listInstallations()
|
|
* @see GHApp#getInstallationById(long) GHApp#getInstallationById(long)
|
|
* @see GHApp#getInstallationByOrganization(String) GHApp#getInstallationByOrganization(String)
|
|
* @see GHApp#getInstallationByRepository(String, String) GHApp#getInstallationByRepository(String, String)
|
|
* @see GHApp#getInstallationByUser(String) GHApp#getInstallationByUser(String)
|
|
*/
|
|
<span class="fc" id="L26">public class GHAppInstallation extends GHObject {</span>
|
|
private GHUser account;
|
|
|
|
@JsonProperty("access_tokens_url")
|
|
private String accessTokenUrl;
|
|
@JsonProperty("repositories_url")
|
|
private String repositoriesUrl;
|
|
@JsonProperty("app_id")
|
|
private long appId;
|
|
@JsonProperty("target_id")
|
|
private long targetId;
|
|
@JsonProperty("target_type")
|
|
private GHTargetType targetType;
|
|
private Map<String, GHPermissionType> permissions;
|
|
private List<String> events;
|
|
@JsonProperty("single_file_name")
|
|
private String singleFileName;
|
|
@JsonProperty("repository_selection")
|
|
private GHRepositorySelection repositorySelection;
|
|
private String htmlUrl;
|
|
|
|
public URL getHtmlUrl() {
|
|
<span class="nc" id="L48"> return GitHubClient.parseURL(htmlUrl);</span>
|
|
}
|
|
|
|
/**
|
|
* Gets root.
|
|
*
|
|
* @return the root
|
|
*/
|
|
public GitHub getRoot() {
|
|
<span class="fc" id="L57"> return root;</span>
|
|
}
|
|
|
|
/**
|
|
* Sets root.
|
|
*
|
|
* @param root
|
|
* the root
|
|
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
|
*/
|
|
@Deprecated
|
|
public void setRoot(GitHub root) {
|
|
<span class="nc" id="L69"> this.root = root;</span>
|
|
<span class="nc" id="L70"> }</span>
|
|
|
|
/**
|
|
* Gets account.
|
|
*
|
|
* @return the account
|
|
*/
|
|
public GHUser getAccount() {
|
|
<span class="fc" id="L78"> return account;</span>
|
|
}
|
|
|
|
/**
|
|
* Sets account.
|
|
*
|
|
* @param account
|
|
* the account
|
|
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
|
*/
|
|
@Deprecated
|
|
public void setAccount(GHUser account) {
|
|
<span class="nc" id="L90"> this.account = account;</span>
|
|
<span class="nc" id="L91"> }</span>
|
|
|
|
/**
|
|
* Gets access token url.
|
|
*
|
|
* @return the access token url
|
|
*/
|
|
public String getAccessTokenUrl() {
|
|
<span class="fc" id="L99"> return accessTokenUrl;</span>
|
|
}
|
|
|
|
/**
|
|
* Sets access token url.
|
|
*
|
|
* @param accessTokenUrl
|
|
* the access token url
|
|
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
|
*/
|
|
@Deprecated
|
|
public void setAccessTokenUrl(String accessTokenUrl) {
|
|
<span class="nc" id="L111"> this.accessTokenUrl = accessTokenUrl;</span>
|
|
<span class="nc" id="L112"> }</span>
|
|
|
|
/**
|
|
* Gets repositories url.
|
|
*
|
|
* @return the repositories url
|
|
*/
|
|
public String getRepositoriesUrl() {
|
|
<span class="fc" id="L120"> return repositoriesUrl;</span>
|
|
}
|
|
|
|
/**
|
|
* List repositories that this app installation can access.
|
|
*
|
|
* @return the paged iterable
|
|
*/
|
|
@Preview(MACHINE_MAN)
|
|
@Deprecated
|
|
public PagedSearchIterable<GHRepository> listRepositories() {
|
|
GitHubRequest request;
|
|
|
|
try {
|
|
<span class="fc" id="L134"> request = root.createRequest().withPreview(MACHINE_MAN).withUrlPath("/installation/repositories").build();</span>
|
|
<span class="nc" id="L135"> } catch (MalformedURLException e) {</span>
|
|
<span class="nc" id="L136"> throw new GHException("", e);</span>
|
|
<span class="fc" id="L137"> }</span>
|
|
|
|
<span class="fc" id="L139"> return new PagedSearchIterable<>(root, request, GHAppInstallationRepositoryResult.class);</span>
|
|
}
|
|
|
|
private static class GHAppInstallationRepositoryResult extends SearchResult<GHRepository> {
|
|
private GHRepository[] repositories;
|
|
|
|
@Override
|
|
GHRepository[] getItems(GitHub root) {
|
|
<span class="fc bfc" id="L147" title="All 2 branches covered."> for (GHRepository item : repositories)</span>
|
|
<span class="fc" id="L148"> item.wrap(root);</span>
|
|
<span class="fc" id="L149"> return repositories;</span>
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Sets repositories url.
|
|
*
|
|
* @param repositoriesUrl
|
|
* the repositories url
|
|
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
|
*/
|
|
@Deprecated
|
|
public void setRepositoriesUrl(String repositoriesUrl) {
|
|
<span class="nc" id="L162"> this.repositoriesUrl = repositoriesUrl;</span>
|
|
<span class="nc" id="L163"> }</span>
|
|
|
|
/**
|
|
* Gets app id.
|
|
*
|
|
* @return the app id
|
|
*/
|
|
public long getAppId() {
|
|
<span class="fc" id="L171"> return appId;</span>
|
|
}
|
|
|
|
/**
|
|
* Sets app id.
|
|
*
|
|
* @param appId
|
|
* the app id
|
|
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
|
*/
|
|
@Deprecated
|
|
public void setAppId(long appId) {
|
|
<span class="nc" id="L183"> this.appId = appId;</span>
|
|
<span class="nc" id="L184"> }</span>
|
|
|
|
/**
|
|
* Gets target id.
|
|
*
|
|
* @return the target id
|
|
*/
|
|
public long getTargetId() {
|
|
<span class="fc" id="L192"> return targetId;</span>
|
|
}
|
|
|
|
/**
|
|
* Sets target id.
|
|
*
|
|
* @param targetId
|
|
* the target id
|
|
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
|
*/
|
|
@Deprecated
|
|
public void setTargetId(long targetId) {
|
|
<span class="nc" id="L204"> this.targetId = targetId;</span>
|
|
<span class="nc" id="L205"> }</span>
|
|
|
|
/**
|
|
* Gets target type.
|
|
*
|
|
* @return the target type
|
|
*/
|
|
public GHTargetType getTargetType() {
|
|
<span class="fc" id="L213"> return targetType;</span>
|
|
}
|
|
|
|
/**
|
|
* Sets target type.
|
|
*
|
|
* @param targetType
|
|
* the target type
|
|
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
|
*/
|
|
@Deprecated
|
|
public void setTargetType(GHTargetType targetType) {
|
|
<span class="nc" id="L225"> this.targetType = targetType;</span>
|
|
<span class="nc" id="L226"> }</span>
|
|
|
|
/**
|
|
* Gets permissions.
|
|
*
|
|
* @return the permissions
|
|
*/
|
|
public Map<String, GHPermissionType> getPermissions() {
|
|
<span class="fc" id="L234"> 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, GHPermissionType> permissions) {
|
|
<span class="nc" id="L246"> this.permissions = permissions;</span>
|
|
<span class="nc" id="L247"> }</span>
|
|
|
|
/**
|
|
* Gets events.
|
|
*
|
|
* @return the events
|
|
*/
|
|
public List<GHEvent> getEvents() {
|
|
<span class="fc" id="L255"> return events.stream()</span>
|
|
<span class="fc" id="L256"> .map(e -> EnumUtils.getEnumOrDefault(GHEvent.class, e, GHEvent.UNKNOWN))</span>
|
|
<span class="fc" id="L257"> .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="L269"> this.events = events.stream().map(GHEvent::symbol).collect(Collectors.toList());</span>
|
|
<span class="nc" id="L270"> }</span>
|
|
|
|
/**
|
|
* Gets single file name.
|
|
*
|
|
* @return the single file name
|
|
*/
|
|
public String getSingleFileName() {
|
|
<span class="fc" id="L278"> return singleFileName;</span>
|
|
}
|
|
|
|
/**
|
|
* Sets single file name.
|
|
*
|
|
* @param singleFileName
|
|
* the single file name
|
|
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
|
*/
|
|
@Deprecated
|
|
public void setSingleFileName(String singleFileName) {
|
|
<span class="nc" id="L290"> this.singleFileName = singleFileName;</span>
|
|
<span class="nc" id="L291"> }</span>
|
|
|
|
/**
|
|
* Gets repository selection.
|
|
*
|
|
* @return the repository selection
|
|
*/
|
|
public GHRepositorySelection getRepositorySelection() {
|
|
<span class="fc" id="L299"> return repositorySelection;</span>
|
|
}
|
|
|
|
/**
|
|
* Sets repository selection.
|
|
*
|
|
* @param repositorySelection
|
|
* the repository selection
|
|
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
|
*/
|
|
@Deprecated
|
|
public void setRepositorySelection(GHRepositorySelection repositorySelection) {
|
|
<span class="nc" id="L311"> this.repositorySelection = repositorySelection;</span>
|
|
<span class="nc" id="L312"> }</span>
|
|
|
|
GHAppInstallation wrapUp(GitHub root) {
|
|
<span class="fc" id="L315"> this.root = root;</span>
|
|
<span class="fc" id="L316"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Delete a Github App installation
|
|
* <p>
|
|
* You must use a JWT to access this endpoint.
|
|
*
|
|
* @throws IOException
|
|
* on error
|
|
* @see <a href="https://developer.github.com/v3/apps/#delete-an-installation">Delete an installation</a>
|
|
*/
|
|
@Preview(GAMBIT)
|
|
@Deprecated
|
|
public void deleteInstallation() throws IOException {
|
|
<span class="fc" id="L331"> root.createRequest()</span>
|
|
<span class="fc" id="L332"> .method("DELETE")</span>
|
|
<span class="fc" id="L333"> .withPreview(GAMBIT)</span>
|
|
<span class="fc" id="L334"> .withUrlPath(String.format("/app/installations/%d", getId()))</span>
|
|
<span class="fc" id="L335"> .send();</span>
|
|
<span class="fc" id="L336"> }</span>
|
|
|
|
/**
|
|
* Starts a builder that creates a new App Installation Token.
|
|
*
|
|
* <p>
|
|
* You use the returned builder to set various properties, then call {@link GHAppCreateTokenBuilder#create()} to
|
|
* finally create an access token.
|
|
*
|
|
* @param permissions
|
|
* map of permissions for the created token
|
|
* @return a GHAppCreateTokenBuilder instance
|
|
* @deprecated Use {@link GHAppInstallation#createToken()} instead.
|
|
*/
|
|
@BetaApi
|
|
@Deprecated
|
|
public GHAppCreateTokenBuilder createToken(Map<String, GHPermissionType> permissions) {
|
|
<span class="nc" id="L353"> return new GHAppCreateTokenBuilder(root,</span>
|
|
<span class="nc" id="L354"> String.format("/app/installations/%d/access_tokens", getId()),</span>
|
|
permissions);
|
|
}
|
|
|
|
/**
|
|
* Starts a builder that creates a new App Installation Token.
|
|
*
|
|
* <p>
|
|
* You use the returned builder to set various properties, then call {@link GHAppCreateTokenBuilder#create()} to
|
|
* finally create an access token.
|
|
*
|
|
* @return a GHAppCreateTokenBuilder instance
|
|
*/
|
|
@BetaApi
|
|
@Deprecated
|
|
public GHAppCreateTokenBuilder createToken() {
|
|
<span class="fc" id="L370"> return new GHAppCreateTokenBuilder(root, String.format("/app/installations/%d/access_tokens", getId()));</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> |