Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
67ea0102
Commit
67ea0102
authored
11 years ago
by
Greg Messner
Browse files
Options
Download
Email Patches
Plain Diff
Completed implementation of branch calls.
parent
5840f333
main
5.0.x
5.0.x.jdk17
6.x
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/com/messners/gitlab/api/RepositoryApi.java
+93
-2
src/main/java/com/messners/gitlab/api/RepositoryApi.java
with
93 additions
and
2 deletions
+93
-2
src/main/java/com/messners/gitlab/api/RepositoryApi.java
+
93
-
2
View file @
67ea0102
package
com.messners.gitlab.api
;
import
java.io.IOException
;
import
java.util.List
;
import
com.messners.gitlab.api.models.Branch
;
import
com.messners.gitlab.api.models.Tag
;
import
com.messners.gitlab.api.models.TreeItem
;
import
com.sun.jersey.api.client.ClientResponse
;
import
com.sun.jersey.api.client.GenericType
;
/**
* This class provides an entry point to all the GitLab API repository calls.
*
* @author Greg Messner <greg@messners.com>
*/
public
class
RepositoryApi
extends
AbstractApi
{
public
RepositoryApi
(
GitLabApi
gitLabApi
)
{
super
(
gitLabApi
);
}
/**
* GET /projects/:id/repository/branches
*
* @param projectId
* @return
* @throws IOException
*/
public
List
<
Branch
>
getBranches
(
Integer
projectId
)
throws
IOException
{
ClientResponse
response
=
get
(
null
,
"projects"
,
projectId
,
"repository"
,
"branches"
);
return
(
response
.
getEntity
(
new
GenericType
<
List
<
Branch
>>()
{}));
}
/**
* GET /projects/:id/repository/branches/:branch
*
* @param gitLabApi TODO
* @param projectId
* @param branchName
* @return
* @throws IOException
*/
public
Branch
getBranch
(
GitLabApi
gitLabApi
,
Integer
projectId
,
String
branchName
)
throws
IOException
{
public
Branch
getBranch
(
Integer
projectId
,
String
branchName
)
throws
IOException
{
ClientResponse
response
=
get
(
null
,
"projects"
,
projectId
,
"repository"
,
"branches"
,
branchName
);
return
(
response
.
getEntity
(
Branch
.
class
));
}
/**
* PUT /projects/:id/repository/branches/:branch/protect
*
* @param projectId
* @param branchName
* @return
* @throws IOException
*/
public
Branch
protectBranch
(
Integer
projectId
,
String
branchName
)
throws
IOException
{
ClientResponse
response
=
put
(
null
,
"projects"
,
projectId
,
"repository"
,
"branches"
,
branchName
,
"protect"
);
return
(
response
.
getEntity
(
Branch
.
class
));
}
/**
* PUT /projects/:id/repository/branches/:branch/unprotect
*
* @param projectId
* @param branchName
* @return
* @throws IOException
*/
public
Branch
unprotectBranch
(
Integer
projectId
,
String
branchName
)
throws
IOException
{
ClientResponse
response
=
put
(
null
,
"projects"
,
projectId
,
"repository"
,
"branches"
,
branchName
,
"unprotect"
);
return
(
response
.
getEntity
(
Branch
.
class
));
}
/**
* GET /projects/:id/repository/tags
*
* @param projectId
* @return
* @throws IOException
*/
public
List
<
Tag
>
getTags
(
Integer
projectId
)
throws
IOException
{
ClientResponse
response
=
put
(
null
,
"projects"
,
projectId
,
"repository"
,
"tags"
);
return
(
response
.
getEntity
(
new
GenericType
<
List
<
Tag
>>()
{}));
}
/**
* GET /projects/:id/repository/tree
*
* @param projectId
* @return
* @throws IOException
*/
public
List
<
TreeItem
>
getTree
(
Integer
projectId
)
throws
IOException
{
ClientResponse
response
=
put
(
null
,
"projects"
,
projectId
,
"repository"
,
"tree"
);
return
(
response
.
getEntity
(
new
GenericType
<
List
<
TreeItem
>>()
{}));
}
/**
* GET /projects/:id/repository/blobs/:sha
*
* @param projectId
* @param commitOrBranchName
* @return
* @throws IOException
*/
public
String
getRawFileContent
(
Integer
projectId
,
String
commitOrBranchName
)
throws
IOException
{
ClientResponse
response
=
get
(
null
,
"projects"
,
projectId
,
"repository"
,
"blobs"
,
commitOrBranchName
);
return
(
response
.
getEntity
(
String
.
class
));
}
}
This diff is collapsed.
Click to expand it.
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
Menu
Explore
Projects
Groups
Snippets