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
3cbf13d2
Commit
3cbf13d2
authored
Dec 11, 2017
by
Greg Messner
Browse files
addGroup() methods now return the created Group instance (#109).
parent
ac78f803
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/GroupApi.java
View file @
3cbf13d2
...
@@ -183,14 +183,77 @@ public class GroupApi extends AbstractApi {
...
@@ -183,14 +183,77 @@ public class GroupApi extends AbstractApi {
*
*
* @param name the name of the group to add
* @param name the name of the group to add
* @param path the path for the group
* @param path the path for the group
* @return the created Group instance
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
void
addGroup
(
String
name
,
String
path
)
throws
GitLabApiException
{
public
Group
addGroup
(
String
name
,
String
path
)
throws
GitLabApiException
{
Form
formData
=
new
Form
();
Form
formData
=
new
Form
();
formData
.
param
(
"name"
,
name
);
formData
.
param
(
"name"
,
name
);
formData
.
param
(
"path"
,
path
);
formData
.
param
(
"path"
,
path
);
post
(
Response
.
Status
.
CREATED
,
formData
,
"groups"
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"groups"
);
return
(
response
.
readEntity
(
Group
.
class
));
}
/**
* 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 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
* @return the created Group instance
* @throws GitLabApiException if any exception occurs
*/
public
Group
addGroup
(
String
name
,
String
path
,
String
description
,
Visibility
visibility
,
Boolean
lfsEnabled
,
Boolean
requestAccessEnabled
,
Integer
parentId
)
throws
GitLabApiException
{
Form
formData
=
new
GitLabApiForm
()
.
withParam
(
"name"
,
name
)
.
withParam
(
"path"
,
path
)
.
withParam
(
"description"
,
description
)
.
withParam
(
"visibility"
,
visibility
)
.
withParam
(
"lfs_enabled"
,
lfsEnabled
)
.
withParam
(
"request_access_enabled"
,
requestAccessEnabled
)
.
withParam
(
"parent_id"
,
isApiVersion
(
ApiVersion
.
V3
)
?
null
:
parentId
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"groups"
);
return
(
response
.
readEntity
(
Group
.
class
));
}
/**
* Updates a 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 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
* @return the updated Group instance
* @throws GitLabApiException if any exception occurs
*/
public
Group
updateGroup
(
Integer
groupId
,
String
name
,
String
path
,
String
description
,
Visibility
visibility
,
Boolean
lfsEnabled
,
Boolean
requestAccessEnabled
,
Integer
parentId
)
throws
GitLabApiException
{
Form
formData
=
new
GitLabApiForm
()
.
withParam
(
"name"
,
name
)
.
withParam
(
"path"
,
path
)
.
withParam
(
"description"
,
description
)
.
withParam
(
"visibility"
,
visibility
)
.
withParam
(
"lfs_enabled"
,
lfsEnabled
)
.
withParam
(
"request_access_enabled"
,
requestAccessEnabled
)
.
withParam
(
"parent_id"
,
isApiVersion
(
ApiVersion
.
V3
)
?
null
:
parentId
);
Response
response
=
put
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"groups"
,
groupId
);
return
(
response
.
readEntity
(
Group
.
class
));
}
}
/**
/**
...
@@ -208,9 +271,12 @@ public class GroupApi extends AbstractApi {
...
@@ -208,9 +271,12 @@ public class GroupApi extends AbstractApi {
* @param requestAccessEnabled (optional) - Allow users to request member access.
* @param requestAccessEnabled (optional) - Allow users to request member access.
* @param parentId (optional) - The parent group id for creating nested group.
* @param parentId (optional) - The parent group id for creating nested group.
* @param sharedRunnersMinutesLimit (optional) - (admin-only) Pipeline minutes quota for this group
* @param sharedRunnersMinutesLimit (optional) - (admin-only) Pipeline minutes quota for this group
* @return the created Group instance
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
* @deprecated Will be removed in version 5.0, replaced by {@link #addGroup(String, String, String, Visibility,
* Boolean, Boolean, Integer)}
*/
*/
public
void
addGroup
(
String
name
,
String
path
,
String
description
,
Boolean
membershipLock
,
public
Group
addGroup
(
String
name
,
String
path
,
String
description
,
Boolean
membershipLock
,
Boolean
shareWithGroupLock
,
Visibility
visibility
,
Boolean
lfsEnabled
,
Boolean
requestAccessEnabled
,
Boolean
shareWithGroupLock
,
Visibility
visibility
,
Boolean
lfsEnabled
,
Boolean
requestAccessEnabled
,
Integer
parentId
,
Integer
sharedRunnersMinutesLimit
)
throws
GitLabApiException
{
Integer
parentId
,
Integer
sharedRunnersMinutesLimit
)
throws
GitLabApiException
{
...
@@ -225,11 +291,12 @@ public class GroupApi extends AbstractApi {
...
@@ -225,11 +291,12 @@ public class GroupApi extends AbstractApi {
.
withParam
(
"request_access_enabled"
,
requestAccessEnabled
)
.
withParam
(
"request_access_enabled"
,
requestAccessEnabled
)
.
withParam
(
"parent_id"
,
parentId
)
.
withParam
(
"parent_id"
,
parentId
)
.
withParam
(
"shared_runners_minutes_limit"
,
sharedRunnersMinutesLimit
);
.
withParam
(
"shared_runners_minutes_limit"
,
sharedRunnersMinutesLimit
);
post
(
Response
.
Status
.
CREATED
,
formData
,
"groups"
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"groups"
);
return
(
response
.
readEntity
(
Group
.
class
));
}
}
/**
/**
*
Cre
ates a
new
project group. Available only for users who can create groups.
*
Upd
ates a project group. Available only for users who can create groups.
*
*
* PUT /groups
* PUT /groups
*
*
...
@@ -241,11 +308,13 @@ public class GroupApi extends AbstractApi {
...
@@ -241,11 +308,13 @@ public class GroupApi extends AbstractApi {
* @param shareWithGroupLock (optional, boolean) - Prevent sharing a project with another group 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 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 lfsEnabled (optional) - Enable/disable Large File Storage (LFS) for the projects in this group
* @param requestAccessEnabled (optional) - Allow users to request member access
.
* @param requestAccessEnabled (optional) - Allow users to request member access
* @param parentId (optional) - The parent group id for creating nested group
.
* @param parentId (optional) - The parent group id for creating nested group
* @param sharedRunnersMinutesLimit (optional) - (admin-only) Pipeline minutes quota for this group
* @param sharedRunnersMinutesLimit (optional) - (admin-only) Pipeline minutes quota for this group
* @return the updated Group instance
* @return the updated Group instance
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
* @deprecated Will be removed in version 5.0, replaced by {@link #updateGroup(Integer, String, String, String,
* Visibility, Boolean, Boolean, Integer)}
*/
*/
public
Group
updateGroup
(
Integer
groupId
,
String
name
,
String
path
,
String
description
,
Boolean
membershipLock
,
public
Group
updateGroup
(
Integer
groupId
,
String
name
,
String
path
,
String
description
,
Boolean
membershipLock
,
Boolean
shareWithGroupLock
,
Visibility
visibility
,
Boolean
lfsEnabled
,
Boolean
requestAccessEnabled
,
Boolean
shareWithGroupLock
,
Visibility
visibility
,
Boolean
lfsEnabled
,
Boolean
requestAccessEnabled
,
...
@@ -262,7 +331,6 @@ public class GroupApi extends AbstractApi {
...
@@ -262,7 +331,6 @@ public class GroupApi extends AbstractApi {
.
withParam
(
"request_access_enabled"
,
requestAccessEnabled
)
.
withParam
(
"request_access_enabled"
,
requestAccessEnabled
)
.
withParam
(
"parent_id"
,
parentId
)
.
withParam
(
"parent_id"
,
parentId
)
.
withParam
(
"shared_runners_minutes_limit"
,
sharedRunnersMinutesLimit
);
.
withParam
(
"shared_runners_minutes_limit"
,
sharedRunnersMinutesLimit
);
Response
response
=
put
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"groups"
,
groupId
);
Response
response
=
put
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"groups"
,
groupId
);
return
(
response
.
readEntity
(
Group
.
class
));
return
(
response
.
readEntity
(
Group
.
class
));
}
}
...
...
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