forked from hub4j/github-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGHMembership.java
More file actions
106 lines (94 loc) · 2.31 KB
/
Copy pathGHMembership.java
File metadata and controls
106 lines (94 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package org.kohsuke.github;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
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()
*/
public class GHMembership extends GitHubInteractiveObject {
String url;
String state;
String role;
GHUser user;
GHOrganization organization;
/**
* Gets url.
*
* @return the url
*/
public URL getUrl() {
return GitHubClient.parseURL(url);
}
/**
* Gets state.
*
* @return the state
*/
public State getState() {
return Enum.valueOf(State.class, state.toUpperCase(Locale.ENGLISH));
}
/**
* Gets role.
*
* @return the role
*/
public Role getRole() {
return Enum.valueOf(Role.class, role.toUpperCase(Locale.ENGLISH));
}
/**
* Gets user.
*
* @return the user
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
public GHUser getUser() {
return user;
}
/**
* Gets organization.
*
* @return the organization
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
public GHOrganization getOrganization() {
return organization;
}
/**
* Accepts a pending invitation to an organization.
*
* @throws IOException
* the io exception
* @see GHMyself#getMembership(GHOrganization) GHMyself#getMembership(GHOrganization)
*/
public void activate() throws IOException {
root().createRequest().method("PATCH").with("state", State.ACTIVE).withUrlPath(url).fetchInto(this);
}
GHMembership wrap(GitHub root) {
if (user != null)
user = root.getUser(user);
return this;
}
/**
* Role of a user in an organization.
*/
public enum Role {
/**
* Organization owner.
*/
ADMIN,
/**
* Non-owner organization member.
*/
MEMBER;
}
/**
* Whether a role is currently active or waiting for acceptance (pending)
*/
public enum State {
ACTIVE, PENDING;
}
}