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
ad3ec370
Commit
ad3ec370
authored
Sep 04, 2015
by
Tim Olshansky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #73 from bozaro/system-hooks
Add system hook API support
parents
920840ef
e3d741e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
9 deletions
+91
-9
GitlabAPI.java
src/main/java/org/gitlab/api/GitlabAPI.java
+51
-9
GitlabSystemHook.java
src/main/java/org/gitlab/api/models/GitlabSystemHook.java
+40
-0
No files found.
src/main/java/org/gitlab/api/GitlabAPI.java
View file @
ad3ec370
...
@@ -701,51 +701,51 @@ public class GitlabAPI {
...
@@ -701,51 +701,51 @@ public class GitlabAPI {
GitlabCommitDiff
[]
diffs
=
retrieve
().
to
(
tailUrl
,
GitlabCommitDiff
[].
class
);
GitlabCommitDiff
[]
diffs
=
retrieve
().
to
(
tailUrl
,
GitlabCommitDiff
[].
class
);
return
Arrays
.
asList
(
diffs
);
return
Arrays
.
asList
(
diffs
);
}
}
/**
/**
* Get raw file content
* Get raw file content
*
*
* @param project Project
* @param project Project
* @param sha The commit or branch name
* @param sha The commit or branch name
* @param filepath The path the file
* @param filepath The path the file
* @throws IOException
* @throws IOException
*/
*/
public
byte
[]
getRawFileContent
(
GitlabProject
project
,
String
sha
,
String
filepath
)
throws
IOException
{
public
byte
[]
getRawFileContent
(
GitlabProject
project
,
String
sha
,
String
filepath
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
project
.
getId
()
+
"/repository/blobs/"
+
sha
+
"?filepath="
+
filepath
;
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
project
.
getId
()
+
"/repository/blobs/"
+
sha
+
"?filepath="
+
filepath
;
return
retrieve
().
to
(
tailUrl
,
byte
[].
class
);
return
retrieve
().
to
(
tailUrl
,
byte
[].
class
);
}
}
/**
/**
* Get the raw file contents for a blob by blob SHA.
* Get the raw file contents for a blob by blob SHA.
*
*
* @param project Project
* @param project Project
* @param sha The commit or branch name
* @param sha The commit or branch name
* @throws IOException
* @throws IOException
*/
*/
public
byte
[]
getRawBlobContent
(
GitlabProject
project
,
String
sha
)
throws
IOException
{
public
byte
[]
getRawBlobContent
(
GitlabProject
project
,
String
sha
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
project
.
getId
()
+
"/repository/raw_blobs/"
+
sha
;
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
project
.
getId
()
+
"/repository/raw_blobs/"
+
sha
;
return
retrieve
().
to
(
tailUrl
,
byte
[].
class
);
return
retrieve
().
to
(
tailUrl
,
byte
[].
class
);
}
}
/**
/**
* Get an archive of the repository
* Get an archive of the repository
*
*
* @param project Project
* @param project Project
* @throws IOException
* @throws IOException
*/
*/
public
byte
[]
getFileArchive
(
GitlabProject
project
)
throws
IOException
{
public
byte
[]
getFileArchive
(
GitlabProject
project
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
project
.
getId
()
+
"/repository/archive"
;
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
project
.
getId
()
+
"/repository/archive"
;
return
retrieve
().
to
(
tailUrl
,
byte
[].
class
);
return
retrieve
().
to
(
tailUrl
,
byte
[].
class
);
}
}
/**
/**
* Get an archive of the repository
* Get an archive of the repository
*
*
* @param project Project
* @param project Project
* @param path The path inside repository. Used to get contend of subdirectories (optional)
* @param path The path inside repository. Used to get contend of subdirectories (optional)
* @param ref_name The name of a repository branch or tag or if not given the default branch (optional)
* @param ref_name The name of a repository branch or tag or if not given the default branch (optional)
* @throws IOException
* @throws IOException
*/
*/
public
List
<
GitlabRepositoryTree
>
getRepositoryTree
(
GitlabProject
project
,
String
path
,
String
ref_name
)
throws
IOException
{
public
List
<
GitlabRepositoryTree
>
getRepositoryTree
(
GitlabProject
project
,
String
path
,
String
ref_name
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
project
.
getId
()
+
"/repository"
+
GitlabRepositoryTree
.
URL
;
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
project
.
getId
()
+
"/repository"
+
GitlabRepositoryTree
.
URL
;
...
@@ -1065,6 +1065,48 @@ public class GitlabAPI {
...
@@ -1065,6 +1065,48 @@ public class GitlabAPI {
return
retrieve
().
to
(
tailUrl
,
GitlabSession
.
class
);
return
retrieve
().
to
(
tailUrl
,
GitlabSession
.
class
);
}
}
/**
* Get list of system hooks
*
* @return The system hooks list
* @throws IOException on gitlab api call error
*/
public
List
<
GitlabSystemHook
>
getSystemHooks
()
throws
IOException
{
String
tailUrl
=
GitlabSystemHook
.
URL
;
return
Arrays
.
asList
(
retrieve
().
to
(
tailUrl
,
GitlabSystemHook
[].
class
));
}
/**
* Add new system hook hook
*
* @param url System hook url
* @throws IOException on gitlab api call error
*/
public
GitlabSystemHook
addSystemHook
(
String
url
)
throws
IOException
{
String
tailUrl
=
GitlabSystemHook
.
URL
;
return
dispatch
().
with
(
"url"
,
url
).
to
(
tailUrl
,
GitlabSystemHook
.
class
);
}
/**
* Test system hook
*
* @throws IOException on gitlab api call error
*/
public
void
testSystemHook
(
Integer
hookId
)
throws
IOException
{
String
tailUrl
=
GitlabSystemHook
.
URL
+
"/"
+
hookId
;
retrieve
().
to
(
tailUrl
,
Void
.
class
);
}
/**
* Delete system hook
*
* @throws IOException on gitlab api call error
*/
public
GitlabSystemHook
deleteSystemHook
(
Integer
hookId
)
throws
IOException
{
String
tailUrl
=
GitlabSystemHook
.
URL
+
"/"
+
hookId
;
return
retrieve
().
method
(
"DELETE"
).
to
(
tailUrl
,
GitlabSystemHook
.
class
);
}
private
String
sanitizeProjectId
(
Serializable
projectId
)
{
private
String
sanitizeProjectId
(
Serializable
projectId
)
{
if
(!(
projectId
instanceof
String
)
&&
!(
projectId
instanceof
Integer
))
{
if
(!(
projectId
instanceof
String
)
&&
!(
projectId
instanceof
Integer
))
{
throw
new
IllegalArgumentException
();
throw
new
IllegalArgumentException
();
...
...
src/main/java/org/gitlab/api/models/GitlabSystemHook.java
0 → 100644
View file @
ad3ec370
package
org
.
gitlab
.
api
.
models
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
java.util.Date
;
public
class
GitlabSystemHook
{
public
final
static
String
URL
=
"/hooks"
;
private
Integer
id
;
private
String
url
;
@JsonProperty
(
"created_at"
)
private
Date
createdAt
;
public
Integer
getId
()
{
return
id
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
public
String
getUrl
()
{
return
url
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
public
Date
getCreatedAt
()
{
return
createdAt
;
}
public
void
setCreatedAt
(
Date
createdAt
)
{
this
.
createdAt
=
createdAt
;
}
}
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