Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
java-gitlab-api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
沈俊林
java-gitlab-api
Commits
10319475
Commit
10319475
authored
Jan 30, 2014
by
Christopher Luu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added project hook methods.
Fetches, adds, and deletes project hooks.
parent
c26ab735
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
116 additions
and
0 deletions
+116
-0
GitlabAPI.java
src/main/java/org/gitlab/api/GitlabAPI.java
+33
-0
GitlabProjectHook.java
src/main/java/org/gitlab/api/models/GitlabProjectHook.java
+83
-0
No files found.
src/main/java/org/gitlab/api/GitlabAPI.java
View file @
10319475
...
@@ -9,6 +9,7 @@ import org.gitlab.api.models.GitlabBranch;
...
@@ -9,6 +9,7 @@ import org.gitlab.api.models.GitlabBranch;
import
org.gitlab.api.models.GitlabMergeRequest
;
import
org.gitlab.api.models.GitlabMergeRequest
;
import
org.gitlab.api.models.GitlabNote
;
import
org.gitlab.api.models.GitlabNote
;
import
org.gitlab.api.models.GitlabProject
;
import
org.gitlab.api.models.GitlabProject
;
import
org.gitlab.api.models.GitlabProjectHook
;
import
org.gitlab.api.models.GitlabUser
;
import
org.gitlab.api.models.GitlabUser
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -52,6 +53,10 @@ public class GitlabAPI {
...
@@ -52,6 +53,10 @@ public class GitlabAPI {
return
new
GitlabHTTPRequestor
(
this
).
method
(
"POST"
);
return
new
GitlabHTTPRequestor
(
this
).
method
(
"POST"
);
}
}
public
GitlabHTTPRequestor
delete
()
{
return
new
GitlabHTTPRequestor
(
this
).
method
(
"DELETE"
);
}
public
boolean
isIgnoreCertificateErrors
()
{
public
boolean
isIgnoreCertificateErrors
()
{
return
_ignoreCertificateErrors
;
return
_ignoreCertificateErrors
;
}
}
...
@@ -115,7 +120,35 @@ public class GitlabAPI {
...
@@ -115,7 +120,35 @@ public class GitlabAPI {
}
}
return
results
;
return
results
;
}
// Get list of project hooks for a project
// GET /projects/:id/hooks
public
List
<
GitlabProjectHook
>
getProjectHooks
(
Integer
projectId
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
projectId
+
GitlabProjectHook
.
URL
;
GitlabProjectHook
[]
hooks
=
retrieve
().
to
(
tailUrl
,
GitlabProjectHook
[].
class
);
return
Arrays
.
asList
(
hooks
);
}
// Create a new project hook
// POST /projects/:id/hooks
public
GitlabProjectHook
createProjectHook
(
Integer
projectId
,
String
url
,
boolean
pushEvents
,
boolean
issuesEvents
,
boolean
mergeRequestEvents
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
projectId
+
GitlabProjectHook
.
URL
;
return
dispatch
()
.
with
(
"url"
,
url
)
.
with
(
"push_events"
,
pushEvents
?
"true"
:
"false"
)
.
with
(
"issues_events"
,
issuesEvents
?
"true"
:
"false"
)
.
with
(
"merge_requests_events"
,
mergeRequestEvents
?
"true"
:
"false"
)
.
to
(
tailUrl
,
GitlabProjectHook
.
class
);
}
// Removes a hook from project
// DELETE /projects/:id/hooks/:hook_id
public
void
deleteProjectHook
(
GitlabProjectHook
hook
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
hook
.
getProjectId
()
+
GitlabProjectHook
.
URL
+
"/"
+
hook
.
getId
();
delete
().
to
(
tailUrl
,
GitlabProjectHook
.
class
);
}
}
/*
/*
...
...
src/main/java/org/gitlab/api/models/GitlabProjectHook.java
0 → 100644
View file @
10319475
package
org
.
gitlab
.
api
.
models
;
import
java.util.Date
;
import
org.codehaus.jackson.annotate.JsonProperty
;
public
class
GitlabProjectHook
{
public
static
final
String
URL
=
"/hooks"
;
private
Integer
_id
;
private
String
_url
;
@JsonProperty
(
"project_id"
)
private
Integer
_projectId
;
@JsonProperty
(
"push_events"
)
private
boolean
_pushEvents
;
@JsonProperty
(
"issues_events"
)
private
boolean
_issueEvents
;
@JsonProperty
(
"merge_requests_events"
)
private
boolean
_mergeRequestsEvents
;
@JsonProperty
(
"created_at"
)
private
Date
_createdAt
;
public
Integer
getId
()
{
return
_id
;
}
public
void
setId
(
Integer
id
)
{
_id
=
id
;
}
public
String
getUrl
()
{
return
_url
;
}
public
void
setUrl
(
String
url
)
{
_url
=
url
;
}
public
Integer
getProjectId
()
{
return
_projectId
;
}
public
void
setProjectId
(
Integer
projectId
)
{
_projectId
=
projectId
;
}
public
boolean
getPushEvents
()
{
return
_pushEvents
;
}
public
void
setPushEvents
(
boolean
pushEvents
)
{
_pushEvents
=
pushEvents
;
}
public
Date
getCreatedAt
()
{
return
_createdAt
;
}
public
void
setCreatedAt
(
Date
createdAt
)
{
_createdAt
=
createdAt
;
}
public
boolean
getIssueEvents
()
{
return
_issueEvents
;
}
public
void
setIssueEvents
(
boolean
issueEvents
)
{
_issueEvents
=
issueEvents
;
}
public
boolean
isMergeRequestsEvents
()
{
return
_mergeRequestsEvents
;
}
public
void
setMergeRequestsEvents
(
boolean
mergeRequestsEvents
)
{
_mergeRequestsEvents
=
mergeRequestsEvents
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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