Files
github-api/jacoco/org.kohsuke.github/GHMembership.java.html
2021-06-02 11:09:28 -07:00

106 lines
4.1 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>GHMembership.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> &gt; <a href="index.source.html" class="el_package">org.kohsuke.github</a> &gt; <span class="el_source">GHMembership.java</span></div><h1>GHMembership.java</h1><pre class="source lang-java linenums">package org.kohsuke.github;
import java.io.IOException;
import java.net.URL;
import java.util.Locale;
/**
* Represents a membership of a user in an organization.
*
* @author Kohsuke Kawaguchi
* @see GHMyself#listOrgMemberships() GHMyself#listOrgMemberships()
*/
<span class="fc" id="L13">public class GHMembership extends GitHubInteractiveObject {</span>
String url;
String state;
String role;
GHUser user;
GHOrganization organization;
/**
* Gets url.
*
* @return the url
*/
public URL getUrl() {
<span class="nc" id="L26"> return GitHubClient.parseURL(url);</span>
}
/**
* Gets state.
*
* @return the state
*/
public State getState() {
<span class="fc" id="L35"> return Enum.valueOf(State.class, state.toUpperCase(Locale.ENGLISH));</span>
}
/**
* Gets role.
*
* @return the role
*/
public Role getRole() {
<span class="fc" id="L44"> return Enum.valueOf(Role.class, role.toUpperCase(Locale.ENGLISH));</span>
}
/**
* Gets user.
*
* @return the user
*/
public GHUser getUser() {
<span class="fc" id="L53"> return user;</span>
}
/**
* Gets organization.
*
* @return the organization
*/
public GHOrganization getOrganization() {
<span class="nc" id="L62"> return organization;</span>
}
/**
* Accepts a pending invitation to an organization.
*
* @throws IOException
* the io exception
* @see GHMyself#getMembership(GHOrganization) GHMyself#getMembership(GHOrganization)
*/
public void activate() throws IOException {
<span class="nc" id="L73"> root.createRequest().method(&quot;PATCH&quot;).with(&quot;state&quot;, State.ACTIVE).withUrlPath(url).fetchInto(this);</span>
<span class="nc" id="L74"> }</span>
GHMembership wrap(GitHub root) {
<span class="fc" id="L77"> this.root = root;</span>
<span class="pc bpc" id="L78" title="1 of 2 branches missed."> if (user != null)</span>
<span class="fc" id="L79"> user = root.getUser(user.wrapUp(root));</span>
<span class="pc bpc" id="L80" title="1 of 2 branches missed."> if (organization != null)</span>
<span class="fc" id="L81"> organization.wrapUp(root);</span>
<span class="fc" id="L82"> return this;</span>
}
/**
* Role of a user in an organization.
*/
<span class="fc" id="L88"> public enum Role {</span>
/**
* Organization owner.
*/
<span class="fc" id="L92"> ADMIN,</span>
/**
* Non-owner organization member.
*/
<span class="fc" id="L96"> MEMBER;</span>
}
/**
* Whether a role is currently active or waiting for acceptance (pending)
*/
<span class="fc" id="L102"> public enum State {</span>
<span class="fc" id="L103"> ACTIVE, PENDING;</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>