mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-21 15:50:49 +00:00
91 lines
4.9 KiB
HTML
91 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.internal.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 extends GitHubInteractiveObject {
|
|
protected final Requester builder;
|
|
private final String apiUrlTail;
|
|
|
|
@BetaApi
|
|
@Deprecated
|
|
<span class="fc" id="L23"> GHAppCreateTokenBuilder(GitHub root, String apiUrlTail) {</span>
|
|
<span class="fc" id="L24"> this.root = root;</span>
|
|
<span class="fc" id="L25"> this.apiUrlTail = apiUrlTail;</span>
|
|
<span class="fc" id="L26"> this.builder = root.createRequest();</span>
|
|
<span class="fc" id="L27"> }</span>
|
|
|
|
@BetaApi
|
|
@Deprecated
|
|
GHAppCreateTokenBuilder(GitHub root, String apiUrlTail, Map<String, GHPermissionType> permissions) {
|
|
<span class="nc" id="L32"> this(root, apiUrlTail);</span>
|
|
<span class="nc" id="L33"> permissions(permissions);</span>
|
|
<span class="nc" id="L34"> }</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
|
|
*/
|
|
@BetaApi
|
|
@Deprecated
|
|
public GHAppCreateTokenBuilder repositoryIds(List<Long> repositoryIds) {
|
|
<span class="fc" id="L48"> this.builder.with("repository_ids", repositoryIds);</span>
|
|
<span class="fc" id="L49"> 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
|
|
*/
|
|
@BetaApi
|
|
@Deprecated
|
|
public GHAppCreateTokenBuilder permissions(Map<String, GHPermissionType> permissions) {
|
|
<span class="fc" id="L63"> Map<String, String> retMap = new HashMap<>();</span>
|
|
<span class="fc bfc" id="L64" title="All 2 branches covered."> for (Map.Entry<String, GHPermissionType> entry : permissions.entrySet()) {</span>
|
|
<span class="fc" id="L65"> retMap.put(entry.getKey(), GitHubRequest.transformEnum(entry.getValue()));</span>
|
|
<span class="fc" id="L66"> }</span>
|
|
<span class="fc" id="L67"> builder.with("permissions", retMap);</span>
|
|
<span class="fc" id="L68"> 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(MACHINE_MAN)
|
|
@Deprecated
|
|
public GHAppInstallationToken create() throws IOException {
|
|
<span class="fc" id="L83"> return builder.method("POST")</span>
|
|
<span class="fc" id="L84"> .withPreview(MACHINE_MAN)</span>
|
|
<span class="fc" id="L85"> .withUrlPath(apiUrlTail)</span>
|
|
<span class="fc" id="L86"> .fetch(GHAppInstallationToken.class)</span>
|
|
<span class="fc" id="L87"> .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> |