Skip to content

Commit 642e8ab

Browse files
novalistimols
authored andcommitted
Support creation of subgroups (#210)
... and every other group creation option that is presently documented.
1 parent 07dda99 commit 642e8ab

File tree

3 files changed

+154
-0
lines changed

3 files changed

+154
-0
lines changed

src/main/java/org/gitlab/api/GitlabAPI.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,35 @@ public GitlabGroup createGroup(String name, String path, String ldapCn, GitlabAc
485485
}
486486

487487

488+
/**
489+
* Creates a Group
490+
*
491+
* @param request The project-creation request
492+
* @param sudoUser The user to create the group on behalf of
493+
*
494+
* @return The GitLab Group
495+
* @throws IOException on gitlab api call error
496+
*/
497+
public GitlabGroup createGroup(CreateGroupRequest request, GitlabUser sudoUser) throws IOException {
498+
499+
Query query = new Query()
500+
.append("name", request.getName())
501+
.append("path", request.getPath())
502+
.appendIf("ldap_cn", request.getLdapCn())
503+
.appendIf("description", request.getDescription())
504+
.appendIf("membershipLock", request.getMembershipLock())
505+
.appendIf("share_with_group_lock", request.getShareWithGroupLock())
506+
.appendIf("visibility", request.getVisibility())
507+
.appendIf("lfs_enabled", request.getLfsEnabled())
508+
.appendIf("request_access_enabled", request.getRequestAccessEnabled())
509+
.appendIf("parent_id", request.getParentId())
510+
.appendIf(PARAM_SUDO, sudoUser != null ? sudoUser.getId() : null);
511+
512+
String tailUrl = GitlabGroup.URL + query.toString();
513+
514+
return dispatch().to(tailUrl, GitlabGroup.class);
515+
}
516+
488517
/**
489518
* Creates a Group
490519
*
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
package org.gitlab.api.models;
2+
3+
4+
public class CreateGroupRequest {
5+
6+
public CreateGroupRequest(String name) {
7+
this(name, name);
8+
}
9+
10+
public CreateGroupRequest(String name, String path) {
11+
this.name = name;
12+
this.path = path;
13+
}
14+
15+
private String name;
16+
private String path;
17+
private String ldapCn;
18+
private String description;
19+
private Boolean membershipLock;
20+
private Boolean shareWithGroupLock;
21+
private Boolean visibility;
22+
private Boolean lfsEnabled;
23+
private Boolean requestAccessEnabled;
24+
private Integer parentId;
25+
26+
public String getName() {
27+
return name;
28+
}
29+
30+
public CreateGroupRequest setName(String name) {
31+
this.name = name;
32+
return this;
33+
}
34+
public String getPath() {
35+
return path;
36+
}
37+
38+
public CreateGroupRequest setPath(String path) {
39+
this.path = path;
40+
return this;
41+
}
42+
43+
public String getLdapCn() {
44+
return ldapCn;
45+
}
46+
47+
public CreateGroupRequest setLdapCn(String ldapCn) {
48+
this.ldapCn = ldapCn;
49+
return this;
50+
}
51+
52+
public String getDescription() {
53+
return description;
54+
}
55+
56+
public CreateGroupRequest setDescription(String description) {
57+
this.description = description;
58+
return this;
59+
}
60+
61+
public Boolean getMembershipLock() {
62+
return membershipLock;
63+
}
64+
65+
public CreateGroupRequest setMembershipLock(Boolean membershipLock) {
66+
this.membershipLock = membershipLock;
67+
return this;
68+
}
69+
70+
public Boolean getShareWithGroupLock() {
71+
return shareWithGroupLock;
72+
}
73+
74+
public CreateGroupRequest setShareWithGroupLock(Boolean shareWithGroupLock) {
75+
this.shareWithGroupLock = shareWithGroupLock;
76+
return this;
77+
}
78+
79+
public Boolean getVisibility() {
80+
return visibility;
81+
}
82+
83+
public CreateGroupRequest setVisibility(Boolean visibility) {
84+
this.visibility = visibility;
85+
return this;
86+
}
87+
88+
public Boolean getLfsEnabled() {
89+
return lfsEnabled;
90+
}
91+
92+
public CreateGroupRequest setLfsEnabled(Boolean lfsEnabled) {
93+
this.lfsEnabled = lfsEnabled;
94+
return this;
95+
}
96+
97+
public Boolean getRequestAccessEnabled() {
98+
return requestAccessEnabled;
99+
}
100+
101+
public CreateGroupRequest setRequestAccessEnabled(Boolean requestAccessEnabled) {
102+
this.requestAccessEnabled = requestAccessEnabled;
103+
return this;
104+
}
105+
106+
public Integer getParentId() {
107+
return parentId;
108+
}
109+
110+
public CreateGroupRequest setParentId(Integer parentId) {
111+
this.parentId = parentId;
112+
return this;
113+
}
114+
}

src/main/java/org/gitlab/api/models/GitlabGroup.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,25 @@ public class GitlabGroup {
2424
@JsonProperty("web_url")
2525
private String webUrl;
2626

27+
@JsonProperty("parent_id")
28+
private Integer parentId;
29+
2730
public Integer getId() {
2831
return id;
2932
}
3033

34+
public Integer getParentId() {
35+
return parentId;
36+
}
37+
3138
public void setId(Integer id) {
3239
this.id = id;
3340
}
3441

42+
public void setParentId(Integer parentId) {
43+
this.parentId = parentId;
44+
}
45+
3546
public String getName() {
3647
return name;
3748
}

0 commit comments

Comments
 (0)