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
712b90dc
Commit
712b90dc
authored
May 02, 2020
by
Greg Messner
Browse files
Added support for searching members by query and user ID (#565)
parent
7960f1d4
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/GroupApi.java
View file @
712b90dc
...
@@ -813,7 +813,7 @@ public class GroupApi extends AbstractApi {
...
@@ -813,7 +813,7 @@ public class GroupApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
Member
>
getAllMembers
(
Object
groupIdOrPath
)
throws
GitLabApiException
{
public
List
<
Member
>
getAllMembers
(
Object
groupIdOrPath
)
throws
GitLabApiException
{
return
(
getAllMembers
(
groupIdOrPath
,
getDefaultPerPage
()).
a
ll
(
));
return
(
getAllMembers
(
groupIdOrPath
,
null
,
nu
ll
));
}
}
/**
/**
...
@@ -829,7 +829,9 @@ public class GroupApi extends AbstractApi {
...
@@ -829,7 +829,9 @@ public class GroupApi extends AbstractApi {
* @return a list of group members viewable by the authenticated user, including inherited members
* @return a list of group members viewable by the authenticated user, including inherited members
* through ancestor groups in the specified page range
* through ancestor groups in the specified page range
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
* @deprecated Will be removed in version 5.0
*/
*/
@Deprecated
public
List
<
Member
>
getAllMembers
(
Object
groupIdOrPath
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
public
List
<
Member
>
getAllMembers
(
Object
groupIdOrPath
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
getPageQueryParams
(
page
,
perPage
),
Response
response
=
get
(
Response
.
Status
.
OK
,
getPageQueryParams
(
page
,
perPage
),
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"members"
,
"all"
);
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"members"
,
"all"
);
...
@@ -850,7 +852,7 @@ public class GroupApi extends AbstractApi {
...
@@ -850,7 +852,7 @@ public class GroupApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Pager
<
Member
>
getAllMembers
(
Object
groupIdOrPath
,
int
itemsPerPage
)
throws
GitLabApiException
{
public
Pager
<
Member
>
getAllMembers
(
Object
groupIdOrPath
,
int
itemsPerPage
)
throws
GitLabApiException
{
return
(
new
Pager
<
Member
>(
this
,
Member
.
class
,
itemsPerPage
,
null
,
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
)
,
"members"
,
"all"
));
return
(
getAllMembers
(
groupIdOrPath
,
null
,
null
,
itemsPerPage
));
}
}
/**
/**
...
@@ -866,7 +868,64 @@ public class GroupApi extends AbstractApi {
...
@@ -866,7 +868,64 @@ public class GroupApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Stream
<
Member
>
getAllMembersStream
(
Object
groupIdOrPath
)
throws
GitLabApiException
{
public
Stream
<
Member
>
getAllMembersStream
(
Object
groupIdOrPath
)
throws
GitLabApiException
{
return
(
getAllMembers
(
groupIdOrPath
,
getDefaultPerPage
()).
stream
());
return
(
getAllMembersStream
(
groupIdOrPath
,
null
,
null
));
}
/**
* Gets a list of group members viewable by the authenticated user, including inherited members
* through ancestor groups. Returns multiple times the same user (with different member attributes)
* when the user is a member of the group and of one or more ancestor group.
*
* <pre><code>GitLab Endpoint: GET /groups/:id/members/all</code></pre>
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param query a query string to search for members
* @param userIds filter the results on the given user IDs
* @return the group members viewable by the authenticated user, including inherited members through ancestor groups
* @throws GitLabApiException if any exception occurs
*/
public
List
<
Member
>
getAllMembers
(
Object
groupIdOrPath
,
String
query
,
List
<
Integer
>
userIds
)
throws
GitLabApiException
{
return
(
getAllMembers
(
groupIdOrPath
,
query
,
userIds
,
getDefaultPerPage
()).
all
());
}
/**
* Gets a Pager of group members viewable by the authenticated user, including inherited members
* through ancestor groups. Returns multiple times the same user (with different member attributes)
* when the user is a member of the group and of one or more ancestor group.
*
* <pre><code>GitLab Endpoint: GET /groups/:id/members/all</code></pre>
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param query a query string to search for members
* @param userIds filter the results on the given user IDs
* @param itemsPerPage the number of Project instances that will be fetched per page
* @return a Pager of the group members viewable by the authenticated user,
* including inherited members through ancestor groups
* @throws GitLabApiException if any exception occurs
*/
public
Pager
<
Member
>
getAllMembers
(
Object
groupIdOrPath
,
String
query
,
List
<
Integer
>
userIds
,
int
itemsPerPage
)
throws
GitLabApiException
{
GitLabApiForm
form
=
new
GitLabApiForm
().
withParam
(
"query"
,
query
).
withParam
(
"user_ids"
,
userIds
);
return
(
new
Pager
<
Member
>(
this
,
Member
.
class
,
itemsPerPage
,
form
.
asMap
(),
"projects"
,
getGroupIdOrPath
(
groupIdOrPath
),
"members"
,
"all"
));
}
/**
* Gets a Stream of group members viewable by the authenticated user, including inherited members
* through ancestor groups. Returns multiple times the same user (with different member attributes)
* when the user is a member of the group and of one or more ancestor group.
*
* <pre><code>GitLab Endpoint: GET /groups/:id/members/all</code></pre>
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param query a query string to search for members
* @param userIds filter the results on the given user IDs
* @return a Stream of the group members viewable by the authenticated user,
* including inherited members through ancestor groups
* @throws GitLabApiException if any exception occurs
*/
public
Stream
<
Member
>
getAllMembersStream
(
Object
groupIdOrPath
,
String
query
,
List
<
Integer
>
userIds
)
throws
GitLabApiException
{
return
(
getAllMembers
(
groupIdOrPath
,
query
,
userIds
,
getDefaultPerPage
()).
stream
());
}
}
/**
/**
...
...
src/main/java/org/gitlab4j/api/ProjectApi.java
View file @
712b90dc
...
@@ -1369,7 +1369,7 @@ public class ProjectApi extends AbstractApi implements Constants {
...
@@ -1369,7 +1369,7 @@ public class ProjectApi extends AbstractApi implements Constants {
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
Member
>
getAllMembers
(
Object
projectIdOrPath
)
throws
GitLabApiException
{
public
List
<
Member
>
getAllMembers
(
Object
projectIdOrPath
)
throws
GitLabApiException
{
return
(
getAllMembers
(
projectIdOrPath
,
getDefaultPerPage
()).
a
ll
(
));
return
(
getAllMembers
(
projectIdOrPath
,
null
,
nu
ll
));
}
}
/**
/**
...
@@ -1385,7 +1385,9 @@ public class ProjectApi extends AbstractApi implements Constants {
...
@@ -1385,7 +1385,9 @@ public class ProjectApi extends AbstractApi implements Constants {
* @param perPage the number of Member instances per page
* @param perPage the number of Member instances per page
* @return the project members viewable by the authenticated user, including inherited members through ancestor groups
* @return the project members viewable by the authenticated user, including inherited members through ancestor groups
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
* @deprecated Will be removed in version 5.0
*/
*/
@Deprecated
public
List
<
Member
>
getAllMembers
(
Object
projectIdOrPath
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
public
List
<
Member
>
getAllMembers
(
Object
projectIdOrPath
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
getPageQueryParams
(
page
,
perPage
),
Response
response
=
get
(
Response
.
Status
.
OK
,
getPageQueryParams
(
page
,
perPage
),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"members"
,
"all"
);
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"members"
,
"all"
);
...
@@ -1407,8 +1409,7 @@ public class ProjectApi extends AbstractApi implements Constants {
...
@@ -1407,8 +1409,7 @@ public class ProjectApi extends AbstractApi implements Constants {
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Pager
<
Member
>
getAllMembers
(
Object
projectIdOrPath
,
int
itemsPerPage
)
throws
GitLabApiException
{
public
Pager
<
Member
>
getAllMembers
(
Object
projectIdOrPath
,
int
itemsPerPage
)
throws
GitLabApiException
{
return
(
new
Pager
<
Member
>(
this
,
Member
.
class
,
itemsPerPage
,
null
,
return
(
getAllMembers
(
projectIdOrPath
,
null
,
null
,
itemsPerPage
));
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"members"
,
"all"
));
}
}
/**
/**
...
@@ -1425,7 +1426,66 @@ public class ProjectApi extends AbstractApi implements Constants {
...
@@ -1425,7 +1426,66 @@ public class ProjectApi extends AbstractApi implements Constants {
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Stream
<
Member
>
getAllMembersStream
(
Object
projectIdOrPath
)
throws
GitLabApiException
{
public
Stream
<
Member
>
getAllMembersStream
(
Object
projectIdOrPath
)
throws
GitLabApiException
{
return
(
getAllMembers
(
projectIdOrPath
,
getDefaultPerPage
()).
stream
());
return
(
getAllMembersStream
(
projectIdOrPath
,
null
,
null
));
}
/**
* Gets a list of project members viewable by the authenticated user,
* including inherited members through ancestor groups. Returns multiple
* times the same user (with different member attributes) when the user is
* a member of the project/group and of one or more ancestor group.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/members/all</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param query a query string to search for members
* @param userIds filter the results on the given user IDs
* @return the project members viewable by the authenticated user, including inherited members through ancestor groups
* @throws GitLabApiException if any exception occurs
*/
public
List
<
Member
>
getAllMembers
(
Object
projectIdOrPath
,
String
query
,
List
<
Integer
>
userIds
)
throws
GitLabApiException
{
return
(
getAllMembers
(
projectIdOrPath
,
query
,
userIds
,
getDefaultPerPage
()).
all
());
}
/**
* Gets a Pager of project members viewable by the authenticated user,
* including inherited members through ancestor groups. Returns multiple
* times the same user (with different member attributes) when the user is
* a member of the project/group and of one or more ancestor group.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/members/all</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param query a query string to search for members
* @param userIds filter the results on the given user IDs
* @param itemsPerPage the number of Project instances that will be fetched per page
* @return a Pager of the project members viewable by the authenticated user,
* including inherited members through ancestor groups
* @throws GitLabApiException if any exception occurs
*/
public
Pager
<
Member
>
getAllMembers
(
Object
projectIdOrPath
,
String
query
,
List
<
Integer
>
userIds
,
int
itemsPerPage
)
throws
GitLabApiException
{
GitLabApiForm
form
=
new
GitLabApiForm
().
withParam
(
"query"
,
query
).
withParam
(
"user_ids"
,
userIds
);
return
(
new
Pager
<
Member
>(
this
,
Member
.
class
,
itemsPerPage
,
form
.
asMap
(),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"members"
,
"all"
));
}
/**
* Gets a Stream of project members viewable by the authenticated user,
* including inherited members through ancestor groups. Returns multiple
* times the same user (with different member attributes) when the user is
* a member of the project/group and of one or more ancestor group.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/members/all</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param query a query string to search for members
* @param userIds filter the results on the given user IDs
* @return a Stream of the project members viewable by the authenticated user,
* including inherited members through ancestor groups
* @throws GitLabApiException if any exception occurs
*/
public
Stream
<
Member
>
getAllMembersStream
(
Object
projectIdOrPath
,
String
query
,
List
<
Integer
>
userIds
)
throws
GitLabApiException
{
return
(
getAllMembers
(
projectIdOrPath
,
query
,
userIds
,
getDefaultPerPage
()).
stream
());
}
}
/**
/**
...
...
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