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
b760f147
Commit
b760f147
authored
May 12, 2019
by
Greg Messner
Browse files
Brought into spec with GitLab API docs (#352).
parent
e9c998ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/ProjectApi.java
View file @
b760f147
...
...
@@ -1706,42 +1706,6 @@ public class ProjectApi extends AbstractApi implements Constants {
}
}
/**
* Adds a hook to project.
*
* <pre><code>POST /projects/:id/hooks</code></pre>
*
* @param projectName the name of the project
* @param url the callback URL for the hook
* @param enabledHooks a ProjectHook instance specifying which hooks to enable
* @param enableSslVerification enable SSL verification
* @param secretToken the secret token to pass back to the hook
* @return the added ProjectHook instance
* @throws GitLabApiException if any exception occurs
*/
public
ProjectHook
addHook
(
String
projectName
,
String
url
,
ProjectHook
enabledHooks
,
boolean
enableSslVerification
,
String
secretToken
)
throws
GitLabApiException
{
if
(
projectName
==
null
)
{
return
(
null
);
}
GitLabApiForm
formData
=
new
GitLabApiForm
()
.
withParam
(
"url"
,
url
,
true
)
.
withParam
(
"push_events"
,
enabledHooks
.
getPushEvents
(),
false
)
.
withParam
(
"issues_events"
,
enabledHooks
.
getIssuesEvents
(),
false
)
.
withParam
(
"merge_requests_events"
,
enabledHooks
.
getMergeRequestsEvents
(),
false
)
.
withParam
(
"tag_push_events"
,
enabledHooks
.
getTagPushEvents
(),
false
)
.
withParam
(
"note_events"
,
enabledHooks
.
getNoteEvents
(),
false
)
.
withParam
(
"job_events"
,
enabledHooks
.
getJobEvents
(),
false
)
.
withParam
(
"pipeline_events"
,
enabledHooks
.
getPipelineEvents
(),
false
)
.
withParam
(
"wiki_events"
,
enabledHooks
.
getWikiPageEvents
(),
false
)
.
withParam
(
"enable_ssl_verification"
,
enabledHooks
.
getEnableSslVerification
())
.
withParam
(
"token"
,
secretToken
,
false
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
,
projectName
,
"hooks"
);
return
(
response
.
readEntity
(
ProjectHook
.
class
));
}
/**
* Adds a hook to project.
*
...
...
@@ -1755,20 +1719,24 @@ public class ProjectApi extends AbstractApi implements Constants {
* @return the added ProjectHook instance
* @throws GitLabApiException if any exception occurs
*/
public
ProjectHook
addHook
(
Object
projectIdOrPath
,
String
url
,
ProjectHook
enabledHooks
,
boolean
enableSslVerification
,
String
secretToken
)
throws
GitLabApiException
{
public
ProjectHook
addHook
(
Object
projectIdOrPath
,
String
url
,
ProjectHook
enabledHooks
,
boolean
enableSslVerification
,
String
secretToken
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
new
GitLabApiForm
()
.
withParam
(
"url"
,
url
,
true
)
.
withParam
(
"push_events"
,
enabledHooks
.
getPushEvents
(),
false
)
.
withParam
(
"push_events_branch_filter"
,
enabledHooks
.
getPushEventsBranchFilter
(),
false
)
.
withParam
(
"issues_events"
,
enabledHooks
.
getIssuesEvents
(),
false
)
.
withParam
(
"confidential_issues_events"
,
enabledHooks
.
getConfidentialIssuesEvents
(),
false
)
.
withParam
(
"merge_requests_events"
,
enabledHooks
.
getMergeRequestsEvents
(),
false
)
.
withParam
(
"tag_push_events"
,
enabledHooks
.
getTagPushEvents
(),
false
)
.
withParam
(
"note_events"
,
enabledHooks
.
getNoteEvents
(),
false
)
.
withParam
(
"confidential_note_events"
,
enabledHooks
.
getConfidentialNoteEvents
(),
false
)
.
withParam
(
"job_events"
,
enabledHooks
.
getJobEvents
(),
false
)
.
withParam
(
"pipeline_events"
,
enabledHooks
.
getPipelineEvents
(),
false
)
.
withParam
(
"wiki_events"
,
enabledHooks
.
getWikiPageEvents
(),
false
)
.
withParam
(
"enable_ssl_verification"
,
enabledHooks
.
getEnableSslVerification
())
.
withParam
(
"enable_ssl_verification"
,
enabledHooks
.
getEnableSslVerification
(),
false
)
.
withParam
(
"repository_update_events"
,
enabledHooks
.
getRepositoryUpdateEvents
(),
false
)
.
withParam
(
"token"
,
secretToken
,
false
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"hooks"
);
return
(
response
.
readEntity
(
ProjectHook
.
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