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
c9779388
Commit
c9779388
authored
Jun 13, 2017
by
Greg Messner
Browse files
Updated GroupApi to match latest spec.
parent
26061bf8
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/GroupApi.java
View file @
c9779388
package
org.gitlab4j.api
;
package
org.gitlab4j.api
;
import
javax.ws.rs.core.Form
;
import
javax.ws.rs.core.GenericType
;
import
javax.ws.rs.core.Response
;
import
org.gitlab4j.api.models.Group
;
import
org.gitlab4j.api.models.Group
;
import
org.gitlab4j.api.models.Member
;
import
org.gitlab4j.api.models.Member
;
import
org.gitlab4j.api.models.Project
;
import
org.gitlab4j.api.models.Visibility
;
import
javax.ws.rs.core.Form
;
import
javax.ws.rs.core.GenericType
;
import
javax.ws.rs.core.Response
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -32,6 +33,21 @@ public class GroupApi extends AbstractApi {
...
@@ -32,6 +33,21 @@ public class GroupApi extends AbstractApi {
}));
}));
}
}
/**
* Get a list of projects belonging to the specified group ID.
*
* GET /groups/:id/projects
*
* @param groupId the group ID to list the projects for
* @return a list of projects belonging to the specified group ID
* @throws GitLabApiException if any exception occurs
*/
public
List
<
Project
>
getProjects
(
int
groupId
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"groups"
,
groupId
,
"projects"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Project
>>()
{
}));
}
/**
/**
* Get all details of a group.
* Get all details of a group.
*
*
...
@@ -47,7 +63,7 @@ public class GroupApi extends AbstractApi {
...
@@ -47,7 +63,7 @@ public class GroupApi extends AbstractApi {
}
}
/**
/**
* Creates a new project group. Available only for
admin
.
* Creates a new project group. Available only for
users who can create groups
.
*
*
* POST /groups
* POST /groups
*
*
...
@@ -63,6 +79,79 @@ public class GroupApi extends AbstractApi {
...
@@ -63,6 +79,79 @@ public class GroupApi extends AbstractApi {
post
(
Response
.
Status
.
CREATED
,
formData
,
"groups"
);
post
(
Response
.
Status
.
CREATED
,
formData
,
"groups"
);
}
}
/**
* Creates a new project group. Available only for users who can create groups.
*
* POST /groups
*
* @param name the name of the group to add
* @param path the path for the group
* @param description (optional) - The group's description
* @param membershipLock (optional, boolean) - Prevent adding new members to project membership within this group
* @param shareWithGroupLock (optional, boolean) - Prevent sharing a project with another group within this group
* @param visibility (optional) - The group's visibility. Can be private, internal, or public.
* @param lfsEnabled (optional) - Enable/disable Large File Storage (LFS) for the projects in this group
* @param requestAccessEnabled (optional) - Allow users to request member access.
* @param parentId (optional) - The parent group id for creating nested group.
* @param sharedRunnersMinutesLimit (optional) - (admin-only) Pipeline minutes quota for this group
* @throws GitLabApiException if any exception occurs
*/
public
void
addGroup
(
String
name
,
String
path
,
String
description
,
Boolean
membershipLock
,
Boolean
shareWithGroupLock
,
Visibility
visibility
,
Boolean
lfsEnabled
,
Boolean
requestAccessEnabled
,
Integer
parentId
,
Integer
sharedRunnersMinutesLimit
)
throws
GitLabApiException
{
Form
formData
=
new
GitLabApiForm
()
.
withParam
(
"name"
,
name
)
.
withParam
(
"path"
,
path
)
.
withParam
(
"description"
,
description
)
.
withParam
(
"membership_lock"
,
membershipLock
)
.
withParam
(
"share_with_group_lock"
,
shareWithGroupLock
)
.
withParam
(
"visibility"
,
visibility
)
.
withParam
(
"lfs_enabled"
,
lfsEnabled
)
.
withParam
(
"request_access_enabled"
,
requestAccessEnabled
)
.
withParam
(
"parent_id"
,
parentId
)
.
withParam
(
"shared_runners_minutes_limit"
,
sharedRunnersMinutesLimit
);
post
(
Response
.
Status
.
CREATED
,
formData
,
"groups"
);
}
/**
* Creates a new project group. Available only for users who can create groups.
*
* PUT /groups
*
* @param groupId the ID of the group to update
* @param name the name of the group to add
* @param path the path for the group
* @param description (optional) - The group's description
* @param membershipLock (optional, boolean) - Prevent adding new members to project membership within this group
* @param shareWithGroupLock (optional, boolean) - Prevent sharing a project with another group within this group
* @param visibility (optional) - The group's visibility. Can be private, internal, or public.
* @param lfsEnabled (optional) - Enable/disable Large File Storage (LFS) for the projects in this group
* @param requestAccessEnabled (optional) - Allow users to request member access.
* @param parentId (optional) - The parent group id for creating nested group.
* @param sharedRunnersMinutesLimit (optional) - (admin-only) Pipeline minutes quota for this group
* @throws GitLabApiException if any exception occurs
*/
public
Group
updateGroup
(
Integer
groupId
,
String
name
,
String
path
,
String
description
,
Boolean
membershipLock
,
Boolean
shareWithGroupLock
,
Visibility
visibility
,
Boolean
lfsEnabled
,
Boolean
requestAccessEnabled
,
Integer
parentId
,
Integer
sharedRunnersMinutesLimit
)
throws
GitLabApiException
{
Form
formData
=
new
GitLabApiForm
()
.
withParam
(
"name"
,
name
)
.
withParam
(
"path"
,
path
)
.
withParam
(
"description"
,
description
)
.
withParam
(
"membership_lock"
,
membershipLock
)
.
withParam
(
"share_with_group_lock"
,
shareWithGroupLock
)
.
withParam
(
"visibility"
,
visibility
)
.
withParam
(
"lfs_enabled"
,
lfsEnabled
)
.
withParam
(
"request_access_enabled"
,
requestAccessEnabled
)
.
withParam
(
"parent_id"
,
parentId
)
.
withParam
(
"shared_runners_minutes_limit"
,
sharedRunnersMinutesLimit
);
Response
response
=
put
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"groups"
,
groupId
);
return
(
response
.
readEntity
(
Group
.
class
));
}
/**
/**
* Removes group with all projects inside.
* Removes group with all projects inside.
*
*
...
@@ -139,4 +228,4 @@ public class GroupApi extends AbstractApi {
...
@@ -139,4 +228,4 @@ public class GroupApi extends AbstractApi {
public
void
removeMember
(
Integer
projectId
,
Integer
userId
)
throws
GitLabApiException
{
public
void
removeMember
(
Integer
projectId
,
Integer
userId
)
throws
GitLabApiException
{
delete
(
Response
.
Status
.
OK
,
null
,
"groups"
,
projectId
,
"members"
,
userId
);
delete
(
Response
.
Status
.
OK
,
null
,
"groups"
,
projectId
,
"members"
,
userId
);
}
}
}
}
\ No newline at end of file
src/main/java/org/gitlab4j/api/models/Group.java
View file @
c9779388
...
@@ -13,9 +13,18 @@ public class Group {
...
@@ -13,9 +13,18 @@ public class Group {
private
Integer
id
;
private
Integer
id
;
private
String
name
;
private
String
name
;
private
Integer
ownerId
;
private
String
path
;
private
String
path
;
private
String
description
;
private
Visibility
visibility
;
private
String
avatarUrl
;
private
String
webUrl
;
private
Boolean
requestAccessEnabled
;
private
String
fullName
;
private
String
fullPath
;
private
Integer
parentId
;
private
Integer
sharedRunnersMinutesLimit
;
private
List
<
Project
>
projects
;
private
List
<
Project
>
projects
;
private
List
<
Project
>
sharedProjects
;
public
Integer
getId
()
{
public
Integer
getId
()
{
return
this
.
id
;
return
this
.
id
;
...
@@ -33,14 +42,6 @@ public class Group {
...
@@ -33,14 +42,6 @@ public class Group {
this
.
name
=
name
;
this
.
name
=
name
;
}
}
public
Integer
getOwnerId
()
{
return
this
.
ownerId
;
}
public
void
setOwnerId
(
Integer
ownerId
)
{
this
.
ownerId
=
ownerId
;
}
public
String
getPath
()
{
public
String
getPath
()
{
return
this
.
path
;
return
this
.
path
;
}
}
...
@@ -49,6 +50,78 @@ public class Group {
...
@@ -49,6 +50,78 @@ public class Group {
this
.
path
=
path
;
this
.
path
=
path
;
}
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
Visibility
getVisibility
()
{
return
visibility
;
}
public
void
setVisibility
(
Visibility
visibility
)
{
this
.
visibility
=
visibility
;
}
public
String
getAvatarUrl
()
{
return
avatarUrl
;
}
public
void
setAvatarUrl
(
String
avatarUrl
)
{
this
.
avatarUrl
=
avatarUrl
;
}
public
String
getWebUrl
()
{
return
webUrl
;
}
public
void
setWebUrl
(
String
webUrl
)
{
this
.
webUrl
=
webUrl
;
}
public
Boolean
getRequestAccessEnabled
()
{
return
requestAccessEnabled
;
}
public
void
setRequestAccessEnabled
(
Boolean
requestAccessEnabled
)
{
this
.
requestAccessEnabled
=
requestAccessEnabled
;
}
public
String
getFullName
()
{
return
fullName
;
}
public
void
setFullName
(
String
fullName
)
{
this
.
fullName
=
fullName
;
}
public
String
getFullPath
()
{
return
fullPath
;
}
public
void
setFullPath
(
String
fullPath
)
{
this
.
fullPath
=
fullPath
;
}
public
Integer
getParentId
()
{
return
parentId
;
}
public
void
setParentId
(
Integer
parentId
)
{
this
.
parentId
=
parentId
;
}
public
Integer
getSharedRunnersMinutesLimit
()
{
return
sharedRunnersMinutesLimit
;
}
public
void
setSharedRunnersMinutesLimit
(
Integer
sharedRunnersMinutesLimit
)
{
this
.
sharedRunnersMinutesLimit
=
sharedRunnersMinutesLimit
;
}
public
List
<
Project
>
getProjects
()
{
public
List
<
Project
>
getProjects
()
{
return
(
projects
);
return
(
projects
);
}
}
...
@@ -56,4 +129,12 @@ public class Group {
...
@@ -56,4 +129,12 @@ public class Group {
public
void
setProjects
(
List
<
Project
>
projects
)
{
public
void
setProjects
(
List
<
Project
>
projects
)
{
this
.
projects
=
projects
;
this
.
projects
=
projects
;
}
}
public
List
<
Project
>
getSharedProjects
()
{
return
(
sharedProjects
);
}
public
void
setSharedProjects
(
List
<
Project
>
sharedProjects
)
{
this
.
sharedProjects
=
sharedProjects
;
}
}
}
src/main/java/org/gitlab4j/api/models/Namespace.java
View file @
c9779388
...
@@ -10,29 +10,11 @@ import javax.xml.bind.annotation.XmlRootElement;
...
@@ -10,29 +10,11 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
Namespace
{
public
class
Namespace
{
private
Date
createdAt
;
private
String
description
;
private
Integer
id
;
private
Integer
id
;
private
String
name
;
private
String
name
;
private
Integer
ownerId
;
private
String
path
;
private
String
path
;
private
String
updatedAt
;
private
String
kind
;
private
String
fullPath
;
public
Date
getCreatedAt
()
{
return
this
.
createdAt
;
}
public
void
setCreatedAt
(
Date
createdAt
)
{
this
.
createdAt
=
createdAt
;
}
public
String
getDescription
()
{
return
this
.
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
Integer
getId
()
{
public
Integer
getId
()
{
return
this
.
id
;
return
this
.
id
;
...
@@ -50,14 +32,6 @@ public class Namespace {
...
@@ -50,14 +32,6 @@ public class Namespace {
this
.
name
=
name
;
this
.
name
=
name
;
}
}
public
Integer
getOwnerId
()
{
return
this
.
ownerId
;
}
public
void
setOwnerId
(
Integer
ownerId
)
{
this
.
ownerId
=
ownerId
;
}
public
String
getPath
()
{
public
String
getPath
()
{
return
this
.
path
;
return
this
.
path
;
}
}
...
@@ -66,11 +40,19 @@ public class Namespace {
...
@@ -66,11 +40,19 @@ public class Namespace {
this
.
path
=
path
;
this
.
path
=
path
;
}
}
public
String
getUpdatedAt
()
{
public
String
getKind
()
{
return
this
.
updatedAt
;
return
kind
;
}
public
void
setKind
(
String
kind
)
{
this
.
kind
=
kind
;
}
public
String
getFullPath
()
{
return
fullPath
;
}
}
public
void
set
UpdatedAt
(
String
updatedAt
)
{
public
void
set
FullPath
(
String
fullPath
)
{
this
.
updatedAt
=
updatedAt
;
this
.
fullPath
=
fullPath
;
}
}
}
}
src/test/resources/org/gitlab4j/api/group.json
View file @
c9779388
{
{
"id"
:
1
,
"id"
:
4
,
"name"
:
"Foobar Group"
,
"name"
:
"Twitter"
,
"path"
:
"foo-bar"
,
"path"
:
"twitter"
,
"owner_id"
:
18
"description"
:
"Aliquid qui quis dignissimos distinctio ut commodi voluptas est."
,
"visibility"
:
"public"
,
"web_url"
:
"https://gitlab.example.com/groups/twitter"
,
"request_access_enabled"
:
false
,
"full_name"
:
"Twitter"
,
"full_path"
:
"twitter"
,
"parent_id"
:
1234
,
"shared_runners_minutes_limit"
:
133
,
"projects"
:
[
{
"id"
:
7
,
"description"
:
"Voluptas veniam qui et beatae voluptas doloremque explicabo facilis."
,
"default_branch"
:
"master"
,
"archived"
:
false
,
"visibility"
:
"public"
,
"ssh_url_to_repo"
:
"git@gitlab.example.com:twitter/typeahead-js.git"
,
"http_url_to_repo"
:
"https://gitlab.example.com/twitter/typeahead-js.git"
,
"web_url"
:
"https://gitlab.example.com/twitter/typeahead-js"
,
"name"
:
"Typeahead.Js"
,
"name_with_namespace"
:
"Twitter / Typeahead.Js"
,
"path"
:
"typeahead-js"
,
"path_with_namespace"
:
"twitter/typeahead-js"
,
"issues_enabled"
:
true
,
"merge_requests_enabled"
:
true
,
"wiki_enabled"
:
true
,
"jobs_enabled"
:
true
,
"snippets_enabled"
:
false
,
"container_registry_enabled"
:
true
,
"created_at"
:
"2016-06-17T07:47:25.578Z"
,
"last_activity_at"
:
"2016-06-17T07:47:25.881Z"
,
"shared_runners_enabled"
:
true
,
"creator_id"
:
1
,
"namespace"
:
{
"id"
:
4
,
"name"
:
"Twitter"
,
"path"
:
"twitter"
,
"kind"
:
"group"
},
"star_count"
:
0
,
"forks_count"
:
0
,
"open_issues_count"
:
3
,
"public_jobs"
:
true
,
"shared_with_groups"
:
[],
"request_access_enabled"
:
false
},
{
"id"
:
6
,
"description"
:
"Aspernatur omnis repudiandae qui voluptatibus eaque."
,
"default_branch"
:
"master"
,
"archived"
:
false
,
"visibility"
:
"internal"
,
"ssh_url_to_repo"
:
"git@gitlab.example.com:twitter/flight.git"
,
"http_url_to_repo"
:
"https://gitlab.example.com/twitter/flight.git"
,
"web_url"
:
"https://gitlab.example.com/twitter/flight"
,
"name"
:
"Flight"
,
"name_with_namespace"
:
"Twitter / Flight"
,
"path"
:
"flight"
,
"path_with_namespace"
:
"twitter/flight"
,
"issues_enabled"
:
true
,
"merge_requests_enabled"
:
true
,
"wiki_enabled"
:
true
,
"jobs_enabled"
:
true
,
"snippets_enabled"
:
false
,
"container_registry_enabled"
:
true
,
"created_at"
:
"2016-06-17T07:47:24.661Z"
,
"last_activity_at"
:
"2016-06-17T07:47:24.838Z"
,
"shared_runners_enabled"
:
true
,
"creator_id"
:
1
,
"namespace"
:
{
"id"
:
4
,
"name"
:
"Twitter"
,
"path"
:
"twitter"
,
"kind"
:
"group"
},
"star_count"
:
0
,
"forks_count"
:
0
,
"open_issues_count"
:
8
,
"public_jobs"
:
true
,
"shared_with_groups"
:
[],
"request_access_enabled"
:
false
}
],
"shared_projects"
:
[
{
"id"
:
8
,
"description"
:
"Velit eveniet provident fugiat saepe eligendi autem."
,
"default_branch"
:
"master"
,
"archived"
:
false
,
"visibility"
:
"private"
,
"ssh_url_to_repo"
:
"git@gitlab.example.com:h5bp/html5-boilerplate.git"
,
"http_url_to_repo"
:
"https://gitlab.example.com/h5bp/html5-boilerplate.git"
,
"web_url"
:
"https://gitlab.example.com/h5bp/html5-boilerplate"
,
"name"
:
"Html5 Boilerplate"
,
"name_with_namespace"
:
"H5bp / Html5 Boilerplate"
,
"path"
:
"html5-boilerplate"
,
"path_with_namespace"
:
"h5bp/html5-boilerplate"
,
"issues_enabled"
:
true
,
"merge_requests_enabled"
:
true
,
"wiki_enabled"
:
true
,
"jobs_enabled"
:
true
,
"snippets_enabled"
:
false
,
"container_registry_enabled"
:
true
,
"created_at"
:
"2016-06-17T07:47:27.089Z"
,
"last_activity_at"
:
"2016-06-17T07:47:27.310Z"
,
"shared_runners_enabled"
:
true
,
"creator_id"
:
1
,
"namespace"
:
{
"id"
:
5
,
"name"
:
"H5bp"
,
"path"
:
"h5bp"
,
"kind"
:
"group"
},
"star_count"
:
0
,
"forks_count"
:
0
,
"open_issues_count"
:
4
,
"public_jobs"
:
true
,
"shared_with_groups"
:
[
{
"group_id"
:
4
,
"group_name"
:
"Twitter"
,
"group_access_level"
:
30
},
{
"group_id"
:
3
,
"group_name"
:
"Gitlab Org"
,
"group_access_level"
:
10
}
]
}
]
}
}
src/test/resources/org/gitlab4j/api/project.json
View file @
c9779388
...
@@ -30,13 +30,9 @@
...
@@ -30,13 +30,9 @@
"last_activity_at"
:
"2013-09-30T13:46:02Z"
,
"last_activity_at"
:
"2013-09-30T13:46:02Z"
,
"creator_id"
:
3
,
"creator_id"
:
3
,
"namespace"
:
{
"namespace"
:
{
"created_at"
:
"2013-09-30T13:46:02Z"
,
"description"
:
""
,
"id"
:
3
,
"id"
:
3
,
"name"
:
"Diaspora"
,
"name"
:
"Diaspora"
,
"owner_id"
:
1
,
"path"
:
"diaspora"
"path"
:
"diaspora"
,
"updated_at"
:
"2013-09-30T13:46:02Z"
},
},
"permissions"
:
{
"permissions"
:
{
"project_access"
:
{
"project_access"
:
{
...
...
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