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
67ea0102
Commit
67ea0102
authored
Mar 12, 2014
by
Greg Messner
Browse files
Completed implementation of branch calls.
parent
5840f333
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/messners/gitlab/api/RepositoryApi.java
View file @
67ea0102
package
com.messners.gitlab.api
;
package
com.messners.gitlab.api
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.List
;
import
com.messners.gitlab.api.models.Branch
;
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.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
class
RepositoryApi
extends
AbstractApi
{
public
RepositoryApi
(
GitLabApi
gitLabApi
)
{
public
RepositoryApi
(
GitLabApi
gitLabApi
)
{
super
(
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
* GET /projects/:id/repository/branches/:branch
*
*
* @param gitLabApi TODO
* @param projectId
* @param projectId
* @param branchName
* @param branchName
* @return
* @return
* @throws IOException
* @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
);
ClientResponse
response
=
get
(
null
,
"projects"
,
projectId
,
"repository"
,
"branches"
,
branchName
);
return
(
response
.
getEntity
(
Branch
.
class
));
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
));
}
}
}
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