mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-14 15:50:05 +00:00
184 lines
7.3 KiB
HTML
184 lines
7.3 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>GHProjectColumn.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">GHProjectColumn.java</span></div><h1>GHProjectColumn.java</h1><pre class="source lang-java linenums">package org.kohsuke.github;
|
|
|
|
import java.io.FileNotFoundException;
|
|
import java.io.IOException;
|
|
import java.net.URL;
|
|
|
|
import static org.kohsuke.github.internal.Previews.INERTIA;
|
|
|
|
/**
|
|
* The type GHProjectColumn.
|
|
*
|
|
* @author Gunnar Skjold
|
|
*/
|
|
<span class="fc" id="L14">public class GHProjectColumn extends GHObject {</span>
|
|
protected GHProject project;
|
|
|
|
private String name;
|
|
private String project_url;
|
|
|
|
@Override
|
|
public URL getHtmlUrl() throws IOException {
|
|
<span class="nc" id="L22"> return null;</span>
|
|
}
|
|
|
|
/**
|
|
* Wrap gh project column.
|
|
*
|
|
* @param root
|
|
* the root
|
|
* @return the gh project column
|
|
*/
|
|
public GHProjectColumn wrap(GitHub root) {
|
|
<span class="fc" id="L33"> this.root = root;</span>
|
|
<span class="fc" id="L34"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Wrap gh project column.
|
|
*
|
|
* @param project
|
|
* the project
|
|
* @return the gh project column
|
|
*/
|
|
public GHProjectColumn wrap(GHProject project) {
|
|
<span class="fc" id="L45"> this.project = project;</span>
|
|
<span class="fc" id="L46"> this.root = project.root;</span>
|
|
<span class="fc" id="L47"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets root.
|
|
*
|
|
* @return the root
|
|
*/
|
|
public GitHub getRoot() {
|
|
<span class="nc" id="L56"> return root;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets project.
|
|
*
|
|
* @return the project
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public GHProject getProject() throws IOException {
|
|
<span class="nc bnc" id="L67" title="All 2 branches missed."> if (project == null) {</span>
|
|
try {
|
|
<span class="nc" id="L69"> project = root.createRequest().withUrlPath(getProjectUrl().getPath()).fetch(GHProject.class).wrap(root);</span>
|
|
<span class="nc" id="L70"> } catch (FileNotFoundException e) {</span>
|
|
<span class="nc" id="L71"> return null;</span>
|
|
<span class="nc" id="L72"> }</span>
|
|
}
|
|
<span class="nc" id="L74"> return project;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets name.
|
|
*
|
|
* @return the name
|
|
*/
|
|
public String getName() {
|
|
<span class="fc" id="L83"> return name;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets project url.
|
|
*
|
|
* @return the project url
|
|
*/
|
|
public URL getProjectUrl() {
|
|
<span class="nc" id="L92"> return GitHubClient.parseURL(project_url);</span>
|
|
}
|
|
|
|
/**
|
|
* Sets name.
|
|
*
|
|
* @param name
|
|
* the name
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void setName(String name) throws IOException {
|
|
<span class="fc" id="L104"> edit("name", name);</span>
|
|
<span class="fc" id="L105"> }</span>
|
|
|
|
private void edit(String key, Object value) throws IOException {
|
|
<span class="fc" id="L108"> root.createRequest().method("PATCH").withPreview(INERTIA).with(key, value).withUrlPath(getApiRoute()).send();</span>
|
|
<span class="fc" id="L109"> }</span>
|
|
|
|
/**
|
|
* Gets api route.
|
|
*
|
|
* @return the api route
|
|
*/
|
|
protected String getApiRoute() {
|
|
<span class="fc" id="L117"> return String.format("/projects/columns/%d", getId());</span>
|
|
}
|
|
|
|
/**
|
|
* Delete.
|
|
*
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void delete() throws IOException {
|
|
<span class="fc" id="L127"> root.createRequest().withPreview(INERTIA).method("DELETE").withUrlPath(getApiRoute()).send();</span>
|
|
<span class="fc" id="L128"> }</span>
|
|
|
|
/**
|
|
* List cards paged iterable.
|
|
*
|
|
* @return the paged iterable
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public PagedIterable<GHProjectCard> listCards() throws IOException {
|
|
<span class="nc" id="L138"> final GHProjectColumn column = this;</span>
|
|
<span class="nc" id="L139"> return root.createRequest()</span>
|
|
<span class="nc" id="L140"> .withPreview(INERTIA)</span>
|
|
<span class="nc" id="L141"> .withUrlPath(String.format("/projects/columns/%d/cards", getId()))</span>
|
|
<span class="nc" id="L142"> .toIterable(GHProjectCard[].class, item -> item.wrap(column));</span>
|
|
}
|
|
|
|
/**
|
|
* Create card gh project card.
|
|
*
|
|
* @param note
|
|
* the note
|
|
* @return the gh project card
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public GHProjectCard createCard(String note) throws IOException {
|
|
<span class="fc" id="L155"> return root.createRequest()</span>
|
|
<span class="fc" id="L156"> .method("POST")</span>
|
|
<span class="fc" id="L157"> .withPreview(INERTIA)</span>
|
|
<span class="fc" id="L158"> .with("note", note)</span>
|
|
<span class="fc" id="L159"> .withUrlPath(String.format("/projects/columns/%d/cards", getId()))</span>
|
|
<span class="fc" id="L160"> .fetch(GHProjectCard.class)</span>
|
|
<span class="fc" id="L161"> .wrap(this);</span>
|
|
}
|
|
|
|
/**
|
|
* Create card gh project card.
|
|
*
|
|
* @param issue
|
|
* the issue
|
|
* @return the gh project card
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public GHProjectCard createCard(GHIssue issue) throws IOException {
|
|
<span class="fc" id="L174"> return root.createRequest()</span>
|
|
<span class="fc" id="L175"> .method("POST")</span>
|
|
<span class="fc" id="L176"> .withPreview(INERTIA)</span>
|
|
<span class="pc bpc" id="L177" title="1 of 2 branches missed."> .with("content_type", issue instanceof GHPullRequest ? "PullRequest" : "Issue")</span>
|
|
<span class="fc" id="L178"> .with("content_id", issue.getId())</span>
|
|
<span class="fc" id="L179"> .withUrlPath(String.format("/projects/columns/%d/cards", getId()))</span>
|
|
<span class="fc" id="L180"> .fetch(GHProjectCard.class)</span>
|
|
<span class="fc" id="L181"> .wrap(this);</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> |