Skip to content

Commit 695d142

Browse files
committed
feat: create group webhook gitlab4j#1173
1 parent 6e5e2e6 commit 695d142

File tree

6 files changed

+529
-25
lines changed

6 files changed

+529
-25
lines changed

src/main/java/org/gitlab4j/api/GroupApi.java

+16-18
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,8 @@
1616
import javax.ws.rs.core.Response;
1717

1818
import org.gitlab4j.api.GitLabApi.ApiVersion;
19-
import org.gitlab4j.api.models.AccessLevel;
20-
import org.gitlab4j.api.models.AccessRequest;
21-
import org.gitlab4j.api.models.AuditEvent;
22-
import org.gitlab4j.api.models.Badge;
23-
import org.gitlab4j.api.models.CustomAttribute;
24-
import org.gitlab4j.api.models.Group;
25-
import org.gitlab4j.api.models.GroupAccessToken;
26-
import org.gitlab4j.api.models.GroupFilter;
27-
import org.gitlab4j.api.models.GroupParams;
28-
import org.gitlab4j.api.models.GroupProjectsFilter;
19+
import org.gitlab4j.api.models.*;
2920
import org.gitlab4j.api.models.ImpersonationToken.Scope;
30-
import org.gitlab4j.api.models.Iteration;
31-
import org.gitlab4j.api.models.IterationFilter;
32-
import org.gitlab4j.api.models.LdapGroupLink;
33-
import org.gitlab4j.api.models.Member;
34-
import org.gitlab4j.api.models.Project;
35-
import org.gitlab4j.api.models.SamlGroupLink;
36-
import org.gitlab4j.api.models.Variable;
37-
import org.gitlab4j.api.models.Visibility;
3821
import org.gitlab4j.api.utils.ISO8601;
3922

