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
1e50236a
Commit
1e50236a
authored
Oct 29, 2017
by
Alex Bobkov
Committed by
Greg Messner
Oct 28, 2017
Browse files
Get active/blocked users (#89)
parent
86c1c6db
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/UserApi.java
View file @
1e50236a
package
org.gitlab4j.api
;
package
org.gitlab4j.api
;
import
java.util.List
;
import
org.gitlab4j.api.GitLabApi.ApiVersion
;
import
org.gitlab4j.api.models.SshKey
;
import
org.gitlab4j.api.models.User
;
import
javax.ws.rs.core.Form
;
import
javax.ws.rs.core.Form
;
import
javax.ws.rs.core.GenericType
;
import
javax.ws.rs.core.GenericType
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response
;
import
java.util.List
;
import
org.gitlab4j.api.GitLabApi.ApiVersion
;
import
org.gitlab4j.api.models.SshKey
;
import
org.gitlab4j.api.models.User
;
/**
/**
* This class provides an entry point to all the GitLab API users calls.
* This class provides an entry point to all the GitLab API users calls.
...
@@ -24,7 +23,7 @@ public class UserApi extends AbstractApi {
...
@@ -24,7 +23,7 @@ public class UserApi extends AbstractApi {
*
*
* GET /users
* GET /users
*
*
* @return a list of Users, this list will only contain the first
2
0 users in the system.
* @return a list of Users, this list will only contain the first
10
0 users in the system.
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
User
>
getUsers
()
throws
GitLabApiException
{
public
List
<
User
>
getUsers
()
throws
GitLabApiException
{
...
@@ -52,7 +51,7 @@ public class UserApi extends AbstractApi {
...
@@ -52,7 +51,7 @@ public class UserApi extends AbstractApi {
*
*
* GET /users
* GET /users
*
*
* @param itemsPerPage the number of
Project
instances that will be fetched per page
* @param itemsPerPage the number of
User
instances that will be fetched per page
* @return a Pager of User
* @return a Pager of User
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
...
@@ -60,6 +59,104 @@ public class UserApi extends AbstractApi {
...
@@ -60,6 +59,104 @@ public class UserApi extends AbstractApi {
return
(
new
Pager
<
User
>(
this
,
User
.
class
,
itemsPerPage
,
null
,
"users"
));
return
(
new
Pager
<
User
>(
this
,
User
.
class
,
itemsPerPage
,
null
,
"users"
));
}
}
/**
* Get a list of active users. Only returns the first page
*
* GET /users?active=true
*
* @return a list of active Users, this list will only contain the first 100 users in the system.
* @throws GitLabApiException if any exception occurs
*/
public
List
<
User
>
getActiveUsers
()
throws
GitLabApiException
{
GitLabApiForm
formData
=
new
GitLabApiForm
()
.
withParam
(
"active"
,
true
)
.
withParam
(
PER_PAGE_PARAM
,
getDefaultPerPage
());
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"users"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
User
>>()
{}));
}
/**
* Get a list of active users using the specified page and per page settings.
*
* GET /users?active=true
*
* @param page the page to get
* @param perPage the number of users per page
* @return the list of active Users in the specified range
* @throws GitLabApiException if any exception occurs
*/
public
List
<
User
>
getActiveUsers
(
int
page
,
int
perPage
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
new
GitLabApiForm
()
.
withParam
(
"active"
,
true
)
.
withParam
(
PAGE_PARAM
,
page
)
.
withParam
(
PER_PAGE_PARAM
,
perPage
);
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"users"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
User
>>()
{}));
}
/**
* Get a Pager of active users.
*
* GET /users?active=true
*
* @param itemsPerPage the number of active User instances that will be fetched per page
* @return a Pager of active User
* @throws GitLabApiException if any exception occurs
*/
public
Pager
<
User
>
getActiveUsers
(
int
itemsPerPage
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
new
GitLabApiForm
().
withParam
(
"active"
,
true
);
return
(
new
Pager
<
User
>(
this
,
User
.
class
,
itemsPerPage
,
formData
.
asMap
(),
"users"
));
}
/**
* Get a list of blocked users. Only returns the first page
*
* GET /users?blocked=true
*
* @return a list of blocked Users, this list will only contain the first 100 users in the system.
* @throws GitLabApiException if any exception occurs
*/
public
List
<
User
>
getBlockedUsers
()
throws
GitLabApiException
{
GitLabApiForm
formData
=
new
GitLabApiForm
()
.
withParam
(
"blocked"
,
true
)
.
withParam
(
PER_PAGE_PARAM
,
getDefaultPerPage
());
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"users"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
User
>>()
{}));
}
/**
* Get a list of blocked users using the specified page and per page settings.
*
* GET /users?blocked=true
*
* @param page the page to get
* @param perPage the number of users per page
* @return the list of blocked Users in the specified range
* @throws GitLabApiException if any exception occurs
*/
public
List
<
User
>
getblockedUsers
(
int
page
,
int
perPage
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
new
GitLabApiForm
()
.
withParam
(
"blocked"
,
true
)
.
withParam
(
PAGE_PARAM
,
page
)
.
withParam
(
PER_PAGE_PARAM
,
perPage
);
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"users"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
User
>>()
{}));
}
/**
* Get a Pager of blocked users.
*
* GET /users?blocked=true
*
* @param itemsPerPage the number of blocked User instances that will be fetched per page
* @return a Pager of blocked User
* @throws GitLabApiException if any exception occurs
*/
public
Pager
<
User
>
getBlockedUsers
(
int
itemsPerPage
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
new
GitLabApiForm
().
withParam
(
"blocked"
,
true
);
return
(
new
Pager
<
User
>(
this
,
User
.
class
,
itemsPerPage
,
formData
.
asMap
(),
"users"
));
}
/**
/**
* Get a single user.
* Get a single user.
*
*
...
...
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