mirror of
https://github.com/jlengrand/github-api.git
synced 2026-04-13 15:51:08 +00:00
92 lines
4.9 KiB
HTML
92 lines
4.9 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>GHAppCreateTokenBuilder.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">GHAppCreateTokenBuilder.java</span></div><h1>GHAppCreateTokenBuilder.java</h1><pre class="source lang-java linenums">package org.kohsuke.github;
|
|
|
|
import java.io.IOException;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import static org.kohsuke.github.Previews.MACHINE_MAN;
|
|
|
|
/**
|
|
* Creates a access token for a GitHub App Installation
|
|
*
|
|
* @author Paulo Miguel Almeida
|
|
* @see GHAppInstallation#createToken(Map) GHAppInstallation#createToken(Map)
|
|
* @see GHAppInstallation#createToken() GHAppInstallation#createToken()
|
|
*/
|
|
public class GHAppCreateTokenBuilder {
|
|
private final GitHub root;
|
|
protected final Requester builder;
|
|
private final String apiUrlTail;
|
|
|
|
@Preview
|
|
@Deprecated
|
|
<span class="fc" id="L24"> GHAppCreateTokenBuilder(GitHub root, String apiUrlTail) {</span>
|
|
<span class="fc" id="L25"> this.root = root;</span>
|
|
<span class="fc" id="L26"> this.apiUrlTail = apiUrlTail;</span>
|
|
<span class="fc" id="L27"> this.builder = root.createRequest();</span>
|
|
<span class="fc" id="L28"> }</span>
|
|
|
|
@Preview
|
|
@Deprecated
|
|
GHAppCreateTokenBuilder(GitHub root, String apiUrlTail, Map<String, GHPermissionType> permissions) {
|
|
<span class="fc" id="L33"> this(root, apiUrlTail);</span>
|
|
<span class="fc" id="L34"> permissions(permissions);</span>
|
|
<span class="fc" id="L35"> }</span>
|
|
|
|
/**
|
|
* By default the installation token has access to all repositories that the installation can access. To restrict
|
|
* the access to specific repositories, you can provide the repository_ids when creating the token. When you omit
|
|
* repository_ids, the response does not contain neither the repositories nor the permissions key.
|
|
*
|
|
* @param repositoryIds
|
|
* Array containing the repositories Ids
|
|
* @return a GHAppCreateTokenBuilder
|
|
*/
|
|
@Preview
|
|
@Deprecated
|
|
public GHAppCreateTokenBuilder repositoryIds(List<Long> repositoryIds) {
|
|
<span class="fc" id="L49"> this.builder.with("repository_ids", repositoryIds);</span>
|
|
<span class="fc" id="L50"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Set the permissions granted to the access token. The permissions object includes the permission names and their
|
|
* access type.
|
|
*
|
|
* @param permissions
|
|
* Map containing the permission names and types.
|
|
* @return a GHAppCreateTokenBuilder
|
|
*/
|
|
@Preview
|
|
@Deprecated
|
|
public GHAppCreateTokenBuilder permissions(Map<String, GHPermissionType> permissions) {
|
|
<span class="fc" id="L64"> Map<String, String> retMap = new HashMap<>();</span>
|
|
<span class="fc bfc" id="L65" title="All 2 branches covered."> for (Map.Entry<String, GHPermissionType> entry : permissions.entrySet()) {</span>
|
|
<span class="fc" id="L66"> retMap.put(entry.getKey(), GitHubRequest.transformEnum(entry.getValue()));</span>
|
|
<span class="fc" id="L67"> }</span>
|
|
<span class="fc" id="L68"> builder.with("permissions", retMap);</span>
|
|
<span class="fc" id="L69"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Creates an app token with all the parameters.
|
|
* <p>
|
|
* You must use a JWT to access this endpoint.
|
|
*
|
|
* @return a GHAppInstallationToken
|
|
* @throws IOException
|
|
* on error
|
|
*/
|
|
@Preview
|
|
@Deprecated
|
|
public GHAppInstallationToken create() throws IOException {
|
|
<span class="fc" id="L84"> return builder.method("POST")</span>
|
|
<span class="fc" id="L85"> .withPreview(MACHINE_MAN)</span>
|
|
<span class="fc" id="L86"> .withUrlPath(apiUrlTail)</span>
|
|
<span class="fc" id="L87"> .fetch(GHAppInstallationToken.class)</span>
|
|
<span class="fc" id="L88"> .wrapUp(root);</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> |