Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
5e57e9fb
Commit
5e57e9fb
authored
6 years ago
by
Greg Messner
Browse files
Options
Download
Email Patches
Plain Diff
Added support fopr filtering when fetching merge requests (#187, #193).
parent
677dcf36
main
5.0.x
5.0.x.jdk17
6.x
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/main/java/org/gitlab4j/api/Constants.java
+44
-0
src/main/java/org/gitlab4j/api/Constants.java
src/main/java/org/gitlab4j/api/GitLabApiForm.java
+2
-2
src/main/java/org/gitlab4j/api/GitLabApiForm.java
src/main/java/org/gitlab4j/api/MergeRequestApi.java
+48
-0
src/main/java/org/gitlab4j/api/MergeRequestApi.java
with
94 additions
and
2 deletions
+94
-2
src/main/java/org/gitlab4j/api/Constants.java
+
44
-
0
View file @
5e57e9fb
...
...
@@ -104,6 +104,29 @@ public interface Constants {
}
}
/** Enum to use for ordering the results of getMergeRequests(). */
public
enum
MergeRequestOrderBy
{
CREATED_AT
,
UPDATED_AT
;
private
static
JacksonJsonEnumHelper
<
MergeRequestOrderBy
>
enumHelper
=
new
JacksonJsonEnumHelper
<>(
MergeRequestOrderBy
.
class
);
@JsonCreator
public
static
MergeRequestOrderBy
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 getGroups() and getSubGroups(). */
public
enum
GroupOrderBy
{
...
...
@@ -191,6 +214,27 @@ public interface Constants {
}
}
/** Enum to use for specifying the scope for getMergeRequests methods. */
public
enum
MergeRequestScope
{
CREATED_BY_ME
,
ASSIGNED_TO_ME
,
ALL
;
private
static
JacksonJsonEnumHelper
<
MergeRequestScope
>
enumHelper
=
new
JacksonJsonEnumHelper
<>(
MergeRequestScope
.
class
);
@JsonCreator
public
static
MergeRequestScope
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 querying the state of a MergeRequest */
public
enum
MergeRequestState
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/GitLabApiForm.java
+
2
-
2
View file @
5e57e9fb
...
...
@@ -23,7 +23,7 @@ public class GitLabApiForm extends Form {
* @param value the value of the field/attribute to add
* @return this GitLabAPiForm instance
*/
p
rotected
GitLabApiForm
withParam
(
String
name
,
Object
value
)
throws
IllegalArgumentException
{
p
ublic
GitLabApiForm
withParam
(
String
name
,
Object
value
)
throws
IllegalArgumentException
{
return
(
withParam
(
name
,
value
,
false
));
}
...
...
@@ -37,7 +37,7 @@ public class GitLabApiForm extends Form {
* @return this GitLabAPiForm instance
* @throws IllegalArgumentException if a required parameter is null or empty
*/
p
rotected
GitLabApiForm
withParam
(
String
name
,
Object
value
,
boolean
required
)
throws
IllegalArgumentException
{
p
ublic
GitLabApiForm
withParam
(
String
name
,
Object
value
,
boolean
required
)
throws
IllegalArgumentException
{
if
(
value
==
null
)
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/MergeRequestApi.java
+
48
-
0
View file @
5e57e9fb
...
...
@@ -5,11 +5,13 @@ import java.util.Optional;
import
javax.ws.rs.core.Form
;
import
javax.ws.rs.core.GenericType
;
import
javax.ws.rs.core.MultivaluedMap
;
import
javax.ws.rs.core.Response
;
import
org.gitlab4j.api.GitLabApi.ApiVersion
;
import
org.gitlab4j.api.models.Commit
;
import
org.gitlab4j.api.models.MergeRequest
;
import
org.gitlab4j.api.models.MergeRequestFilter
;
import
org.gitlab4j.api.models.Participant
;
/**
...
...
@@ -21,6 +23,52 @@ public class MergeRequestApi extends AbstractApi {
super
(
gitLabApi
);
}
/**
* Get all merge requests matching the filter.
*
* GET /merge_requests
*
* @param filter a MergeRequestFilter instance with the filter settings
* @return all merge requests for the specified project matching the filter
* @throws GitLabApiException if any exception occurs
*/
public
List
<
MergeRequest
>
getMergeRequests
(
MergeRequestFilter
filter
)
throws
GitLabApiException
{
return
(
getMergeRequests
(
filter
,
1
,
getDefaultPerPage
()));
}
/**
* Get all merge requests matching the filter.
*
* GET /merge_requests
*
* @param filter a MergeRequestFilter instance with the filter settings
* @param page the page to get
* @param perPage the number of MergeRequest instances per page
* @return all merge requests for the specified project matching the filter
* @throws GitLabApiException if any exception occurs
*/
public
List
<
MergeRequest
>
getMergeRequests
(
MergeRequestFilter
filter
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
MultivaluedMap
<
String
,
String
>
queryParams
=
(
filter
!=
null
?
filter
.
getQueryParams
(
page
,
perPage
).
asMap
()
:
getPageQueryParams
(
page
,
perPage
));
Response
response
=
get
(
Response
.
Status
.
OK
,
queryParams
,
"merge_requests"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
MergeRequest
>>()
{}));
}
/**
* Get all merge requests matching the filter.
*
* GET /merge_requests
*
* @param filter a MergeRequestFilter instance with the filter settings
* @param itemsPerPage the number of MergeRequest instances that will be fetched per page
* @return all merge requests for the specified project matching the filter
* @throws GitLabApiException if any exception occurs
*/
public
Pager
<
MergeRequest
>
getMergeRequests
(
MergeRequestFilter
filter
,
int
itemsPerPage
)
throws
GitLabApiException
{
MultivaluedMap
<
String
,
String
>
queryParams
=
(
filter
!=
null
?
filter
.
getQueryParams
().
asMap
()
:
null
);
return
(
new
Pager
<
MergeRequest
>(
this
,
MergeRequest
.
class
,
itemsPerPage
,
queryParams
,
"merge_requests"
));
}
/**
* Get all merge requests for the specified project.
*
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Explore
Projects
Groups
Snippets