4023
/**
@@ -2440,4 +2423,19 @@ public GroupAccessToken rotateGroupAccessToken(Object groupIdOrPath, Long tokenI
24402423
public void revokeGroupAccessToken(Object groupIdOrPath, Long tokenId) throws GitLabApiException {
24412424
delete(Response.Status.NO_CONTENT, null, "groups", getGroupIdOrPath(groupIdOrPath), "access_tokens", tokenId);
24422425
}
2426+
2427+
/**
2428+
* Add a group hook
2429+
*
2430+
* <pre><code>GitLab Endpoint: POST /groups/:id/hooks</code></pre>
2431+
*
2432+
* @param groupIdOrPath the group in the form of an Long(ID), String(path), or Group instance
2433+
* @param groupHookParams webhook creation options
2434+
* @throws GitLabApiException if any exception occurs
2435+
*/
2436+
public GroupHook addWebhook(Object groupIdOrPath, GroupHookParams groupHookParams) throws GitLabApiException {
2437+
Response response = post(
2438+
Response.Status.CREATED, groupHookParams.getForm(), "groups", getGroupIdOrPath(groupIdOrPath), "hooks");
2439+
return (response.readEntity(GroupHook.class));
2440+
}
24432441
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
package org.gitlab4j.api.models;
2+
3+
import java.io.Serializable;
4+
import java.util.Date;
5+
6+
public class GroupHook implements Serializable {
7+
private static final long serialVersionUID = 1L;
8+
9+
private Long id;
10+
private String url;
11+
private String name;
12+
private String description;
13+
private Long groupId;
14+
private Boolean pushEvents;
15+
private String pushEventsBranchFilter;
16+
private String branchFilterStrategy;
17+
private Boolean issuesEvents;
18+
private Boolean confidentialIssuesEvents;
19+
private Boolean mergeRequestsEvents;
20+
private Boolean tagPushEvents;
21+
private Boolean noteEvents;
22+
private Boolean confidentialNoteEvents;
23+
private Boolean jobEvents;
24+
private Boolean pipelineEvents;
25+
private Boolean wikiPageEvents;
26+
private Boolean deploymentEvents;
27+
private Boolean featureFlagEvents;
28+
private Boolean releasesEvents;
29+
private Boolean subgroupEvents;
30+
private Boolean memberEvents;
31+
private Boolean enableSslVerification;
32+
private Boolean repositoryUpdateEvents;
33+
private Date createdAt;
34+
private Boolean resourceAccessTokenEvents;
35+
private String customWebhookTemplate;
36+
37+
public String getDescription() {
38+
return description;
39+
}
40+
41+
public void setDescription(String description) {
42+
this.description = description;
43+
}
44+
45+
public Long getId() {
46+
return id;
47+
}
48+
49+
public void setId(Long id) {
50+
this.id = id;
51+
}
52+
53+
public String getUrl() {
54+
return url;
55+
}
56+
57+
public void setUrl(String url) {
58+
this.url = url;
59+
}
60+
61+
public String getName() {
62+
return name;
63+
}
64+
65+
public void setName(String name) {
66+
this.name = name;
67+
}
68+
69+
public Long getGroupId() {
70+
return groupId;
71+
}
72+
73+
public void setGroupId(Long groupId) {
74+
this.groupId = groupId;
75+
}
76+
77+
public Boolean getPushEvents() {
78+
return pushEvents;
79+
}
80+
81+
public void setPushEvents(Boolean pushEvents) {
82+
this.pushEvents = pushEvents;
83+
}
84+
85+
public String getPushEventsBranchFilter() {
86+
return pushEventsBranchFilter;
87+
}
88+
89+
public void setPushEventsBranchFilter(String pushEventsBranchFilter) {
90+
this.pushEventsBranchFilter = pushEventsBranchFilter;
91+
}
92+
93+
public String getBranchFilterStrategy() {
94+
return branchFilterStrategy;
95+
}
96+
97+
public void setBranchFilterStrategy(String branchFilterStrategy) {
98+
this.branchFilterStrategy = branchFilterStrategy;
99+
}
100+
101+
public Boolean getIssuesEvents() {
102+
return issuesEvents;
103+
}
104+
105+
public void setIssuesEvents(Boolean issuesEvents) {
106+
this.issuesEvents = issuesEvents;
107+
}
108+
109+
public Boolean getConfidentialIssuesEvents() {
110+
return confidentialIssuesEvents;
111+
}
112+
113+
public void setConfidentialIssuesEvents(Boolean confidentialIssuesEvents) {
114+
this.confidentialIssuesEvents = confidentialIssuesEvents;
115+
}
116+
117+
public Boolean getMergeRequestsEvents() {
118+
return mergeRequestsEvents;
119+
}
120+
121+
public void setMergeRequestsEvents(Boolean mergeRequestsEvents) {
122+
this.mergeRequestsEvents = mergeRequestsEvents;
123+
}
124+
125+
public Boolean getTagPushEvents() {
126+
return tagPushEvents;
127+
}
128+
129+
public void setTagPushEvents(Boolean tagPushEvents) {
130+
this.tagPushEvents = tagPushEvents;
131+
}
132+
133+
public Boolean getNoteEvents() {
134+
return noteEvents;
135+
}
136+
137+
public void setNoteEvents(Boolean noteEvents) {
138+
this.noteEvents = noteEvents;
139+
}
140+
141+
public Boolean getConfidentialNoteEvents() {
142+
return confidentialNoteEvents;
143+
}
144+
145+
public void setConfidentialNoteEvents(Boolean confidentialNoteEvents) {
146+
this.confidentialNoteEvents = confidentialNoteEvents;
147+
}
148+
149+
public Boolean getJobEvents() {
150+
return jobEvents;
151+
}
152+
153+
public void setJobEvents(Boolean jobEvents) {
154+
this.jobEvents = jobEvents;
155+
}
156+
157+
public Boolean getPipelineEvents() {
158+
return pipelineEvents;
159+
}
160+
161+
public void setPipelineEvents(Boolean pipelineEvents) {
162+
this.pipelineEvents = pipelineEvents;
163+
}
164+
165+
public Boolean getWikiPageEvents() {
166+
return wikiPageEvents;
167+
}
168+
169+
public void setWikiPageEvents(Boolean wikiPageEvents) {
170+
this.wikiPageEvents = wikiPageEvents;
171+
}
172+
173+
public Boolean getDeploymentEvents() {
174+
return deploymentEvents;
175+
}
176+
177+
public void setDeploymentEvents(Boolean deploymentEvents) {
178+
this.deploymentEvents = deploymentEvents;
179+
}
180+
181+
public Boolean getFeatureFlagEvents() {
182+
return featureFlagEvents;
183+
}
184+
185+
public void setFeatureFlagEvents(Boolean featureFlagEvents) {
186+
this.featureFlagEvents = featureFlagEvents;
187+
}
188+
189+
public Boolean getReleasesEvents() {
190+
return releasesEvents;
191+
}
192+
193+
public void setReleasesEvents(Boolean releasesEvents) {
194+
this.releasesEvents = releasesEvents;
195+
}
196+
197+
public Boolean getSubgroupEvents() {
198+
return subgroupEvents;
199+
}
200+
201+
public void setSubgroupEvents(Boolean subgroupEvents) {
202+
this.subgroupEvents = subgroupEvents;
203+
}
204+
205+
public Boolean getMemberEvents() {
206+
return memberEvents;
207+
}
208+
209+
public void setMemberEvents(Boolean memberEvents) {
210+
this.memberEvents = memberEvents;
211+
}
212+
213+
public Boolean getEnableSslVerification() {
214+
return enableSslVerification;
215+
}
216+
217+
public void setEnableSslVerification(Boolean enableSslVerification) {
218+
this.enableSslVerification = enableSslVerification;
219+
}
220+
221+
public Boolean getRepositoryUpdateEvents() {
222+
return repositoryUpdateEvents;
223+
}
224+
225+
public void setRepositoryUpdateEvents(Boolean repositoryUpdateEvents) {
226+
this.repositoryUpdateEvents = repositoryUpdateEvents;
227+
}
228+
229+
public Date getCreatedAt() {
230+
return createdAt;
231+
}
232+
233+
public void setCreatedAt(Date createdAt) {
234+
this.createdAt = createdAt;
235+
}
236+
237+
public Boolean getResourceAccessTokenEvents() {
238+
return resourceAccessTokenEvents;
239+
}
240+
241+
public void setResourceAccessTokenEvents(Boolean resourceAccessTokenEvents) {
242+
this.resourceAccessTokenEvents = resourceAccessTokenEvents;
243+
}
244+
245+
public String getCustomWebhookTemplate() {
246+
return customWebhookTemplate;
247+
}
248+
249+
public void setCustomWebhookTemplate(String customWebhookTemplate) {
250+
this.customWebhookTemplate = customWebhookTemplate;
251+
}
252+
}

0 commit comments

Comments
 (0)