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
cabccb49
Commit
cabccb49
authored
May 09, 2018
by
David Lam
Committed by
Greg Messner
May 08, 2018
Browse files
add extern uid field for create (#182)
* add extern uid field for create * added fluent builder pattern to User
parent
b61f3f9b
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/UserApi.java
View file @
cabccb49
...
@@ -311,23 +311,34 @@ public class UserApi extends AbstractApi {
...
@@ -311,23 +311,34 @@ public class UserApi extends AbstractApi {
/**
/**
* Creates a new user. Note only administrators can create new users.
* Creates a new user. Note only administrators can create new users.
* Either password or reset_password should be specified (reset_password takes priority).
*
* If both the User object's projectsLimit and the parameter projectsLimit is specified
* the parameter will take precedence.
*
*
* POST /users
* POST /users
*
*
* email (required) - Email
* email (required) - Email
* password (required) - Password
* password (optional) - Password
* reset_password (optional) - Send user password reset link - true or false(default)
* username (required) - Username
* username (required) - Username
* name (required) - Name
* name (required) - Name
* skype (optional) - Skype ID
* skype (optional) - Skype ID
* linkedin (optional) - Linked
i
n
* linkedin (optional) - Linked
I
n
* twitter (optional) - Twitter account
* twitter (optional) - Twitter account
* website_url (optional) - Website url
* website_url (optional) - Website URL
* organization (optional) - Organization name
* projects_limit (optional) - Number of projects user can create
* projects_limit (optional) - Number of projects user can create
* extern_uid (optional) - External UID
* extern_uid (optional) - External UID
* provider (optional) - External provider name
* provider (optional) - External provider name
* bio (optional) - User's bio
* bio (optional) - User's biography
* location (optional) - User's location
* admin (optional) - User is admin - true or false (default)
* admin (optional) - User is admin - true or false (default)
* can_create_group (optional) - User can create groups - true or false
* can_create_group (optional) - User can create groups - true or false
* skip_confirmation (optional) - Skip confirmation - true or false (default)
* external (optional) - Flags the user as external - true or false(default)
* avatar (optional) - Image file for user's avatar
* shared_runners_minutes_limit (optional) - Pipeline minutes quota for this user
*
*
* @param user the User instance with the user info to create
* @param user the User instance with the user info to create
* @param password the password for the new user
* @param password the password for the new user
...
@@ -335,31 +346,79 @@ public class UserApi extends AbstractApi {
...
@@ -335,31 +346,79 @@ public class UserApi extends AbstractApi {
* @return created User instance
* @return created User instance
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
User
createUser
(
User
user
,
String
password
,
Integer
projectsLimit
)
throws
GitLabApiException
{
public
User
createUser
(
User
user
,
CharSequence
password
,
Integer
projectsLimit
)
throws
GitLabApiException
{
Form
formData
=
userToForm
(
user
,
projectsLimit
,
password
,
true
);
Form
formData
=
userToForm
(
user
,
projectsLimit
,
password
,
null
,
true
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"users"
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"users"
);
return
(
response
.
readEntity
(
User
.
class
));
return
(
response
.
readEntity
(
User
.
class
));
}
}
/**
/**
* Modifies an existing user. Only administrators can change attributes of a user.
* Creates a new user. Note only administrators can create new users.
* Either password or reset_password should be specified (reset_password takes priority).
*
*
* PUT /users/:id
* Creates a user with reset_password being <code>true</code>
*
* POST /users
*
*
* email (required) - Email
* email (required) - Email
* password (required) - Password
* password (optional) - Password
* reset_password (optional) - Send user password reset link - true or false(default)
* username (required) - Username
* username (required) - Username
* name (required) - Name
* name (required) - Name
* skype (optional) - Skype ID
* skype (optional) - Skype ID
* linkedin (optional) - Linked
i
n
* linkedin (optional) - Linked
I
n
* twitter (optional) - Twitter account
* twitter (optional) - Twitter account
* website_url (optional) - Website url
* website_url (optional) - Website URL
* organization (optional) - Organization name
* projects_limit (optional) - Number of projects user can create
* projects_limit (optional) - Number of projects user can create
* extern_uid (optional) - External UID
* extern_uid (optional) - External UID
* provider (optional) - External provider name
* provider (optional) - External provider name
* bio (optional) - User's bio
* bio (optional) - User's biography
* location (optional) - User's location
* admin (optional) - User is admin - true or false (default)
* admin (optional) - User is admin - true or false (default)
* can_create_group (optional) - User can create groups - true or false
* can_create_group (optional) - User can create groups - true or false
* skip_confirmation (optional) - Skip confirmation - true or false (default)
* external (optional) - Flags the user as external - true or false(default)
* avatar (optional) - Image file for user's avatar
* shared_runners_minutes_limit (optional) - Pipeline minutes quota for this user
*
* @param user the User instance with the user info to create
* @param password the password for the new user
* @param resetPassword whether to send a password reset link
* @return created User instance
* @throws GitLabApiException if any exception occurs
*/
public
User
createUser
(
User
user
,
CharSequence
password
,
boolean
resetPassword
)
throws
GitLabApiException
{
Form
formData
=
userToForm
(
user
,
null
,
password
,
resetPassword
,
true
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"users"
);
return
(
response
.
readEntity
(
User
.
class
));
}
/**
* Modifies an existing user. Only administrators can change attributes of a user.
*
* PUT /users/:id
*
* email - Email
* username - Username
* name - Name
* password - Password
* skype - Skype ID
* linkedin - LinkedIn
* twitter - Twitter account
* website_url - Website URL
* organization - Organization name
* projects_limit - Limit projects each user can create
* extern_uid - External UID
* provider - External provider name
* bio - User's biography
* location (optional) - User's location
* admin (optional) - User is admin - true or false (default)
* can_create_group (optional) - User can create groups - true or false
* skip_reconfirmation (optional) - Skip reconfirmation - true or false (default)
* external (optional) - Flags the user as external - true or false(default)
* shared_runners_minutes_limit (optional) - Pipeline minutes quota for this user
* avatar (optional) - Image file for user's avatar
*
*
* @param user the User instance with the user info to modify
* @param user the User instance with the user info to modify
* @param password the new password for the user
* @param password the new password for the user
...
@@ -367,8 +426,8 @@ public class UserApi extends AbstractApi {
...
@@ -367,8 +426,8 @@ public class UserApi extends AbstractApi {
* @return the modified User instance
* @return the modified User instance
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
User
modifyUser
(
User
user
,
String
password
,
Integer
projectsLimit
)
throws
GitLabApiException
{
public
User
modifyUser
(
User
user
,
CharSequence
password
,
Integer
projectsLimit
)
throws
GitLabApiException
{
Form
form
=
userToForm
(
user
,
projectsLimit
,
password
,
false
);
Form
form
=
userToForm
(
user
,
projectsLimit
,
password
,
false
,
false
);
Response
response
=
put
(
Response
.
Status
.
OK
,
form
.
asMap
(),
"users"
,
user
.
getId
());
Response
response
=
put
(
Response
.
Status
.
OK
,
form
.
asMap
(),
"users"
,
user
.
getId
());
return
(
response
.
readEntity
(
User
.
class
));
return
(
response
.
readEntity
(
User
.
class
));
}
}
...
@@ -560,7 +619,7 @@ public class UserApi extends AbstractApi {
...
@@ -560,7 +619,7 @@ public class UserApi extends AbstractApi {
}
}
/**
/**
* Deletes key owned by currently authenticated user. This is an idempotent function and calling it
* Deletes key owned by currently authenticated user. This is an idempotent function and calling it
* on a key that is already deleted or not available results in success.
* on a key that is already deleted or not available results in success.
*
*
* DELETE /user/keys/:key_id
* DELETE /user/keys/:key_id
...
@@ -744,24 +803,34 @@ public class UserApi extends AbstractApi {
...
@@ -744,24 +803,34 @@ public class UserApi extends AbstractApi {
* @param create whether the form is being populated to create a new user
* @param create whether the form is being populated to create a new user
* @return the populated Form instance
* @return the populated Form instance
*/
*/
Form
userToForm
(
User
user
,
Integer
projectsLimit
,
String
password
,
boolean
create
)
{
Form
userToForm
(
User
user
,
Integer
projectsLimit
,
CharSequence
password
,
Boolean
resetPassword
,
boolean
create
)
{
if
(
create
)
{
if
((
password
==
null
||
password
.
toString
().
trim
().
isEmpty
())
&&
!
resetPassword
)
{
throw
new
IllegalArgumentException
(
"either password or reset_password must be set"
);
}
}
projectsLimit
=
(
projectsLimit
==
null
)
?
user
.
getProjectsLimit
()
:
projectsLimit
;
return
(
new
GitLabApiForm
()
return
(
new
GitLabApiForm
()
.
withParam
(
"email"
,
user
.
getEmail
(),
create
)
.
withParam
(
"email"
,
user
.
getEmail
(),
create
)
.
withParam
(
"password"
,
password
,
create
)
.
withParam
(
"password"
,
password
,
false
)
.
withParam
(
"reset_password"
,
resetPassword
,
false
)
.
withParam
(
"username"
,
user
.
getUsername
(),
create
)
.
withParam
(
"username"
,
user
.
getUsername
(),
create
)
.
withParam
(
"name"
,
user
.
getName
(),
create
)
.
withParam
(
"name"
,
user
.
getName
(),
create
)
.
withParam
(
"skype"
,
user
.
getSkype
(),
false
)
.
withParam
(
"skype"
,
user
.
getSkype
(),
false
)
.
withParam
(
"linkedin"
,
user
.
getLinkedin
(),
false
)
.
withParam
(
"linkedin"
,
user
.
getLinkedin
(),
false
)
.
withParam
(
"twitter"
,
user
.
getTwitter
(),
false
)
.
withParam
(
"twitter"
,
user
.
getTwitter
(),
false
)
.
withParam
(
"website_url"
,
user
.
getWebsiteUrl
(),
false
)
.
withParam
(
"website_url"
,
user
.
getWebsiteUrl
(),
false
)
.
withParam
(
"projects_limit"
,
projectsLimit
,
false
)
.
withParam
(
"organization"
,
user
.
getOrganization
(),
false
)
.
withParam
(
"organization"
,
user
.
getOrganization
(),
false
)
.
withParam
(
"projects_limit"
,
projectsLimit
,
false
)
.
withParam
(
"extern_uid"
,
user
.
getExternUid
(),
false
)
.
withParam
(
"provider"
,
user
.
getProvider
(),
false
)
.
withParam
(
"provider"
,
user
.
getProvider
(),
false
)
.
withParam
(
"bio"
,
user
.
getBio
(),
false
)
.
withParam
(
"bio"
,
user
.
getBio
(),
false
)
.
withParam
(
"location"
,
user
.
getLocation
(),
false
)
.
withParam
(
"location"
,
user
.
getLocation
(),
false
)
.
withParam
(
"admin"
,
user
.
getIsAdmin
(),
false
)
.
withParam
(
"admin"
,
user
.
getIsAdmin
(),
false
)
.
withParam
(
"can_create_group"
,
user
.
getCanCreateGroup
(),
false
)
.
withParam
(
"can_create_group"
,
user
.
getCanCreateGroup
(),
false
)
.
withParam
(
"external"
,
user
.
getExternal
(),
false
))
.
withParam
(
"skip_confirmation"
,
user
.
getSkipConfirmation
(),
false
)
.
withParam
(
"skip_confirmation"
,
user
.
getSkipConfirmation
(),
false
);
.
withParam
(
"external"
,
user
.
getExternal
(),
false
)
.
withParam
(
"shared_runners_minutes_limit"
,
user
.
getSharedRunnersMinutesLimit
(),
false
));
}
}
}
}
src/main/java/org/gitlab4j/api/models/User.java
View file @
cabccb49
...
@@ -4,4 +4,103 @@ import javax.xml.bind.annotation.XmlRootElement;
...
@@ -4,4 +4,103 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlRootElement
public
class
User
extends
AbstractUser
{
public
class
User
extends
AbstractUser
{
private
String
externUid
;
public
void
setExternUid
(
String
externUid
)
{
this
.
externUid
=
externUid
;
}
public
String
getExternUid
()
{
return
this
.
externUid
;
}
public
User
withEmail
(
String
email
)
{
setEmail
(
email
);
return
this
;
}
public
User
withName
(
String
name
)
{
setName
(
name
);
return
this
;
}
public
User
withUsername
(
String
username
)
{
setUsername
(
username
);
return
this
;
}
public
User
withSkype
(
String
skype
)
{
setSkype
(
skype
);
return
this
;
}
public
User
withLinkedin
(
String
linkedIn
)
{
setLinkedin
(
linkedIn
);
return
this
;
}
public
User
withTwitter
(
String
twitter
)
{
setTwitter
(
twitter
);
return
this
;
}
public
User
withWebsiteUrl
(
String
websiteUrl
)
{
setWebsiteUrl
(
websiteUrl
);
return
this
;
}
public
User
withOrganization
(
String
organization
)
{
setOrganization
(
organization
);
return
this
;
}
public
User
withProjectLimit
(
Integer
projectsLimit
)
{
setProjectsLimit
(
projectsLimit
);
return
this
;
}
public
User
withExternUid
(
String
externUid
)
{
setExternUid
(
externUid
);
return
this
;
}
public
User
withProvider
(
String
provider
)
{
setProvider
(
provider
);
return
this
;
}
public
User
withBio
(
String
bio
)
{
setBio
(
bio
);
return
this
;
}
public
User
withLocation
(
String
location
)
{
setLocation
(
location
);
return
this
;
}
public
User
withIsAdmin
(
Boolean
isAdmin
)
{
setIsAdmin
(
isAdmin
);
return
this
;
}
public
User
withCanCreateGroup
(
Boolean
canCreateGroup
)
{
setCanCreateGroup
(
canCreateGroup
);
return
this
;
}
public
User
withSkipConfirmation
(
Boolean
skipConfirmation
)
{
setSkipConfirmation
(
skipConfirmation
);
return
this
;
}
public
User
withExternal
(
Boolean
external
)
{
setExternal
(
external
);
return
this
;
}
public
User
withSharedRunnersMinuteLimit
(
Integer
sharedRunnersMinuteLimit
)
{
setSharedRunnersMinutesLimit
(
sharedRunnersMinuteLimit
);
return
this
;
}
}
}
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