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
036fa56d
Commit
036fa56d
authored
Jan 03, 2018
by
Greg Messner
Browse files
Added hard_delete support to deleteUser() (#123).
parent
ddc98a7a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/UserApi.java
View file @
036fa56d
...
@@ -351,13 +351,28 @@ public class UserApi extends AbstractApi {
...
@@ -351,13 +351,28 @@ public class UserApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
void
deleteUser
(
Integer
userId
)
throws
GitLabApiException
{
public
void
deleteUser
(
Integer
userId
)
throws
GitLabApiException
{
deleteUser
(
userId
,
null
);
}
/**
* Deletes a user. Available only for administrators.
*
* DELETE /users/:id
*
* @param userId the user ID to delete
* @param hardDelete If true, contributions that would usually be moved to the
* ghost user will be deleted instead, as well as groups owned solely by this user
* @throws GitLabApiException if any exception occurs
*/
public
void
deleteUser
(
Integer
userId
,
Boolean
hardDelete
)
throws
GitLabApiException
{
if
(
userId
==
null
)
{
if
(
userId
==
null
)
{
throw
new
RuntimeException
(
"userId cannot be null"
);
throw
new
RuntimeException
(
"userId cannot be null"
);
}
}
GitLabApiForm
formData
=
new
GitLabApiForm
().
withParam
(
"hard_delete "
,
hardDelete
);
Response
.
Status
expectedStatus
=
(
isApiVersion
(
ApiVersion
.
V3
)
?
Response
.
Status
.
OK
:
Response
.
Status
.
NO_CONTENT
);
Response
.
Status
expectedStatus
=
(
isApiVersion
(
ApiVersion
.
V3
)
?
Response
.
Status
.
OK
:
Response
.
Status
.
NO_CONTENT
);
delete
(
expectedStatus
,
null
,
"users"
,
userId
);
delete
(
expectedStatus
,
formData
.
asMap
()
,
"users"
,
userId
);
}
}
/**
/**
...
@@ -369,7 +384,21 @@ public class UserApi extends AbstractApi {
...
@@ -369,7 +384,21 @@ public class UserApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
void
deleteUser
(
User
user
)
throws
GitLabApiException
{
public
void
deleteUser
(
User
user
)
throws
GitLabApiException
{
deleteUser
(
user
.
getId
());
deleteUser
(
user
.
getId
(),
null
);
}
/**
* Deletes a user. Available only for administrators.
*
* DELETE /users/:id
*
* @param user the User instance to delete
* @param hardDelete If true, contributions that would usually be moved to the
* ghost user will be deleted instead, as well as groups owned solely by this user
* @throws GitLabApiException if any exception occurs
*/
public
void
deleteUser
(
User
user
,
Boolean
hardDelete
)
throws
GitLabApiException
{
deleteUser
(
user
.
getId
(),
hardDelete
);
}
}
/**
/**
...
...
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