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
d0c57228
Commit
d0c57228
authored
Sep 19, 2018
by
Ruben Vitt
Committed by
Greg Messner
Sep 18, 2018
Browse files
feat-impl: custom attributes for users (#252)
parent
55518136
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/AbstractApi.java
View file @
d0c57228
...
@@ -113,13 +113,13 @@ public abstract class AbstractApi implements Constants {
...
@@ -113,13 +113,13 @@ public abstract class AbstractApi implements Constants {
protected
GitLabApiClient
getApiClient
()
{
protected
GitLabApiClient
getApiClient
()
{
return
(
gitLabApi
.
getApiClient
());
return
(
gitLabApi
.
getApiClient
());
}
}
/**
/**
* Encode a string to be used as in-path argument for a gitlab api request.
* Encode a string to be used as in-path argument for a gitlab api request.
*
*
* Standard URL encoding changes spaces to plus signs, but for arguments that are part of the path,
* Standard URL encoding changes spaces to plus signs, but for arguments that are part of the path,
* like the :file_path in a "Get raw file" request, gitlab expects spaces to be encoded with %20.
* like the :file_path in a "Get raw file" request, gitlab expects spaces to be encoded with %20.
*
*
* @param s the string to encode
* @param s the string to encode
* @return encoded version of s with spaces encoded as %2F
* @return encoded version of s with spaces encoded as %2F
* @throws GitLabApiException if encoding throws an exception
* @throws GitLabApiException if encoding throws an exception
...
@@ -517,6 +517,7 @@ public abstract class AbstractApi implements Constants {
...
@@ -517,6 +517,7 @@ public abstract class AbstractApi implements Constants {
return
(
new
GitLabApiException
(
thrown
));
return
(
new
GitLabApiException
(
thrown
));
}
}
/**
/**
* Creates a MultivaluedMap instance containing "page" and "per_page" params.
* Creates a MultivaluedMap instance containing "page" and "per_page" params.
*
*
...
@@ -525,6 +526,20 @@ public abstract class AbstractApi implements Constants {
...
@@ -525,6 +526,20 @@ public abstract class AbstractApi implements Constants {
* @return a MultivaluedMap instance containing "page" and "per_page" params
* @return a MultivaluedMap instance containing "page" and "per_page" params
*/
*/
protected
MultivaluedMap
<
String
,
String
>
getPageQueryParams
(
int
page
,
int
perPage
)
{
protected
MultivaluedMap
<
String
,
String
>
getPageQueryParams
(
int
page
,
int
perPage
)
{
return
(
new
GitLabApiForm
().
withParam
(
PAGE_PARAM
,
page
).
withParam
(
PER_PAGE_PARAM
,
perPage
).
asMap
());
}
/**
* Creates a MultivaluedMap instance containing "page" and "per_page" params.
*
* @param page the page to get
* @param perPage the number of projects per page
* @param customAttributesEnabled enables customAttributes for this query
* @return a MultivaluedMap instance containing "page" and "per_page" params
*/
protected
MultivaluedMap
<
String
,
String
>
getPageQueryParams
(
int
page
,
int
perPage
,
boolean
customAttributesEnabled
)
{
if
(
customAttributesEnabled
)
return
(
new
GitLabApiForm
().
withParam
(
"with_custom_attributes"
,
true
).
withParam
(
PAGE_PARAM
,
page
).
withParam
(
PER_PAGE_PARAM
,
perPage
).
asMap
());
return
(
new
GitLabApiForm
().
withParam
(
PAGE_PARAM
,
page
).
withParam
(
PER_PAGE_PARAM
,
perPage
).
asMap
());
return
(
new
GitLabApiForm
().
withParam
(
PAGE_PARAM
,
page
).
withParam
(
PER_PAGE_PARAM
,
perPage
).
asMap
());
}
}
...
@@ -536,4 +551,16 @@ public abstract class AbstractApi implements Constants {
...
@@ -536,4 +551,16 @@ public abstract class AbstractApi implements Constants {
protected
MultivaluedMap
<
String
,
String
>
getDefaultPerPageParam
()
{
protected
MultivaluedMap
<
String
,
String
>
getDefaultPerPageParam
()
{
return
(
new
GitLabApiForm
().
withParam
(
PER_PAGE_PARAM
,
getDefaultPerPage
()).
asMap
());
return
(
new
GitLabApiForm
().
withParam
(
PER_PAGE_PARAM
,
getDefaultPerPage
()).
asMap
());
}
}
/**
* Creates a MultivaluedMap instance containing the "per_page" param with the default value.
*
* @param customAttributesEnabled enables customAttributes for this query
* @return a MultivaluedMap instance containing the "per_page" param with the default value
*/
protected
MultivaluedMap
<
String
,
String
>
getDefaultPerPageParam
(
boolean
customAttributesEnabled
)
{
if
(
customAttributesEnabled
)
return
(
new
GitLabApiForm
().
withParam
(
"with_custom_attributes"
,
true
).
withParam
(
PER_PAGE_PARAM
,
getDefaultPerPage
()).
asMap
());
return
(
new
GitLabApiForm
().
withParam
(
PER_PAGE_PARAM
,
getDefaultPerPage
()).
asMap
());
}
}
}
src/main/java/org/gitlab4j/api/UserApi.java
View file @
d0c57228
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/models/AbstractUser.java
View file @
d0c57228
package
org.gitlab4j.api.models
;
package
org.gitlab4j.api.models
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
...
@@ -7,6 +9,7 @@ import javax.xml.bind.annotation.XmlAccessType;
...
@@ -7,6 +9,7 @@ import javax.xml.bind.annotation.XmlAccessType;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
AbstractUser
{
public
class
AbstractUser
{
private
String
avatarUrl
;
private
String
avatarUrl
;
...
@@ -17,6 +20,7 @@ public class AbstractUser {
...
@@ -17,6 +20,7 @@ public class AbstractUser {
private
Date
confirmedAt
;
private
Date
confirmedAt
;
private
Date
createdAt
;
private
Date
createdAt
;
private
Date
currentSignInAt
;
private
Date
currentSignInAt
;
private
List
<
CustomAttribute
>
customAttributes
;
private
String
email
;
private
String
email
;
private
Boolean
external
;
private
Boolean
external
;
private
Integer
id
;
private
Integer
id
;
...
@@ -288,4 +292,12 @@ public class AbstractUser {
...
@@ -288,4 +292,12 @@ public class AbstractUser {
public
void
setSkipConfirmation
(
Boolean
skipConfirmation
)
{
public
void
setSkipConfirmation
(
Boolean
skipConfirmation
)
{
this
.
skipConfirmation
=
skipConfirmation
;
this
.
skipConfirmation
=
skipConfirmation
;
}
}
public
List
<
CustomAttribute
>
getCustomAttributes
()
{
return
customAttributes
;
}
public
void
setCustomAttributes
(
List
<
CustomAttribute
>
customAttributes
)
{
this
.
customAttributes
=
customAttributes
;
}
}
}
src/main/java/org/gitlab4j/api/models/CustomAttribute.java
0 → 100644
View file @
d0c57228
package
org.gitlab4j.api.models
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
CustomAttribute
{
private
String
key
;
private
String
value
;
public
String
getKey
()
{
return
key
;
}
public
void
setKey
(
String
key
)
{
this
.
key
=
key
;
}
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
public
CustomAttribute
withKey
(
String
key
)
{
this
.
key
=
key
;
return
this
;
}
public
CustomAttribute
withValue
(
String
value
)
{
this
.
value
=
value
;
return
this
;
}
}
src/main/java/org/gitlab4j/api/models/User.java
View file @
d0c57228
package
org.gitlab4j.api.models
;
package
org.gitlab4j.api.models
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
java.util.List
;
@XmlRootElement
@XmlRootElement
public
class
User
extends
AbstractUser
{
public
class
User
extends
AbstractUser
{
...
@@ -103,4 +104,9 @@ public class User extends AbstractUser {
...
@@ -103,4 +104,9 @@ public class User extends AbstractUser {
setSharedRunnersMinutesLimit
(
sharedRunnersMinuteLimit
);
setSharedRunnersMinutesLimit
(
sharedRunnersMinuteLimit
);
return
this
;
return
this
;
}
}
public
User
withCustomAttributes
(
List
<
CustomAttribute
>
customAttributes
)
{
setCustomAttributes
(
customAttributes
);
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