Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
4b727853
Unverified
Commit
4b727853
authored
Jul 07, 2018
by
Greg Messner
Committed by
GitHub
Jul 07, 2018
Browse files
Add Epic and Epic Issues API support (#218)
parent
2263d761
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
4b727853
...
@@ -11,7 +11,7 @@ To utilize the GitLab API for Java in your project, simply add the following dep
...
@@ -11,7 +11,7 @@ To utilize the GitLab API for Java in your project, simply add the following dep
```
java
```
java
dependencies
{
dependencies
{
...
...
compile
group:
'
org
.
gitlab4j
'
,
name:
'
gitlab4j
-
api
'
,
version:
'
4.8
.
29
'
compile
group:
'
org
.
gitlab4j
'
,
name:
'
gitlab4j
-
api
'
,
version:
'
4.8
.
30
'
}
}
```
```
...
@@ -20,7 +20,7 @@ dependencies {
...
@@ -20,7 +20,7 @@ dependencies {
<dependency>
<dependency>
<groupId>
org.gitlab4j
</groupId>
<groupId>
org.gitlab4j
</groupId>
<artifactId>
gitlab4j-api
</artifactId>
<artifactId>
gitlab4j-api
</artifactId>
<version>
4.8.
29
</version>
<version>
4.8.
30
</version>
</dependency>
</dependency>
```
```
...
@@ -137,6 +137,7 @@ The API has been broken up into sub APIs classes to make it easier to learn and
...
@@ -137,6 +137,7 @@ The API has been broken up into sub APIs classes to make it easier to learn and
------------------
------------------
[
CommitsApi
](
#commitsapi
)
<br/>
[
CommitsApi
](
#commitsapi
)
<br/>
[
DeployKeysApi
](
#deploykeysapi
)
<br/>
[
DeployKeysApi
](
#deploykeysapi
)
<br/>
[
EpicsApi
](
#epicsapi
)
<br/>
[
EventsApi
](
#eventsapi
)
<br/>
[
EventsApi
](
#eventsapi
)
<br/>
[
GroupApi
](
#groupapi
)
<br/>
[
GroupApi
](
#groupapi
)
<br/>
[
HealthCheckApi
](
#healthcheckapi
)
<br/>
[
HealthCheckApi
](
#healthcheckapi
)
<br/>
...
@@ -179,10 +180,16 @@ List<Commit> commits = gitLabApi.getCommitsApi().getCommits(1234, "new-feature",
...
@@ -179,10 +180,16 @@ List<Commit> commits = gitLabApi.getCommitsApi().getCommits(1234, "new-feature",
List
<
DeployKey
>
deployKeys
=
gitLabApi
.
getDeployKeysApi
().
getDeployKeys
();
List
<
DeployKey
>
deployKeys
=
gitLabApi
.
getDeployKeysApi
().
getDeployKeys
();
```
```
#### EpicsApi
```
java
// Get a list epics of the requested group and its subgroups.
List
<
Epic
>
epics
=
gitLabApi
.
getEpicsApi
().
getEpics
(
1
);
```
#### EventsApi
#### EventsApi
```
java
```
java
// Get a list of Events for the authenticated user
// Get a list of Events for the authenticated user
Date
after
=
new
Date
(
0
);
// After Epo
s
c
Date
after
=
new
Date
(
0
);
// After Epoc
h
Date
before
=
new
Date
();
// Before now
Date
before
=
new
Date
();
// Before now
List
<
Event
>
events
=
gitLabApi
.
getEventsApi
().
getAuthenticatedUserEvents
(
null
,
null
,
before
,
after
,
DESC
);
List
<
Event
>
events
=
gitLabApi
.
getEventsApi
().
getAuthenticatedUserEvents
(
null
,
null
,
before
,
after
,
DESC
);
```
```
...
...
src/main/java/org/gitlab4j/api/Constants.java
View file @
4b727853
...
@@ -59,6 +59,30 @@ public interface Constants {
...
@@ -59,6 +59,30 @@ public interface Constants {
}
}
}
}
/** Enum to use for ordering the results of getEpics(). */
public
enum
EpicOrderBy
{
CREATED_AT
,
UPDATED_AT
;
private
static
JacksonJsonEnumHelper
<
EpicOrderBy
>
enumHelper
=
new
JacksonJsonEnumHelper
<>(
EpicOrderBy
.
class
);
@JsonCreator
public
static
EpicOrderBy
forValue
(
String
value
)
{
return
enumHelper
.
forValue
(
value
);
}
@JsonValue
public
String
toValue
()
{
return
(
enumHelper
.
toString
(
this
));
}
@Override
public
String
toString
()
{
return
(
enumHelper
.
toString
(
this
));
}
}
/** Enum to use for ordering the results of getProjects(). */
/** Enum to use for ordering the results of getProjects(). */
public
enum
ProjectOrderBy
{
public
enum
ProjectOrderBy
{
...
...
src/main/java/org/gitlab4j/api/EpicsApi.java
0 → 100644
View file @
4b727853
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/GitLabApi.java
View file @
4b727853
...
@@ -50,6 +50,7 @@ public class GitLabApi {
...
@@ -50,6 +50,7 @@ public class GitLabApi {
private
CommitsApi
commitsApi
;
private
CommitsApi
commitsApi
;
private
DeployKeysApi
deployKeysApi
;
private
DeployKeysApi
deployKeysApi
;
private
EpicsApi
epicsApi
;
private
EventsApi
eventsApi
;
private
EventsApi
eventsApi
;
private
GroupApi
groupApi
;
private
GroupApi
groupApi
;
private
HealthCheckApi
healthCheckApi
;
private
HealthCheckApi
healthCheckApi
;
...
@@ -846,6 +847,25 @@ public class GitLabApi {
...
@@ -846,6 +847,25 @@ public class GitLabApi {
return
(
deployKeysApi
);
return
(
deployKeysApi
);
}
}
/**
* Gets the EpicsApi instance owned by this GitLabApi instance. The EpicsApi is used
* to perform all Epics and Epic Issues related API calls.
*
* @return the EpicsApi instance owned by this GitLabApi instance
*/
public
EpicsApi
getEpicsApi
()
{
if
(
epicsApi
==
null
)
{
synchronized
(
this
)
{
if
(
epicsApi
==
null
)
{
epicsApi
=
new
EpicsApi
(
this
);
}
}
}
return
(
epicsApi
);
}
/**
/**
* Gets the EventsApi instance owned by this GitLabApi instance. The EventsApi is used
* Gets the EventsApi instance owned by this GitLabApi instance. The EventsApi is used
* to perform all events related API calls.
* to perform all events related API calls.
...
...
src/main/java/org/gitlab4j/api/GitLabApiForm.java
View file @
4b727853
...
@@ -21,6 +21,18 @@ public class GitLabApiForm extends Form {
...
@@ -21,6 +21,18 @@ public class GitLabApiForm extends Form {
super
(
map
);
super
(
map
);
}
}
/**
* Create a GitLabApiForm instance with the "page", and "per_page" parameters preset.
*
* @param page the value for the "page" parameter
* @param perPage the value for the "per_page" parameter
*/
public
GitLabApiForm
(
int
page
,
int
perPage
)
{
super
();
withParam
(
AbstractApi
.
PAGE_PARAM
,
page
);
withParam
(
AbstractApi
.
PER_PAGE_PARAM
,
(
Integer
)
perPage
);
}
/**
/**
* Fluent method for adding query and form parameters to a get() or post() call.
* Fluent method for adding query and form parameters to a get() or post() call.
*
*
...
...
src/main/java/org/gitlab4j/api/models/Epic.java
0 → 100644
View file @
4b727853
package
org.gitlab4j.api.models
;
import
java.util.Date
;
import
java.util.List
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlRootElement
;
@XmlRootElement
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
Epic
{
private
Integer
id
;
private
Integer
iid
;
private
Integer
groupId
;
private
String
title
;
private
String
description
;
private
Author
author
;
private
List
<
String
>
labels
;
private
Date
startDate
;
private
Date
endDate
;
private
Date
createdAt
;
private
Date
updatedAt
;
public
Integer
getId
()
{
return
id
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
public
Integer
getIid
()
{
return
iid
;
}
public
void
setIid
(
Integer
iid
)
{
this
.
iid
=
iid
;
}
public
Integer
getGroupId
()
{
return
groupId
;
}
public
void
setGroupId
(
Integer
groupId
)
{
this
.
groupId
=
groupId
;
}
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
Epic
withTitle
(
String
title
)
{
this
.
title
=
title
;
return
(
this
);
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
Epic
withDescription
(
String
description
)
{
this
.
description
=
description
;
return
(
this
);
}
public
Author
getAuthor
()
{
return
author
;
}
public
void
setAuthor
(
Author
author
)
{
this
.
author
=
author
;
}
public
Epic
withAuthor
(
Author
author
)
{
this
.
author
=
author
;
return
(
this
);
}
public
List
<
String
>
getLabels
()
{
return
labels
;
}
public
void
setLabels
(
List
<
String
>
labels
)
{
this
.
labels
=
labels
;
}
public
Epic
withLabels
(
List
<
String
>
labels
)
{
this
.
labels
=
labels
;
return
(
this
);
}
public
Date
getStartDate
()
{
return
startDate
;
}
public
void
setStartDate
(
Date
startDate
)
{
this
.
startDate
=
startDate
;
}
public
Epic
withStartDate
(
Date
startDate
)
{
this
.
startDate
=
startDate
;
return
(
this
);
}
public
Date
getEndDate
()
{
return
endDate
;
}
public
void
setEndDate
(
Date
endDate
)
{
this
.
endDate
=
endDate
;
}
public
Epic
withEndDate
(
Date
endDate
)
{
this
.
endDate
=
endDate
;
return
(
this
);
}
public
Date
getCreatedAt
()
{
return
createdAt
;
}
public
void
setCreatedAt
(
Date
createdAt
)
{
this
.
createdAt
=
createdAt
;
}
public
Date
getUpdatedAt
()
{
return
updatedAt
;
}
public
void
setUpdatedAt
(
Date
updatedAt
)
{
this
.
updatedAt
=
updatedAt
;
}
}
src/main/java/org/gitlab4j/api/models/EpicIssue.java
0 → 100644
View file @
4b727853
package
org.gitlab4j.api.models
;
import
java.util.Map
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
EpicIssue
extends
Issue
{
private
Integer
downvotes
;
private
Integer
upvotes
;
@JsonProperty
(
"_links"
)
private
Map
<
String
,
String
>
links
;
private
Boolean
subscribed
;
private
Integer
epicIssueId
;
private
Integer
relativePosition
;
public
Integer
getDownvotes
()
{
return
downvotes
;
}
public
void
setDownvotes
(
Integer
downvotes
)
{
this
.
downvotes
=
downvotes
;
}
public
Integer
getUpvotes
()
{
return
upvotes
;
}
public
void
setUpvotes
(
Integer
upvotes
)
{
this
.
upvotes
=
upvotes
;
}
public
Map
<
String
,
String
>
getLinks
()
{
return
links
;
}
public
void
setLinks
(
Map
<
String
,
String
>
links
)
{
this
.
links
=
links
;
}
@JsonIgnore
public
String
getLinkByName
(
String
name
)
{
if
(
links
==
null
||
links
.
isEmpty
())
{
return
(
null
);
}
return
(
links
.
get
(
name
));
}
public
Boolean
getSubscribed
()
{
return
subscribed
;
}
public
void
setSubscribed
(
Boolean
subscribed
)
{
this
.
subscribed
=
subscribed
;
}
public
Integer
getEpicIssueId
()
{
return
epicIssueId
;
}
public
void
setEpicIssueId
(
Integer
epicIssueId
)
{
this
.
epicIssueId
=
epicIssueId
;
}
public
Integer
getRelativePosition
()
{
return
relativePosition
;
}
public
void
setRelativePosition
(
Integer
relativePosition
)
{
this
.
relativePosition
=
relativePosition
;
}
}
src/main/java/org/gitlab4j/api/models/Issue.java
View file @
4b727853
...
@@ -15,6 +15,7 @@ import org.gitlab4j.api.Constants.IssueState;
...
@@ -15,6 +15,7 @@ import org.gitlab4j.api.Constants.IssueState;
public
class
Issue
{
public
class
Issue
{
private
Assignee
assignee
;
private
Assignee
assignee
;
private
List
<
Assignee
>
assignees
;
private
Author
author
;
private
Author
author
;
private
Boolean
confidential
;
private
Boolean
confidential
;
private
Date
createdAt
;
private
Date
createdAt
;
...
@@ -33,6 +34,8 @@ public class Issue {
...
@@ -33,6 +34,8 @@ public class Issue {
private
String
title
;
private
String
title
;
private
Integer
userNotesCount
;
private
Integer
userNotesCount
;
private
String
webUrl
;
private
String
webUrl
;
private
Integer
weight
;
private
Boolean
discussionLocked
;
private
TimeStats
timeStats
;
private
TimeStats
timeStats
;
public
Assignee
getAssignee
()
{
public
Assignee
getAssignee
()
{
...
@@ -43,6 +46,14 @@ public class Issue {
...
@@ -43,6 +46,14 @@ public class Issue {
this
.
assignee
=
assignee
;
this
.
assignee
=
assignee
;
}
}
public
List
<
Assignee
>
getAssignees
()
{
return
assignees
;
}
public
void
setAssignees
(
List
<
Assignee
>
assignees
)
{
this
.
assignees
=
assignees
;
}
public
Author
getAuthor
()
{
public
Author
getAuthor
()
{
return
author
;
return
author
;
}
}
...
@@ -187,6 +198,22 @@ public class Issue {
...
@@ -187,6 +198,22 @@ public class Issue {
this
.
webUrl
=
webUrl
;
this
.
webUrl
=
webUrl
;
}
}
public
Integer
getWeight
()
{
return
weight
;
}
public
void
setWeight
(
Integer
weight
)
{
this
.
weight
=
weight
;
}
public
Boolean
getDiscussionLocked
()
{
return
discussionLocked
;
}
public
void
setDiscussionLocked
(
Boolean
discussionLocked
)
{
this
.
discussionLocked
=
discussionLocked
;
}
public
TimeStats
getTimeStats
()
{
public
TimeStats
getTimeStats
()
{
return
timeStats
;
return
timeStats
;
}
}
...
...
src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java
View file @
4b727853
...
@@ -38,6 +38,8 @@ import org.gitlab4j.api.models.CommitPayload;
...
@@ -38,6 +38,8 @@ import org.gitlab4j.api.models.CommitPayload;
import
org.gitlab4j.api.models.CompareResults
;
import
org.gitlab4j.api.models.CompareResults
;
import
org.gitlab4j.api.models.DeployKey
;
import
org.gitlab4j.api.models.DeployKey
;
import
org.gitlab4j.api.models.Diff
;
import
org.gitlab4j.api.models.Diff
;
import
org.gitlab4j.api.models.Epic
;
import
org.gitlab4j.api.models.EpicIssue
;
import
org.gitlab4j.api.models.Event
;
import
org.gitlab4j.api.models.Event
;
import
org.gitlab4j.api.models.FileUpload
;
import
org.gitlab4j.api.models.FileUpload
;
import
org.gitlab4j.api.models.Group
;
import
org.gitlab4j.api.models.Group
;
...
@@ -169,6 +171,28 @@ public class TestGitLabApiBeans {
...
@@ -169,6 +171,28 @@ public class TestGitLabApiBeans {
}
}
}
}
@Test
public
void
testEpic
()
{
try
{
Epic
epic
=
makeFakeApiCall
(
Epic
.
class
,
"epic"
);
assertTrue
(
compareJson
(
epic
,
"epic"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
testEpicIssue
()
{
try
{
EpicIssue
epicIssue
=
makeFakeApiCall
(
EpicIssue
.
class
,
"epic-issue"
);
assertTrue
(
compareJson
(
epicIssue
,
"epic-issue"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
@Test
@Test
public
void
testEvent
()
{
public
void
testEvent
()
{
...
...
src/test/resources/org/gitlab4j/api/epic-issue.json
0 → 100644
View file @
4b727853
{
"id"
:
76
,
"iid"
:
6
,
"project_id"
:
8
,
"title"
:
"Consequatur vero maxime deserunt laboriosam est voluptas dolorem."
,
"description"
:
"Ratione dolores corrupti mollitia soluta quia."
,
"state"
:
"opened"
,
"created_at"
:
"2017-11-15T13:39:24.670Z"
,
"updated_at"
:
"2018-01-04T10:49:19.506Z"
,
"labels"
:
[],
"milestone"
:
{
"id"
:
38
,
"iid"
:
3
,
"project_id"
:
8
,
"title"
:
"v2.0"
,
"description"
:
"In tempore culpa inventore quo accusantium."
,
"state"
:
"closed"
,
"created_at"
:
"2017-11-15T13:39:13.825Z"
,
"updated_at"
:
"2017-11-15T13:39:13.825Z"
},
"assignees"
:
[{
"id"
:
7
,
"name"
:
"Pamella Huel"
,
"username"
:
"arnita"
,
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/a2f5c6fcef64c9c69cb8779cb292be1b?s=80&d=identicon"
,
"web_url"
:
"http://localhost:3001/arnita"
}],
"assignee"
:
{
"id"
:
7
,
"name"
:
"Pamella Huel"
,
"username"
:
"arnita"
,
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/a2f5c6fcef64c9c69cb8779cb292be1b?s=80&d=identicon"
,
"web_url"
:
"http://localhost:3001/arnita"
},
"author"
:
{
"id"
:
13
,
"name"
:
"Michell Johns"
,
"username"
:
"chris_hahn"
,
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/30e3b2122ccd6b8e45e8e14a3ffb58fc?s=80&d=identicon"
,
"web_url"
:
"http://localhost:3001/chris_hahn"
},
"user_notes_count"
:
8
,
"upvotes"
:
0
,
"downvotes"
:
0
,
"confidential"
:
false
,
"weight"
:
9
,
"discussion_locked"
:
true
,
"web_url"
:
"http://localhost:3001/h5bp/html5-boilerplate/issues/6"
,
"time_stats"
:
{
"time_estimate"
:
0
,
"total_time_spent"
:
0
},
"_links"
:{
"self"
:
"http://localhost:3001/api/v4/projects/8/issues/6"
,
"notes"
:
"http://localhost:3001/api/v4/projects/8/issues/6/notes"
,
"award_emoji"
:
"http://localhost:3001/api/v4/projects/8/issues/6/award_emoji"
,
"project"
:
"http://localhost:3001/api/v4/projects/8"
},
"subscribed"
:
true
,
"epic_issue_id"
:
2
,
"relative_position"
:
55
}
\ No newline at end of file
src/test/resources/org/gitlab4j/api/epic.json
0 → 100644
View file @
4b727853
{
"id"
:
30
,
"iid"
:
5
,
"group_id"
:
7
,
"title"
:
"Ea cupiditate dolores ut vero consequatur quasi veniam voluptatem et non."
,
"description"
:
"Molestias dolorem eos vitae expedita impedit necessitatibus quo voluptatum."
,
"author"
:{
"id"
:
7
,
"name"
:
"Pamella Huel"
,
"username"
:
"arnita"
,
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/a2f5c6fcef64c9c69cb8779cb292be1b?s=80&d=identicon"
,
"web_url"
:
"http://localhost:3001/arnita"
},
"created_at"
:
"2018-01-21T06:21:13.165Z"
,
"updated_at"
:
"2018-01-22T12:41:41.166Z"
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment