Package org.kohsuke.github
Class GHIssue
- java.lang.Object
-
- org.kohsuke.github.GHObject
-
- org.kohsuke.github.GHIssue
-
- All Implemented Interfaces:
Reactable
- Direct Known Subclasses:
GHPullRequest
public class GHIssue extends GHObject implements Reactable
Represents an issue on GitHub.- Author:
- Eric Maupin, Kohsuke Kawaguchi
- See Also:
GHRepository#getIssue(int)
,GitHub#searchIssues()
,GHIssueSearchBuilder
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GHIssue.PullRequest
The type PullRequest.
-
Field Summary
Fields Modifier and Type Field Description protected GHUser
assignee
The assignee.protected GHUser[]
assignees
The assignees.protected String
body
The body.protected String
closed_at
The closed at.protected GHUser
closed_by
The closed by.protected int
comments
The comments.protected String
html_url
The html url.protected List<GHLabel>
labels
The labels.protected boolean
locked
The locked.protected GHMilestone
milestone
The milestone.protected int
number
The number.protected GHIssue.PullRequest
pull_request
The pull request.protected String
state
The state.protected String
title
The html url.protected GHUser
user
The user.-
Fields inherited from class org.kohsuke.github.GHObject
responseHeaderFields
-
-
Constructor Summary
Constructors Constructor Description GHIssue()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addAssignees(Collection<GHUser> assignees)
Add assignees.void
addAssignees(GHUser... assignees)
Add assignees.List<GHLabel>
addLabels(String... names)
Adds labels to the issue.List<GHLabel>
addLabels(Collection<GHLabel> labels)
Add labels.List<GHLabel>
addLabels(GHLabel... labels)
Add labels.void
assignTo(GHUser user)
Assign to.void
close()
Closes this issue.GHIssueComment
comment(String message)
Updates the issue by adding a comment.GHReaction
createReaction(ReactionContent content)
Creates the reaction.void
deleteReaction(GHReaction reaction)
Delete reaction.protected String
getApiRoute()
Gets api route.URL
getApiURL()
Deprecated.GHUser
getAssignee()
Gets assignee.List<GHUser>
getAssignees()
Gets assignees.String
getBody()
The description of this pull request.Date
getClosedAt()
Gets closed at.GHUser
getClosedBy()
Reports who has closed the issue.List<GHIssueComment>
getComments()
Obtains all the comments associated with this issue.int
getCommentsCount()
Gets comments count.URL
getHtmlUrl()
The HTML page of this issue, like https://github.com/jenkinsci/jenkins/issues/100protected String
getIssuesApiRoute()
Gets issues api route.Collection<GHLabel>
getLabels()
Gets labels.protected static List<String>
getLogins(Collection<GHUser> users)
Gets the logins.GHMilestone
getMilestone()
Gets milestone.int
getNumber()
ID.GHIssue.PullRequest
getPullRequest()
Returns non-null if this issue is a shadow of a pull request.GHRepository
getRepository()
Repository to which the issue belongs.GitHub
getRoot()
Deprecated.For access to theGitHub
instance, use a local copy instead of pulling it out of objects.GHIssueState
getState()
Gets state.String
getTitle()
Gets title.GHUser
getUser()
User who submitted the issue.boolean
isLocked()
Is locked boolean.boolean
isPullRequest()
Is pull request boolean.PagedIterable<GHIssueComment>
listComments()
Obtains all the comments associated with this issue, without any filter.PagedIterable<GHIssueEvent>
listEvents()
Lists events for this issue.PagedIterable<GHReaction>
listReactions()
List reactions.void
lock()
Lock.GHIssueCommentQueryBuilder
queryComments()
Search comments on this issue by specifying filters through a builder pattern.void
removeAssignees(Collection<GHUser> assignees)
Remove assignees.void
removeAssignees(GHUser... assignees)
Remove assignees.List<GHLabel>
removeLabel(String name)
Remove a single label.List<GHLabel>
removeLabels(String... names)
Remove a collection of labels.List<GHLabel>
removeLabels(Collection<GHLabel> labels)
Remove a collection of labels.List<GHLabel>
removeLabels(GHLabel... labels)
Remove a collection of labels.void
reopen()
Reopens this issue.void
setAssignees(Collection<GHUser> assignees)
Sets assignees.void
setAssignees(GHUser... assignees)
Sets assignees.void
setBody(String body)
Sets body.void
setLabels(String... labels)
Sets labels on the target to a specific list.void
setMilestone(GHMilestone milestone)
Sets the milestone for this issue.void
setTitle(String title)
Sets title.void
unlock()
Unlock.-
Methods inherited from class org.kohsuke.github.GHObject
getCreatedAt, getId, getNodeId, getResponseHeaderFields, getUpdatedAt, getUrl, setResponseHeaderFields, toString
-
-
-
-
Field Detail
-
assignee
protected GHUser assignee
The assignee.
-
assignees
protected GHUser[] assignees
The assignees.
-
state
protected String state
The state.
-
number
protected int number
The number.
-
closed_at
protected String closed_at
The closed at.
-
comments
protected int comments
The comments.
-
body
protected String body
The body.
-
user
protected GHUser user
The user.
-
title
protected String title
The html url.
-
html_url
protected String html_url
The html url.
-
pull_request
protected GHIssue.PullRequest pull_request
The pull request.
-
milestone
protected GHMilestone milestone
The milestone.
-
closed_by
protected GHUser closed_by
The closed by.
-
locked
protected boolean locked
The locked.
-
-
Method Detail
-
getRepository
public GHRepository getRepository()
Repository to which the issue belongs.- Returns:
- the repository
-
getBody
public String getBody()
The description of this pull request.- Returns:
- the body
-
getNumber
public int getNumber()
ID.- Returns:
- the number
-
getHtmlUrl
public URL getHtmlUrl()
The HTML page of this issue, like https://github.com/jenkinsci/jenkins/issues/100- Specified by:
getHtmlUrl
in classGHObject
- Returns:
- the html url
-
getTitle
public String getTitle()
Gets title.- Returns:
- the title
-
isLocked
public boolean isLocked()
Is locked boolean.- Returns:
- the boolean
-
getState
public GHIssueState getState()
Gets state.- Returns:
- the state
-
getLabels
public Collection<GHLabel> getLabels()
Gets labels.- Returns:
- the labels
-
getClosedAt
public Date getClosedAt()
Gets closed at.- Returns:
- the closed at
-
getApiURL
@Deprecated public URL getApiURL()
Deprecated.Gets api url.- Returns:
- API URL of this object.
-
lock
public void lock() throws IOException
Lock.- Throws:
IOException
- the io exception
-
unlock
public void unlock() throws IOException
Unlock.- Throws:
IOException
- the io exception
-
comment
@WithBridgeMethods(void.class) public GHIssueComment comment(String message) throws IOException
Updates the issue by adding a comment.- Parameters:
message
- the message- Returns:
- Newly posted comment.
- Throws:
IOException
- the io exception
-
close
public void close() throws IOException
Closes this issue.- Throws:
IOException
- the io exception
-
reopen
public void reopen() throws IOException
Reopens this issue.- Throws:
IOException
- the io exception
-
setTitle
public void setTitle(String title) throws IOException
Sets title.- Parameters:
title
- the title- Throws:
IOException
- the io exception
-
setBody
public void setBody(String body) throws IOException
Sets body.- Parameters:
body
- the body- Throws:
IOException
- the io exception
-
setMilestone
public void setMilestone(GHMilestone milestone) throws IOException
Sets the milestone for this issue.- Parameters:
milestone
- The milestone to assign this issue to. Use null to remove the milestone for this issue.- Throws:
IOException
- The io exception
-
assignTo
public void assignTo(GHUser user) throws IOException
Assign to.- Parameters:
user
- the user- Throws:
IOException
- the io exception
-
setLabels
public void setLabels(String... labels) throws IOException
Sets labels on the target to a specific list.- Parameters:
labels
- the labels- Throws:
IOException
- the io exception
-
addLabels
@WithBridgeMethods(void.class) public List<GHLabel> addLabels(String... names) throws IOException
Adds labels to the issue. Labels that are already present on the target are ignored.- Parameters:
names
- Names of the label- Returns:
- the complete list of labels including the new additions
- Throws:
IOException
- the io exception
-
addLabels
@WithBridgeMethods(void.class) public List<GHLabel> addLabels(GHLabel... labels) throws IOException
Add labels. Labels that are already present on the target are ignored.- Parameters:
labels
- the labels- Returns:
- the complete list of labels including the new additions
- Throws:
IOException
- the io exception
-
addLabels
@WithBridgeMethods(void.class) public List<GHLabel> addLabels(Collection<GHLabel> labels) throws IOException
Add labels. Labels that are already present on the target are ignored.- Parameters:
labels
- the labels- Returns:
- the complete list of labels including the new additions
- Throws:
IOException
- the io exception
-
removeLabel
@WithBridgeMethods(void.class) public List<GHLabel> removeLabel(String name) throws IOException
Remove a single label. Attempting to remove a label that is not present throwsGHFileNotFoundException
.- Parameters:
name
- the name- Returns:
- the remaining list of labels
- Throws:
IOException
- the io exception, throwsGHFileNotFoundException
if label was not present.
-
removeLabels
@WithBridgeMethods(void.class) public List<GHLabel> removeLabels(String... names) throws IOException
Remove a collection of labels. Attempting to remove labels that are not present on the target are ignored.- Parameters:
names
- the names- Returns:
- the remaining list of labels
- Throws:
IOException
- the io exception
-
removeLabels
@WithBridgeMethods(void.class) public List<GHLabel> removeLabels(GHLabel... labels) throws IOException
Remove a collection of labels. Attempting to remove labels that are not present on the target are ignored.- Parameters:
labels
- the labels- Returns:
- the remaining list of labels
- Throws:
IOException
- the io exception- See Also:
#removeLabels(String...)
-
removeLabels
@WithBridgeMethods(void.class) public List<GHLabel> removeLabels(Collection<GHLabel> labels) throws IOException
Remove a collection of labels. Attempting to remove labels that are not present on the target are ignored.- Parameters:
labels
- the labels- Returns:
- the remaining list of labels
- Throws:
IOException
- the io exception
-
getComments
public List<GHIssueComment> getComments() throws IOException
Obtains all the comments associated with this issue.- Returns:
- the comments
- Throws:
IOException
- the io exception- See Also:
#listComments()
-
listComments
public PagedIterable<GHIssueComment> listComments() throws IOException
Obtains all the comments associated with this issue, without any filter.- Returns:
- the paged iterable
- Throws:
IOException
- the io exception- See Also:
- List issue comments,
queryComments to apply filters.
-
queryComments
public GHIssueCommentQueryBuilder queryComments()
Search comments on this issue by specifying filters through a builder pattern.- Returns:
- the query builder
- See Also:
- List issue comments
-
createReaction
@Preview(SQUIRREL_GIRL) public GHReaction createReaction(ReactionContent content) throws IOException
Creates the reaction.- Specified by:
createReaction
in interfaceReactable
- Parameters:
content
- the content- Returns:
- the GH reaction
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
deleteReaction
public void deleteReaction(GHReaction reaction) throws IOException
Delete reaction.- Specified by:
deleteReaction
in interfaceReactable
- Parameters:
reaction
- the reaction- Throws:
IOException
- Signals that an I/O exception has occurred.
-
listReactions
@Preview(SQUIRREL_GIRL) public PagedIterable<GHReaction> listReactions()
List reactions.- Specified by:
listReactions
in interfaceReactable
- Returns:
- the paged iterable
-
addAssignees
public void addAssignees(GHUser... assignees) throws IOException
Add assignees.- Parameters:
assignees
- the assignees- Throws:
IOException
- the io exception
-
addAssignees
public void addAssignees(Collection<GHUser> assignees) throws IOException
Add assignees.- Parameters:
assignees
- the assignees- Throws:
IOException
- the io exception
-
setAssignees
public void setAssignees(GHUser... assignees) throws IOException
Sets assignees.- Parameters:
assignees
- the assignees- Throws:
IOException
- the io exception
-
setAssignees
public void setAssignees(Collection<GHUser> assignees) throws IOException
Sets assignees.- Parameters:
assignees
- the assignees- Throws:
IOException
- the io exception
-
removeAssignees
public void removeAssignees(GHUser... assignees) throws IOException
Remove assignees.- Parameters:
assignees
- the assignees- Throws:
IOException
- the io exception
-
removeAssignees
public void removeAssignees(Collection<GHUser> assignees) throws IOException
Remove assignees.- Parameters:
assignees
- the assignees- Throws:
IOException
- the io exception
-
getApiRoute
protected String getApiRoute()
Gets api route.- Returns:
- the api route
-
getIssuesApiRoute
protected String getIssuesApiRoute()
Gets issues api route.- Returns:
- the issues api route
-
getAssignee
public GHUser getAssignee() throws IOException
Gets assignee.- Returns:
- the assignee
- Throws:
IOException
- the io exception
-
getUser
public GHUser getUser() throws IOException
User who submitted the issue.- Returns:
- the user
- Throws:
IOException
- the io exception
-
getClosedBy
public GHUser getClosedBy() throws IOException
Reports who has closed the issue.Note that GitHub doesn't always seem to report this information even for an issue that's already closed. See https://github.com/kohsuke/github-api/issues/60.
- Returns:
- the closed by
- Throws:
IOException
- the io exception
-
getCommentsCount
public int getCommentsCount()
Gets comments count.- Returns:
- the comments count
-
getPullRequest
public GHIssue.PullRequest getPullRequest()
Returns non-null if this issue is a shadow of a pull request.- Returns:
- the pull request
-
isPullRequest
public boolean isPullRequest()
Is pull request boolean.- Returns:
- the boolean
-
getMilestone
public GHMilestone getMilestone()
Gets milestone.- Returns:
- the milestone
-
getLogins
protected static List<String> getLogins(Collection<GHUser> users)
Gets the logins.- Parameters:
users
- the users- Returns:
- the logins
-
listEvents
public PagedIterable<GHIssueEvent> listEvents() throws IOException
Lists events for this issue. See https://developer.github.com/v3/issues/events/- Returns:
- the paged iterable
- Throws:
IOException
- the io exception
-
getRoot
@Deprecated public GitHub getRoot()
Deprecated.For access to theGitHub
instance, use a local copy instead of pulling it out of objects.Get the rootGitHub
instance for this object.- Returns:
- the root
GitHub
instance
-
-