mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-23 00:11:24 +00:00
185 lines
7.3 KiB
HTML
185 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.Previews.INERTIA;
|
|
|
|
/**
|
|
* The type GHProjectColumn.
|
|
*
|
|
* @author Gunnar Skjold
|
|
*/
|
|
<span class="fc" id="L14">public class GHProjectColumn extends GHObject {</span>
|
|
protected GitHub root;
|
|
protected GHProject project;
|
|
|
|
private String name;
|
|
private String project_url;
|
|
|
|
@Override
|
|
public URL getHtmlUrl() throws IOException {
|
|
<span class="nc" id="L23"> 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="L34"> this.root = root;</span>
|
|
<span class="fc" id="L35"> 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="L46"> this.project = project;</span>
|
|
<span class="fc" id="L47"> this.root = project.root;</span>
|
|
<span class="fc" id="L48"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets root.
|
|
*
|
|
* @return the root
|
|
*/
|
|
public GitHub getRoot() {
|
|
<span class="nc" id="L57"> return root;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets project.
|
|
*
|
|
* @return the project
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public GHProject getProject() throws IOException {
|
|
<span class="nc bnc" id="L68" title="All 2 branches missed."> if (project == null) {</span>
|
|
try {
|
|
<span class="nc" id="L70"> project = root.createRequest().withUrlPath(getProjectUrl().getPath()).fetch(GHProject.class).wrap(root);</span>
|
|
<span class="nc" id="L71"> } catch (FileNotFoundException e) {</span>
|
|
<span class="nc" id="L72"> return null;</span>
|
|
<span class="nc" id="L73"> }</span>
|
|
}
|
|
<span class="nc" id="L75"> return project;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets name.
|
|
*
|
|
* @return the name
|
|
*/
|
|
public String getName() {
|
|
<span class="fc" id="L84"> return name;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets project url.
|
|
*
|
|
* @return the project url
|
|
*/
|
|
public URL getProjectUrl() {
|
|
<span class="nc" id="L93"> 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="L105"> edit("name", name);</span>
|
|
<span class="fc" id="L106"> }</span>
|
|
|
|
private void edit(String key, Object value) throws IOException {
|
|
<span class="fc" id="L109"> root.createRequest().method("PATCH").withPreview(INERTIA).with(key, value).withUrlPath(getApiRoute()).send();</span>
|
|
<span class="fc" id="L110"> }</span>
|
|
|
|
/**
|
|
* Gets api route.
|
|
*
|
|
* @return the api route
|
|
*/
|
|
protected String getApiRoute() {
|
|
<span class="fc" id="L118"> return String.format("/projects/columns/%d", id);</span>
|
|
}
|
|
|
|
/**
|
|
* Delete.
|
|
*
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void delete() throws IOException {
|
|
<span class="fc" id="L128"> root.createRequest().withPreview(INERTIA).method("DELETE").withUrlPath(getApiRoute()).send();</span>
|
|
<span class="fc" id="L129"> }</span>
|
|
|
|
/**
|
|
* List cards paged iterable.
|
|
*
|
|
* @return the paged iterable
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public PagedIterable<GHProjectCard> listCards() throws IOException {
|
|
<span class="nc" id="L139"> final GHProjectColumn column = this;</span>
|
|
<span class="nc" id="L140"> return root.createRequest()</span>
|
|
<span class="nc" id="L141"> .withPreview(INERTIA)</span>
|
|
<span class="nc" id="L142"> .withUrlPath(String.format("/projects/columns/%d/cards", id))</span>
|
|
<span class="nc" id="L143"> .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="L156"> return root.createRequest()</span>
|
|
<span class="fc" id="L157"> .method("POST")</span>
|
|
<span class="fc" id="L158"> .withPreview(INERTIA)</span>
|
|
<span class="fc" id="L159"> .with("note", note)</span>
|
|
<span class="fc" id="L160"> .withUrlPath(String.format("/projects/columns/%d/cards", id))</span>
|
|
<span class="fc" id="L161"> .fetch(GHProjectCard.class)</span>
|
|
<span class="fc" id="L162"> .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="L175"> return root.createRequest()</span>
|
|
<span class="fc" id="L176"> .method("POST")</span>
|
|
<span class="fc" id="L177"> .withPreview(INERTIA)</span>
|
|
<span class="pc bpc" id="L178" title="1 of 2 branches missed."> .with("content_type", issue instanceof GHPullRequest ? "PullRequest" : "Issue")</span>
|
|
<span class="fc" id="L179"> .with("content_id", issue.getId())</span>
|
|
<span class="fc" id="L180"> .withUrlPath(String.format("/projects/columns/%d/cards", id))</span>
|
|
<span class="fc" id="L181"> .fetch(GHProjectCard.class)</span>
|
|
<span class="fc" id="L182"> .wrap(this);</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> |