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
03de9141
Commit
03de9141
authored
Jan 12, 2018
by
Greg Messner
Browse files
Added support to fetch subgroups (#126).
parent
af23f997
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/Constants.java
View file @
03de9141
...
...
@@ -104,6 +104,28 @@ public interface Constants {
}
}
/** Enum to use for ordering the results of getGroups() and getSubGroups(). */
public
enum
GroupOrderBy
{
NAME
,
PATH
;
private
static
JacksonJsonEnumHelper
<
GroupOrderBy
>
enumHelper
=
new
JacksonJsonEnumHelper
<>(
GroupOrderBy
.
class
);
@JsonCreator
public
static
GroupOrderBy
forValue
(
String
value
)
{
return
enumHelper
.
forValue
(
value
);
}
@JsonValue
public
String
toValue
()
{
return
(
enumHelper
.
toString
(
this
));
}
@Override
public
String
toString
()
{
return
(
enumHelper
.
toString
(
this
));
}
}
/** Enum to use for specifying the scope when calling getPipelines(). */
public
enum
PipelineScope
{
...
...
src/main/java/org/gitlab4j/api/GroupApi.java
View file @
03de9141
...
...
@@ -12,6 +12,7 @@ import org.gitlab4j.api.models.AccessLevel;
import
org.gitlab4j.api.models.Group
;
import
org.gitlab4j.api.models.Member
;
import
org.gitlab4j.api.models.Project
;
import
org.gitlab4j.api.models.User
;
import
org.gitlab4j.api.models.Visibility
;
/**
...
...
@@ -97,7 +98,7 @@ public class GroupApi extends AbstractApi {
*
* @param search the group name or path search criteria
* @param itemsPerPage the number of Group instances that will be fetched per page
* @return a
List
containing matching Group instances
* @return a
Pager
containing matching Group instances
* @throws GitLabApiException if any exception occurs
*/
public
Pager
<
Group
>
getGroups
(
String
search
,
int
itemsPerPage
)
throws
GitLabApiException
{
...
...
@@ -105,6 +106,124 @@ public class GroupApi extends AbstractApi {
return
(
new
Pager
<
Group
>(
this
,
Group
.
class
,
itemsPerPage
,
formData
.
asMap
(),
"groups"
));
}
/**
* Get a list of visible direct subgroups in this group.
*
* <p><code>GET /groups/:id/subgroups</code></p>
*
* @param groupId the group ID to get the sub groups for
* @return a List<Group> containing the group's sub-groups
* @throws GitLabApiException if any exception occurs
* @since GitLab 10.3.0
*/
public
List
<
Group
>
getSubGroups
(
Integer
groupId
)
throws
GitLabApiException
{
return
(
getSubGroups
(
groupId
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
1
,
getDefaultPerPage
()));
}
/**
* Get a list of visible direct subgroups in this group.
*
* <p><code>GET /groups/:id/subgroups</code></p>
*
* @param groupId the group ID to get the sub groups for
* @param skipGroups skip the group IDs passed
* @param allAvailable show all the groups you have access to (defaults to false for authenticated users)
* @param search return the list of authorized groups matching the search criteria
* @param orderBy order groups by NAME or PATH. Default is NAME
* @param sortOrder order groups in ASC or DESC order. Default is ASC
* @param statistics include group statistics (admins only)
* @param owned limit to groups owned by the current user
* @return a List<Group> of the matching subgroups
* @throws GitLabApiException if any exception occurs
* @since GitLab 10.3.0
*/
public
List
<
Group
>
getSubGroups
(
Integer
groupId
,
List
<
Integer
>
skipGroups
,
Boolean
allAvailable
,
String
search
,
GroupOrderBy
orderBy
,
SortOrder
sortOrder
,
Boolean
statistics
,
Boolean
owned
)
throws
GitLabApiException
{
return
(
getSubGroups
(
groupId
,
skipGroups
,
allAvailable
,
search
,
orderBy
,
sortOrder
,
statistics
,
owned
,
1
,
getDefaultPerPage
()));
}
/**
* Get a list of visible direct subgroups in this group.
*
* <p><code>GET /groups/:id/subgroups</code></p>
*
* @param groupId the group ID to get the sub groups for
* @param skipGroups skip the group IDs passed
* @param allAvailable show all the groups you have access to (defaults to false for authenticated users)
* @param search return the list of authorized groups matching the search criteria
* @param orderBy order groups by NAME or PATH. Default is NAME
* @param sortOrder order groups in ASC or DESC order. Default is ASC
* @param statistics include group statistics (admins only)
* @param owned limit to groups owned by the current user
* @param page the page to get
* @param perPage the number of Group instances per page
* @return a List<Group> of the matching subgroups
* @throws GitLabApiException if any exception occurs
* @since GitLab 10.3.0
*/
public
List
<
Group
>
getSubGroups
(
Integer
groupId
,
List
<
Integer
>
skipGroups
,
Boolean
allAvailable
,
String
search
,
GroupOrderBy
orderBy
,
SortOrder
sortOrder
,
Boolean
statistics
,
Boolean
owned
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
Form
formData
=
new
GitLabApiForm
()
.
withParam
(
"skip_groups"
,
skipGroups
)
.
withParam
(
"all_available"
,
allAvailable
)
.
withParam
(
"search"
,
search
)
.
withParam
(
"order_by"
,
orderBy
)
.
withParam
(
"sort_order"
,
sortOrder
)
.
withParam
(
"statistics"
,
statistics
)
.
withParam
(
"owned"
,
owned
)
.
withParam
(
PAGE_PARAM
,
page
)
.
withParam
(
PER_PAGE_PARAM
,
perPage
);
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"groups"
,
groupId
,
"subgroups"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Group
>>()
{}));
}
/**
* Get a Pager of visible direct subgroups in this group.
*
* <p><code>GET /groups/:id/subgroups</code></p>
*
* @param groupId the group ID to get the sub groups for
* @param itemsPerPage the number of Group instances that will be fetched per page
* @return a Pager containing matching Group instances
* @throws GitLabApiException if any exception occurs
* @since GitLab 10.3.0
*/
public
Pager
<
Group
>
getSubGroups
(
Integer
groupId
,
int
itemsPerPage
)
throws
GitLabApiException
{
return
(
new
Pager
<
Group
>(
this
,
Group
.
class
,
itemsPerPage
,
null
,
"groups"
,
groupId
,
"subgroups"
));
}
/**
* Get a Pager of visible direct subgroups in this group.
*
* <p><code>GET /groups/:id/subgroups</code></p>
*
* @param groupId the group ID to get the sub groups for
* @param skipGroups skip the group IDs passed
* @param allAvailable show all the groups you have access to (defaults to false for authenticated users)
* @param search return the list of authorized groups matching the search criteria
* @param orderBy order groups by NAME or PATH. Default is NAME
* @param sortOrder order groups in ASC or DESC order. Default is ASC
* @param statistics include group statistics (admins only)
* @param owned limit to groups owned by the current user
* @param itemsPerPage the number of Group instances that will be fetched per page
* @return a Pager containing matching Group instances
* @throws GitLabApiException if any exception occurs
* @since GitLab 10.3.0
*/
public
Pager
<
Group
>
getSubGroups
(
Integer
groupId
,
List
<
Integer
>
skipGroups
,
Boolean
allAvailable
,
String
search
,
GroupOrderBy
orderBy
,
SortOrder
sortOrder
,
Boolean
statistics
,
Boolean
owned
,
int
itemsPerPage
)
throws
GitLabApiException
{
Form
formData
=
new
GitLabApiForm
()
.
withParam
(
"skip_groups"
,
skipGroups
)
.
withParam
(
"all_available"
,
allAvailable
)
.
withParam
(
"search"
,
search
)
.
withParam
(
"order_by"
,
orderBy
)
.
withParam
(
"sort_order"
,
sortOrder
)
.
withParam
(
"statistics"
,
statistics
)
.
withParam
(
"owned"
,
owned
);
return
(
new
Pager
<
Group
>(
this
,
Group
.
class
,
itemsPerPage
,
formData
.
asMap
(),
"groups"
,
groupId
,
"subgroups"
));
}
/**
* Get a list of projects belonging to the specified group ID.
*
...
...
src/main/java/org/gitlab4j/api/models/Group.java
View file @
03de9141
...
...
@@ -11,11 +11,52 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
Group
{
public
class
Statistics
{
private
Integer
storageSize
;
private
Integer
repositorySize
;
private
Integer
lfsObjectsSize
;
private
Integer
jobArtifactsSize
;
public
Integer
getStorageSize
()
{
return
storageSize
;
}
public
void
setStorageSize
(
Integer
storageSize
)
{
this
.
storageSize
=
storageSize
;
}
public
Integer
getRepositorySize
()
{
return
repositorySize
;
}
public
void
setRepositorySize
(
Integer
repositorySize
)
{
this
.
repositorySize
=
repositorySize
;
}
public
Integer
getLfsObjectsSize
()
{
return
lfsObjectsSize
;
}
public
void
setLfsObjectsSize
(
Integer
lfsObjectsSize
)
{
this
.
lfsObjectsSize
=
lfsObjectsSize
;
}
public
Integer
getJobArtifactsSize
()
{
return
jobArtifactsSize
;
}
public
void
setJobArtifactsSize
(
Integer
jobArtifactsSize
)
{
this
.
jobArtifactsSize
=
jobArtifactsSize
;
}
}
private
Integer
id
;
private
String
name
;
private
String
path
;
private
String
description
;
private
Visibility
visibility
;
private
Boolean
lfsEnabled
;
private
String
avatarUrl
;
private
String
webUrl
;
private
Boolean
requestAccessEnabled
;
...
...
@@ -23,6 +64,7 @@ public class Group {
private
String
fullPath
;
private
Integer
parentId
;
private
Integer
sharedRunnersMinutesLimit
;
private
Statistics
statistics
;
private
List
<
Project
>
projects
;
private
List
<
Project
>
sharedProjects
;
...
...
@@ -66,6 +108,14 @@ public class Group {
this
.
visibility
=
visibility
;
}
public
Boolean
getLfsEnabled
()
{
return
lfsEnabled
;
}
public
void
setLfsEnabled
(
Boolean
lfsEnabled
)
{
this
.
lfsEnabled
=
lfsEnabled
;
}
public
String
getAvatarUrl
()
{
return
avatarUrl
;
}
...
...
@@ -122,6 +172,14 @@ public class Group {
this
.
sharedRunnersMinutesLimit
=
sharedRunnersMinutesLimit
;
}
public
Statistics
getStatistics
()
{
return
statistics
;
}
public
void
setStatistics
(
Statistics
statistics
)
{
this
.
statistics
=
statistics
;
}
public
List
<
Project
>
getProjects
()
{
return
(
projects
);
}
...
...
src/test/resources/org/gitlab4j/api/group.json
View file @
03de9141
...
...
@@ -10,6 +10,12 @@
"full_path"
:
"twitter"
,
"parent_id"
:
1234
,
"shared_runners_minutes_limit"
:
133
,
"statistics"
:
{
"storage_size"
:
212
,
"repository_size"
:
33
,
"lfs_objects_size"
:
123
,
"job_artifacts_size"
:
57
},
"projects"
:
[
{
"id"
:
7
,
...
...
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