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
6675a0af
Commit
6675a0af
authored
Dec 11, 2018
by
Greg Messner
Browse files
Added getOptionalBranch() (#281).
parent
a1c36764
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/RepositoryApi.java
View file @
6675a0af
...
@@ -8,6 +8,7 @@ import java.net.URLEncoder;
...
@@ -8,6 +8,7 @@ import java.net.URLEncoder;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
import
java.nio.file.StandardCopyOption
;
import
java.nio.file.StandardCopyOption
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Optional
;
import
javax.ws.rs.core.Form
;
import
javax.ws.rs.core.Form
;
import
javax.ws.rs.core.GenericType
;
import
javax.ws.rs.core.GenericType
;
...
@@ -36,12 +37,13 @@ public class RepositoryApi extends AbstractApi {
...
@@ -36,12 +37,13 @@ public class RepositoryApi extends AbstractApi {
*
*
* GET /projects/:id/repository/branches
* GET /projects/:id/repository/branches
*
*
* @param projectId the project
to get the list of branches for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @return the list of repository branches for the specified project
ID
* @return the list of repository branches for the specified project
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
Branch
>
getBranches
(
Integer
projectId
)
throws
GitLabApiException
{
public
List
<
Branch
>
getBranches
(
Object
projectIdOrPath
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
getDefaultPerPageParam
(),
"projects"
,
projectId
,
"repository"
,
"branches"
);
Response
response
=
get
(
Response
.
Status
.
OK
,
getDefaultPerPageParam
(),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"branches"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Branch
>>()
{}));
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Branch
>>()
{}));
}
}
...
@@ -50,14 +52,15 @@ public class RepositoryApi extends AbstractApi {
...
@@ -50,14 +52,15 @@ public class RepositoryApi extends AbstractApi {
*
*
* GET /projects/:id/repository/branches
* GET /projects/:id/repository/branches
*
*
* @param projectId the project to get the list of branches for
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @return the list of repository branches for the specified project ID
* @param page the page to get
* @param page the page to get
* @param perPage the number of Branch instances per page
* @param perPage the number of Branch instances per page
* @return the list of repository branches for the specified project
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
Branch
>
getBranches
(
Integer
projectId
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
public
List
<
Branch
>
getBranches
(
Object
projectIdOrPath
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
getPageQueryParams
(
page
,
perPage
),
"projects"
,
projectId
,
"repository"
,
"branches"
);
Response
response
=
get
(
Response
.
Status
.
OK
,
getPageQueryParams
(
page
,
perPage
),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"branches"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Branch
>>()
{}));
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Branch
>>()
{}));
}
}
...
@@ -66,14 +69,15 @@ public class RepositoryApi extends AbstractApi {
...
@@ -66,14 +69,15 @@ public class RepositoryApi extends AbstractApi {
*
*
* GET /projects/:id/repository/branches
* GET /projects/:id/repository/branches
*
*
* @param projectId the project
to get the list of branches for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param itemsPerPage the number of Project instances that will be fetched per page
* @param itemsPerPage the number of Project instances that will be fetched per page
* @return the list of repository branches for the specified project ID
* @return the list of repository branches for the specified project ID
*
*
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Pager
<
Branch
>
getBranches
(
Integer
projectId
,
int
itemsPerPage
)
throws
GitLabApiException
{
public
Pager
<
Branch
>
getBranches
(
Object
projectIdOrPath
,
int
itemsPerPage
)
throws
GitLabApiException
{
return
(
new
Pager
<
Branch
>(
this
,
Branch
.
class
,
itemsPerPage
,
null
,
"projects"
,
projectId
,
"repository"
,
"branches"
));
return
(
new
Pager
<
Branch
>(
this
,
Branch
.
class
,
itemsPerPage
,
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"branches"
));
}
}
/**
/**
...
@@ -81,33 +85,53 @@ public class RepositoryApi extends AbstractApi {
...
@@ -81,33 +85,53 @@ public class RepositoryApi extends AbstractApi {
*
*
* GET /projects/:id/repository/branches/:branch
* GET /projects/:id/repository/branches/:branch
*
*
* @param projectId the project
to get the branch for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param branchName the name of the branch to get
* @param branchName the name of the branch to get
* @return the branch info for the specified project ID/branch name pair
* @return the branch info for the specified project ID/branch name pair
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Branch
getBranch
(
Integer
projectId
,
String
branchName
)
throws
GitLabApiException
{
public
Branch
getBranch
(
Object
projectIdOrPath
,
String
branchName
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"repository"
,
"branches"
,
urlEncode
(
branchName
));
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"branches"
,
urlEncode
(
branchName
));
return
(
response
.
readEntity
(
Branch
.
class
));
return
(
response
.
readEntity
(
Branch
.
class
));
}
}
/**
* Get an Optional instance with the value for the specific repository branch.
*
* GET /projects/:id/repository/branches/:branch
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param branchName the name of the branch to get
* @return an Optional instance with the info for the specified project ID/branch name pair as the value
* @throws GitLabApiException if any exception occurs
*/
public
Optional
<
Branch
>
getOptionalBranch
(
Object
projectIdOrPath
,
String
branchName
)
throws
GitLabApiException
{
try
{
return
(
Optional
.
ofNullable
(
getBranch
(
projectIdOrPath
,
branchName
)));
}
catch
(
GitLabApiException
glae
)
{
return
(
GitLabApi
.
createOptionalFromException
(
glae
));
}
}
/**
/**
* Creates a branch for the project. Support as of version 6.8.x
* Creates a branch for the project. Support as of version 6.8.x
*
*
* POST /projects/:id/repository/branches
* POST /projects/:id/repository/branches
*
*
* @param projectId the project
to create the branch for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param branchName the name of the branch to create
* @param branchName the name of the branch to create
* @param ref Source to create the branch from, can be an existing branch, tag or commit SHA
* @param ref Source to create the branch from, can be an existing branch, tag or commit SHA
* @return the branch info for the created branch
* @return the branch info for the created branch
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Branch
createBranch
(
Integer
projectId
,
String
branchName
,
String
ref
)
throws
GitLabApiException
{
public
Branch
createBranch
(
Object
projectId
OrPath
,
String
branchName
,
String
ref
)
throws
GitLabApiException
{
Form
formData
=
new
GitLabApiForm
()
Form
formData
=
new
GitLabApiForm
()
.
withParam
(
isApiVersion
(
ApiVersion
.
V3
)
?
"branch_name"
:
"branch"
,
branchName
,
true
)
.
withParam
(
isApiVersion
(
ApiVersion
.
V3
)
?
"branch_name"
:
"branch"
,
branchName
,
true
)
.
withParam
(
"ref"
,
ref
,
true
);
.
withParam
(
"ref"
,
ref
,
true
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
.
asMap
(),
"projects"
,
projectId
,
"repository"
,
"branches"
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
.
asMap
(),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"branches"
);
return
(
response
.
readEntity
(
Branch
.
class
));
return
(
response
.
readEntity
(
Branch
.
class
));
}
}
...
@@ -116,13 +140,14 @@ public class RepositoryApi extends AbstractApi {
...
@@ -116,13 +140,14 @@ public class RepositoryApi extends AbstractApi {
*
*
* DELETE /projects/:id/repository/branches/:branch
* DELETE /projects/:id/repository/branches/:branch
*
*
* @param projectId the project
that the branch belongs to
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param branchName the name of the branch to delete
* @param branchName the name of the branch to delete
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
void
deleteBranch
(
Integer
projectId
,
String
branchName
)
throws
GitLabApiException
{
public
void
deleteBranch
(
Object
projectId
OrPath
,
String
branchName
)
throws
GitLabApiException
{
Response
.
Status
expectedStatus
=
(
isApiVersion
(
ApiVersion
.
V3
)
?
Response
.
Status
.
OK
:
Response
.
Status
.
NO_CONTENT
);
Response
.
Status
expectedStatus
=
(
isApiVersion
(
ApiVersion
.
V3
)
?
Response
.
Status
.
OK
:
Response
.
Status
.
NO_CONTENT
);
delete
(
expectedStatus
,
null
,
"projects"
,
projectId
,
"repository"
,
"branches"
,
urlEncode
(
branchName
));
delete
(
expectedStatus
,
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"branches"
,
urlEncode
(
branchName
));
}
}
/**
/**
...
@@ -131,13 +156,14 @@ public class RepositoryApi extends AbstractApi {
...
@@ -131,13 +156,14 @@ public class RepositoryApi extends AbstractApi {
*
*
* PUT /projects/:id/repository/branches/:branch/protect
* PUT /projects/:id/repository/branches/:branch/protect
*
*
* @param projectId
the ID of
the project
to p
ro
t
ect
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or P
ro
j
ect
instance
* @param branchName the name of the branch to protect
* @param branchName the name of the branch to protect
* @return the branch info for the protected branch
* @return the branch info for the protected branch
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Branch
protectBranch
(
Integer
projectId
,
String
branchName
)
throws
GitLabApiException
{
public
Branch
protectBranch
(
Object
projectIdOrPath
,
String
branchName
)
throws
GitLabApiException
{
Response
response
=
put
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"repository"
,
"branches"
,
urlEncode
(
branchName
),
"protect"
);
Response
response
=
put
(
Response
.
Status
.
OK
,
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"branches"
,
urlEncode
(
branchName
),
"protect"
);
return
(
response
.
readEntity
(
Branch
.
class
));
return
(
response
.
readEntity
(
Branch
.
class
));
}
}
...
@@ -147,13 +173,14 @@ public class RepositoryApi extends AbstractApi {
...
@@ -147,13 +173,14 @@ public class RepositoryApi extends AbstractApi {
*
*
* PUT /projects/:id/repository/branches/:branch/unprotect
* PUT /projects/:id/repository/branches/:branch/unprotect
*
*
* @param projectId
the ID of
the project
to un-p
ro
t
ect
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or P
ro
j
ect
instance
* @param branchName the name of the branch to un-protect
* @param branchName the name of the branch to un-protect
* @return the branch info for the unprotected branch
* @return the branch info for the unprotected branch
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Branch
unprotectBranch
(
Integer
projectId
,
String
branchName
)
throws
GitLabApiException
{
public
Branch
unprotectBranch
(
Object
projectIdOrPath
,
String
branchName
)
throws
GitLabApiException
{
Response
response
=
put
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"repository"
,
"branches"
,
urlEncode
(
branchName
),
"unprotect"
);
Response
response
=
put
(
Response
.
Status
.
OK
,
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"branches"
,
urlEncode
(
branchName
),
"unprotect"
);
return
(
response
.
readEntity
(
Branch
.
class
));
return
(
response
.
readEntity
(
Branch
.
class
));
}
}
...
@@ -162,13 +189,14 @@ public class RepositoryApi extends AbstractApi {
...
@@ -162,13 +189,14 @@ public class RepositoryApi extends AbstractApi {
*
*
* GET /projects/:id/repository/tags
* GET /projects/:id/repository/tags
*
*
* @param projectId
the ID of
the project
to get the tags for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @return the list of tags for the specified project ID
* @return the list of tags for the specified project ID
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
* @deprecated Replaced by TagsApi.getTags(Object)
* @deprecated Replaced by TagsApi.getTags(Object)
*/
*/
public
List
<
Tag
>
getTags
(
Integer
projectId
)
throws
GitLabApiException
{
public
List
<
Tag
>
getTags
(
Object
projectIdOrPath
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
getDefaultPerPageParam
(),
"projects"
,
projectId
,
"repository"
,
"tags"
);
Response
response
=
get
(
Response
.
Status
.
OK
,
getDefaultPerPageParam
(),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"tags"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Tag
>>()
{}));
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Tag
>>()
{}));
}
}
...
@@ -177,15 +205,16 @@ public class RepositoryApi extends AbstractApi {
...
@@ -177,15 +205,16 @@ public class RepositoryApi extends AbstractApi {
*
*
* GET /projects/:id/repository/tags
* GET /projects/:id/repository/tags
*
*
* @param projectId
the ID of
the project
to get the tags for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param page the page to get
* @param page the page to get
* @param perPage the number of Tag instances per page
* @param perPage the number of Tag instances per page
* @return the list of tags for the specified project ID
* @return the list of tags for the specified project ID
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
* @deprecated Replaced by TagsApi.getTags(Object, int, int)
* @deprecated Replaced by TagsApi.getTags(Object, int, int)
*/
*/
public
List
<
Tag
>
getTags
(
Integer
projectId
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
public
List
<
Tag
>
getTags
(
Object
projectIdOrPath
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
getPageQueryParams
(
page
,
perPage
),
"projects"
,
projectId
,
"repository"
,
"tags"
);
Response
response
=
get
(
Response
.
Status
.
OK
,
getPageQueryParams
(
page
,
perPage
),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"tags"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Tag
>>()
{}));
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Tag
>>()
{}));
}
}
...
@@ -194,14 +223,15 @@ public class RepositoryApi extends AbstractApi {
...
@@ -194,14 +223,15 @@ public class RepositoryApi extends AbstractApi {
*
*
* GET /projects/:id/repository/tags
* GET /projects/:id/repository/tags
*
*
* @param projectId
the ID of
the project
to get the tags for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param itemsPerPage the number of Project instances that will be fetched per page
* @param itemsPerPage the number of Project instances that will be fetched per page
* @return the list of tags for the specified project ID
* @return the list of tags for the specified project ID
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
* @deprecated Replaced by TagsApi.getTags(Object, int)
* @deprecated Replaced by TagsApi.getTags(Object, int)
*/
*/
public
Pager
<
Tag
>
getTags
(
Integer
projectId
,
int
itemsPerPage
)
throws
GitLabApiException
{
public
Pager
<
Tag
>
getTags
(
Object
projectIdOrPath
,
int
itemsPerPage
)
throws
GitLabApiException
{
return
(
new
Pager
<
Tag
>(
this
,
Tag
.
class
,
itemsPerPage
,
null
,
"projects"
,
projectId
,
"repository"
,
"tags"
));
return
(
new
Pager
<
Tag
>(
this
,
Tag
.
class
,
itemsPerPage
,
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"tags"
));
}
}
/**
/**
...
@@ -209,7 +239,7 @@ public class RepositoryApi extends AbstractApi {
...
@@ -209,7 +239,7 @@ public class RepositoryApi extends AbstractApi {
*
*
* POST /projects/:id/repository/tags
* POST /projects/:id/repository/tags
*
*
* @param projectId
the ID of the project
* @param projectId
OrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param tagName The name of the tag Must be unique for the project
* @param tagName The name of the tag Must be unique for the project
* @param ref the git ref to place the tag on
* @param ref the git ref to place the tag on
* @param message the message to included with the tag (optional)
* @param message the message to included with the tag (optional)
...
@@ -218,25 +248,26 @@ public class RepositoryApi extends AbstractApi {
...
@@ -218,25 +248,26 @@ public class RepositoryApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
* @deprecated Replaced by TagsApi.createTag(Object, String, String, String, String)
* @deprecated Replaced by TagsApi.createTag(Object, String, String, String, String)
*/
*/
public
Tag
createTag
(
Integer
projectId
,
String
tagName
,
String
ref
,
String
message
,
String
releaseNotes
)
throws
GitLabApiException
{
public
Tag
createTag
(
Object
projectId
OrPath
,
String
tagName
,
String
ref
,
String
message
,
String
releaseNotes
)
throws
GitLabApiException
{
Form
formData
=
new
GitLabApiForm
()
Form
formData
=
new
GitLabApiForm
()
.
withParam
(
"tag_name"
,
tagName
,
true
)
.
withParam
(
"tag_name"
,
tagName
,
true
)
.
withParam
(
"ref"
,
ref
,
true
)
.
withParam
(
"ref"
,
ref
,
true
)
.
withParam
(
"message"
,
message
,
false
)
.
withParam
(
"message"
,
message
,
false
)
.
withParam
(
"release_description"
,
releaseNotes
,
false
);
.
withParam
(
"release_description"
,
releaseNotes
,
false
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
.
asMap
(),
"projects"
,
projectId
,
"repository"
,
"tags"
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
.
asMap
(),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"tags"
);
return
(
response
.
readEntity
(
Tag
.
class
));
return
(
response
.
readEntity
(
Tag
.
class
));
}
}
/**
/**
* Creates a tag on a particular ref of a given project. A message and a File instance containing the
* Creates a tag on a particular ref of a given project. A message and a File instance containing the
* release notes are optional. This method is the same as {@link #createTag(
Integer
, String, String, String, String)},
* release notes are optional. This method is the same as {@link #createTag(
Object
, String, String, String, String)},
* but instead allows the release notes to be supplied in a file.
* but instead allows the release notes to be supplied in a file.
*
*
* POST /projects/:id/repository/tags
* POST /projects/:id/repository/tags
*
*
* @param projectId
the ID of the project
* @param projectId
OrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param tagName the name of the tag, must be unique for the project
* @param tagName the name of the tag, must be unique for the project
* @param ref the git ref to place the tag on
* @param ref the git ref to place the tag on
* @param message the message to included with the tag (optional)
* @param message the message to included with the tag (optional)
...
@@ -245,7 +276,7 @@ public class RepositoryApi extends AbstractApi {
...
@@ -245,7 +276,7 @@ public class RepositoryApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
* @deprecated Replaced by TagsApi.CreateTag(Object, String, String, String, File)
* @deprecated Replaced by TagsApi.CreateTag(Object, String, String, String, File)
*/
*/
public
Tag
createTag
(
Integer
projectId
,
String
tagName
,
String
ref
,
String
message
,
File
releaseNotesFile
)
throws
GitLabApiException
{
public
Tag
createTag
(
Object
projectId
OrPath
,
String
tagName
,
String
ref
,
String
message
,
File
releaseNotesFile
)
throws
GitLabApiException
{
String
releaseNotes
;
String
releaseNotes
;
if
(
releaseNotesFile
!=
null
)
{
if
(
releaseNotesFile
!=
null
)
{
...
@@ -258,7 +289,7 @@ public class RepositoryApi extends AbstractApi {
...
@@ -258,7 +289,7 @@ public class RepositoryApi extends AbstractApi {
releaseNotes
=
null
;
releaseNotes
=
null
;
}
}
return
(
createTag
(
projectId
,
tagName
,
ref
,
message
,
releaseNotes
));
return
(
createTag
(
projectId
OrPath
,
tagName
,
ref
,
message
,
releaseNotes
));
}
}
/**
/**
...
@@ -266,14 +297,14 @@ public class RepositoryApi extends AbstractApi {
...
@@ -266,14 +297,14 @@ public class RepositoryApi extends AbstractApi {
*
*
* DELETE /projects/:id/repository/tags/:tag_name
* DELETE /projects/:id/repository/tags/:tag_name
*
*
* @param projectId
the ID of the project
* @param projectId
OrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param tagName The name of the tag to delete
* @param tagName The name of the tag to delete
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
* @deprecated Replaced by TagsApi.deleteTag(Object, String)
* @deprecated Replaced by TagsApi.deleteTag(Object, String)
*/
*/
public
void
deleteTag
(
Integer
projectId
,
String
tagName
)
throws
GitLabApiException
{
public
void
deleteTag
(
Object
projectId
OrPath
,
String
tagName
)
throws
GitLabApiException
{
Response
.
Status
expectedStatus
=
(
isApiVersion
(
ApiVersion
.
V3
)
?
Response
.
Status
.
OK
:
Response
.
Status
.
NO_CONTENT
);
Response
.
Status
expectedStatus
=
(
isApiVersion
(
ApiVersion
.
V3
)
?
Response
.
Status
.
OK
:
Response
.
Status
.
NO_CONTENT
);
delete
(
expectedStatus
,
null
,
"projects"
,
projectId
,
"repository"
,
"tags"
,
tagName
);
delete
(
expectedStatus
,
null
,
"projects"
,
getProjectIdOrPath
(
projectId
OrPath
)
,
"repository"
,
"tags"
,
tagName
);
}
}
/**
/**
...
@@ -281,12 +312,12 @@ public class RepositoryApi extends AbstractApi {
...
@@ -281,12 +312,12 @@ public class RepositoryApi extends AbstractApi {
*
*
* GET /projects/:id/repository/tree
* GET /projects/:id/repository/tree
*
*
* @param projectId
the ID of
the project
to get the files for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @return a tree with the root directories and files of a project
* @return a tree with the root directories and files of a project
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
TreeItem
>
getTree
(
Integer
projectId
)
throws
GitLabApiException
{
public
List
<
TreeItem
>
getTree
(
Object
projectId
OrPath
)
throws
GitLabApiException
{
return
(
getTree
(
projectId
,
"/"
,
"master"
));
return
(
getTree
(
projectId
OrPath
,
"/"
,
"master"
));
}
}
/**
/**
...
@@ -294,13 +325,13 @@ public class RepositoryApi extends AbstractApi {
...
@@ -294,13 +325,13 @@ public class RepositoryApi extends AbstractApi {
*
*
* GET /projects/:id/repository/tree
* GET /projects/:id/repository/tree
*
*
* @param projectId
the ID of
the project
to get the files for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param itemsPerPage the number of Project instances that will be fetched per page
* @param itemsPerPage the number of Project instances that will be fetched per page
* @return a Pager containing a tree with the root directories and files of a project
* @return a Pager containing a tree with the root directories and files of a project
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Pager
<
TreeItem
>
getTree
(
Integer
projectId
,
int
itemsPerPage
)
throws
GitLabApiException
{
public
Pager
<
TreeItem
>
getTree
(
Object
projectId
OrPath
,
int
itemsPerPage
)
throws
GitLabApiException
{
return
(
getTree
(
projectId
,
"/"
,
"master"
,
false
,
itemsPerPage
));
return
(
getTree
(
projectId
OrPath
,
"/"
,
"master"
,
false
,
itemsPerPage
));
}
}
/**
/**
...
@@ -312,14 +343,14 @@ public class RepositoryApi extends AbstractApi {
...
@@ -312,14 +343,14 @@ public class RepositoryApi extends AbstractApi {
* path (optional) - The path inside repository. Used to get content of subdirectories
* path (optional) - The path inside repository. Used to get content of subdirectories
* ref_name (optional) - The name of a repository branch or tag or if not given the default branch
* ref_name (optional) - The name of a repository branch or tag or if not given the default branch
*
*
* @param projectId
the ID of
the project
to get the files for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param filePath the path inside repository, used to get content of subdirectories
* @param filePath the path inside repository, used to get content of subdirectories
* @param refName the name of a repository branch or tag or if not given the default branch
* @param refName the name of a repository branch or tag or if not given the default branch
* @return a tree with the directories and files of a project
* @return a tree with the directories and files of a project
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
TreeItem
>
getTree
(
Integer
projectId
,
String
filePath
,
String
refName
)
throws
GitLabApiException
{
public
List
<
TreeItem
>
getTree
(
Object
projectId
OrPath
,
String
filePath
,
String
refName
)
throws
GitLabApiException
{
return
(
getTree
(
projectId
,
filePath
,
refName
,
false
));
return
(
getTree
(
projectId
OrPath
,
filePath
,
refName
,
false
));
}
}
/**
/**
...
@@ -331,15 +362,15 @@ public class RepositoryApi extends AbstractApi {
...
@@ -331,15 +362,15 @@ public class RepositoryApi extends AbstractApi {
* path (optional) - The path inside repository. Used to get content of subdirectories
* path (optional) - The path inside repository. Used to get content of subdirectories
* ref_name (optional) - The name of a repository branch or tag or if not given the default branch
* ref_name (optional) - The name of a repository branch or tag or if not given the default branch
*
*
* @param projectId
the ID of
the project
to get the files for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param filePath the path inside repository, used to get content of subdirectories
* @param filePath the path inside repository, used to get content of subdirectories
* @param refName the name of a repository branch or tag or if not given the default branch
* @param refName the name of a repository branch or tag or if not given the default branch
* @param itemsPerPage the number of Project instances that will be fetched per page
* @param itemsPerPage the number of Project instances that will be fetched per page
* @return a Pager containing a tree with the directories and files of a project
* @return a Pager containing a tree with the directories and files of a project
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Pager
<
TreeItem
>
getTree
(
Integer
projectId
,
String
filePath
,
String
refName
,
int
itemsPerPage
)
throws
GitLabApiException
{
public
Pager
<
TreeItem
>
getTree
(
Object
projectId
OrPath
,
String
filePath
,
String
refName
,
int
itemsPerPage
)
throws
GitLabApiException
{
return
(
getTree
(
projectId
,
filePath
,
refName
,
false
,
itemsPerPage
));
return
(
getTree
(
projectId
OrPath
,
filePath
,
refName
,
false
,
itemsPerPage
));
}
}
/**
/**
...
@@ -352,21 +383,21 @@ public class RepositoryApi extends AbstractApi {
...
@@ -352,21 +383,21 @@ public class RepositoryApi extends AbstractApi {
* ref_name (optional) - The name of a repository branch or tag or if not given the default branch
* ref_name (optional) - The name of a repository branch or tag or if not given the default branch
* recursive (optional) - Boolean value used to get a recursive tree (false by default)
* recursive (optional) - Boolean value used to get a recursive tree (false by default)
*
*
* @param projectId
the ID of
the project
to get the files for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param filePath the path inside repository, used to get content of subdirectories
* @param filePath the path inside repository, used to get content of subdirectories
* @param refName the name of a repository branch or tag or if not given the default branch
* @param refName the name of a repository branch or tag or if not given the default branch
* @param recursive flag to get a recursive tree or not
* @param recursive flag to get a recursive tree or not
* @return a tree with the directories and files of a project
* @return a tree with the directories and files of a project
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
TreeItem
>
getTree
(
Integer
projectId
,
String
filePath
,
String
refName
,
Boolean
recursive
)
throws
GitLabApiException
{
public
List
<
TreeItem
>
getTree
(
Object
projectId
OrPath
,
String
filePath
,
String
refName
,
Boolean
recursive
)
throws
GitLabApiException
{
Form
formData
=
new
GitLabApiForm
()
Form
formData
=
new
GitLabApiForm
()
.
withParam
(
"id"
,
projectId
,
true
)
.
withParam
(
"id"
,
getProjectIdOrPath
(
projectId
OrPath
)
,
true
)
.
withParam
(
"path"
,
filePath
,
false
)
.
withParam
(
"path"
,
filePath
,
false
)
.
withParam
(
isApiVersion
(
ApiVersion
.
V3
)
?
"ref_name"
:
"ref"
,
refName
,
false
)
.
withParam
(
isApiVersion
(
ApiVersion
.
V3
)
?
"ref_name"
:
"ref"
,
refName
,
false
)
.
withParam
(
"recursive"
,
recursive
,
false
)
.
withParam
(
"recursive"
,
recursive
,
false
)
.
withParam
(
PER_PAGE_PARAM
,
getDefaultPerPage
());
.
withParam
(
PER_PAGE_PARAM
,
getDefaultPerPage
());
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"projects"
,
projectId
,
"repository"
,
"tree"
);
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"projects"
,
getProjectIdOrPath
(
projectId
OrPath
)
,
"repository"
,
"tree"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
TreeItem
>>()
{}));
return
(
response
.
readEntity
(
new
GenericType
<
List
<
TreeItem
>>()
{}));
}
}
...
@@ -380,7 +411,7 @@ public class RepositoryApi extends AbstractApi {
...
@@ -380,7 +411,7 @@ public class RepositoryApi extends AbstractApi {
* ref_name (optional) - The name of a repository branch or tag or if not given the default branch
* ref_name (optional) - The name of a repository branch or tag or if not given the default branch
* recursive (optional) - Boolean value used to get a recursive tree (false by default)
* recursive (optional) - Boolean value used to get a recursive tree (false by default)
*
*
* @param projectId
the ID of
the project
to get the files for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param filePath the path inside repository, used to get content of subdirectories
* @param filePath the path inside repository, used to get content of subdirectories
* @param refName the name of a repository branch or tag or if not given the default branch
* @param refName the name of a repository branch or tag or if not given the default branch
* @param recursive flag to get a recursive tree or not
* @param recursive flag to get a recursive tree or not
...
@@ -388,13 +419,14 @@ public class RepositoryApi extends AbstractApi {
...
@@ -388,13 +419,14 @@ public class RepositoryApi extends AbstractApi {
* @return a tree with the directories and files of a project
* @return a tree with the directories and files of a project
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Pager
<
TreeItem
>
getTree
(
Integer
projectId
,
String
filePath
,
String
refName
,
Boolean
recursive
,
int
itemsPerPage
)
throws
GitLabApiException
{
public
Pager
<
TreeItem
>
getTree
(
Object
projectId
OrPath
,
String
filePath
,
String
refName
,
Boolean
recursive
,
int
itemsPerPage
)
throws
GitLabApiException
{
Form
formData
=
new
GitLabApiForm
()
Form
formData
=
new
GitLabApiForm
()
.
withParam
(
"id"
,
projectId
,
true
)
.
withParam
(
"id"
,
getProjectIdOrPath
(
projectId
OrPath
)
,
true
)
.
withParam
(
"path"
,
filePath
,
false
)
.
withParam
(
"path"
,
filePath
,
false
)
.
withParam
(
isApiVersion
(
ApiVersion
.
V3
)
?
"ref_name"
:
"ref"
,
refName
,
false
)
.
withParam
(
isApiVersion
(
ApiVersion
.
V3
)
?
"ref_name"
:
"ref"
,
refName
,
false
)
.
withParam
(
"recursive"
,
recursive
,
false
);
.
withParam
(
"recursive"
,
recursive
,
false
);
return
(
new
Pager
<
TreeItem
>(
this
,
TreeItem
.
class
,
itemsPerPage
,
formData
.
asMap
(),
"projects"
,
projectId
,
"repository"
,
"tree"
));
return
(
new
Pager
<
TreeItem
>(
this
,
TreeItem
.
class
,
itemsPerPage
,
formData
.
asMap
(),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"tree"
));
}
}
/**
/**
...
@@ -402,14 +434,14 @@ public class RepositoryApi extends AbstractApi {
...
@@ -402,14 +434,14 @@ public class RepositoryApi extends AbstractApi {
*
*
* GET /projects/:id/repository/raw_blobs/:sha
* GET /projects/:id/repository/raw_blobs/:sha
*
*
* @param projectId
the ID of the project
* @param projectId
OrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param sha the SHA of the file to get the contents for
* @param sha the SHA of the file to get the contents for
* @return the raw file contents for the blob on an InputStream
* @return the raw file contents for the blob on an InputStream
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
InputStream
getRawBlobContent
(
Integer
projectId
,
String
sha
)
throws
GitLabApiException
{
public
InputStream
getRawBlobContent
(
Object
projectId
OrPath
,
String
sha
)
throws
GitLabApiException
{
Response
response
=
getWithAccepts
(
Response
.
Status
.
OK
,
null
,
MediaType
.
MEDIA_TYPE_WILDCARD
,
Response
response
=
getWithAccepts
(
Response
.
Status
.
OK
,
null
,
MediaType
.
MEDIA_TYPE_WILDCARD
,
"projects"
,
projectId
,
"repository"
,
"blobs"
,
sha
,
"raw"
);
"projects"
,
getProjectIdOrPath
(
projectId
OrPath
)
,
"repository"
,
"blobs"
,
sha
,
"raw"
);
return
(
response
.
readEntity
(
InputStream
.
class
));
return
(
response
.
readEntity
(
InputStream
.
class
));
}
}
...
@@ -418,16 +450,16 @@ public class RepositoryApi extends AbstractApi {
...
@@ -418,16 +450,16 @@ public class RepositoryApi extends AbstractApi {
*
*
* GET /projects/:id/repository/archive
* GET /projects/:id/repository/archive
*
*
* @param projectId
the ID of the project
* @param projectId
OrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param sha the SHA of the archive to get
* @param sha the SHA of the archive to get
* @return an input stream that can be used to save as a file
* @return an input stream that can be used to save as a file
* or to read the content of the archive
* or to read the content of the archive
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
InputStream
getRepositoryArchive
(
Integer
projectId
,
String
sha
)
throws
GitLabApiException
{
public
InputStream
getRepositoryArchive
(
Object
projectId
OrPath
,
String
sha
)
throws
GitLabApiException
{
Form
formData
=
new
GitLabApiForm
().
withParam
(
"sha"
,
sha
);
Form
formData
=
new
GitLabApiForm
().
withParam
(
"sha"
,
sha
);
Response
response
=
getWithAccepts
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
MediaType
.
MEDIA_TYPE_WILDCARD
,
Response
response
=
getWithAccepts
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
MediaType
.
MEDIA_TYPE_WILDCARD
,
"projects"
,
projectId
,
"repository"
,
"archive"
);
"projects"
,
getProjectIdOrPath
(
projectId
OrPath
)
,
"repository"
,
"archive"
);
return
(
response
.
readEntity
(
InputStream
.
class
));
return
(
response
.
readEntity
(
InputStream
.
class
));
}
}
...
@@ -436,15 +468,15 @@ public class RepositoryApi extends AbstractApi {
...
@@ -436,15 +468,15 @@ public class RepositoryApi extends AbstractApi {
*
*
* GET /projects/:id/repository/archive
* GET /projects/:id/repository/archive
*
*
* @param projectId
the ID of the project
* @param projectId
OrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param sha the SHA of the archive to get
* @param sha the SHA of the archive to get
* @param format The archive format, defaults to "tar.gz" if null
* @param format The archive format, defaults to "tar.gz" if null
* @return an input stream that can be used to save as a file or to read the content of the archive
* @return an input stream that can be used to save as a file or to read the content of the archive
* @throws GitLabApiException if format is not a valid archive format or any exception occurs
* @throws GitLabApiException if format is not a valid archive format or any exception occurs
*/
*/
public
InputStream
getRepositoryArchive
(
Integer
projectId
,
String
sha
,
String
format
)
throws
GitLabApiException
{
public
InputStream
getRepositoryArchive
(
Object
projectId
OrPath
,
String
sha
,
String
format
)
throws
GitLabApiException
{
ArchiveFormat
archiveFormat
=
ArchiveFormat
.
forValue
(
format
);
ArchiveFormat
archiveFormat
=
ArchiveFormat
.
forValue
(
format
);
return
(
getRepositoryArchive
(
projectId
,
sha
,
archiveFormat
));
return
(
getRepositoryArchive
(
projectId
OrPath
,
sha
,
archiveFormat
));
}
}
/**
/**
...
@@ -452,13 +484,13 @@ public class RepositoryApi extends AbstractApi {
...
@@ -452,13 +484,13 @@ public class RepositoryApi extends AbstractApi {
*
*
* GET /projects/:id/repository/archive
* GET /projects/:id/repository/archive
*
*
* @param projectId
the ID of the project
* @param projectId
OrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param sha the SHA of the archive to get
* @param sha the SHA of the archive to get
* @param format The archive format, defaults to TAR_GZ if null
* @param format The archive format, defaults to TAR_GZ if null
* @return an input stream that can be used to save as a file or to read the content of the archive
* @return an input stream that can be used to save as a file or to read the content of the archive
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
InputStream
getRepositoryArchive
(
Integer
projectId
,
String
sha
,
ArchiveFormat
format
)
throws
GitLabApiException
{
public
InputStream
getRepositoryArchive
(
Object
projectId
OrPath
,
String
sha
,
ArchiveFormat
format
)
throws
GitLabApiException
{
if
(
format
==
null
)
{
if
(
format
==
null
)
{
format
=
ArchiveFormat
.
TAR_GZ
;
format
=
ArchiveFormat
.
TAR_GZ
;
...
@@ -473,7 +505,7 @@ public class RepositoryApi extends AbstractApi {
...
@@ -473,7 +505,7 @@ public class RepositoryApi extends AbstractApi {
*/
*/
Form
formData
=
new
GitLabApiForm
().
withParam
(
"sha"
,
sha
);
Form
formData
=
new
GitLabApiForm
().
withParam
(
"sha"
,
sha
);
Response
response
=
getWithAccepts
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
MediaType
.
MEDIA_TYPE_WILDCARD
,
Response
response
=
getWithAccepts
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
MediaType
.
MEDIA_TYPE_WILDCARD
,
"projects"
,
projectId
,
"repository"
,
"archive"
+
"."
+
format
.
toString
());
"projects"
,
getProjectIdOrPath
(
projectId
OrPath
)
,
"repository"
,
"archive"
+
"."
+
format
.
toString
());
return
(
response
.
readEntity
(
InputStream
.
class
));
return
(
response
.
readEntity
(
InputStream
.
class
));
}
}
...
@@ -483,17 +515,17 @@ public class RepositoryApi extends AbstractApi {
...
@@ -483,17 +515,17 @@ public class RepositoryApi extends AbstractApi {
*
*
* GET /projects/:id/repository/archive
* GET /projects/:id/repository/archive
*
*
* @param projectId
the ID of the project
* @param projectId
OrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param sha the SHA of the archive to get
* @param sha the SHA of the archive to get
* @param directory the File instance of the directory to save the archive to, if null will use "java.io.tmpdir"
* @param directory the File instance of the directory to save the archive to, if null will use "java.io.tmpdir"
* @return a File instance pointing to the downloaded instance
* @return a File instance pointing to the downloaded instance
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
File
getRepositoryArchive
(
Integer
projectId
,
String
sha
,
File
directory
)
throws
GitLabApiException
{
public
File
getRepositoryArchive
(
Object
projectId
OrPath
,
String
sha
,
File
directory
)
throws
GitLabApiException
{
Form
formData
=
new
GitLabApiForm
().
withParam
(
"sha"
,
sha
);
Form
formData
=
new
GitLabApiForm
().
withParam
(
"sha"
,
sha
);
Response
response
=
getWithAccepts
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
MediaType
.
MEDIA_TYPE_WILDCARD
,
Response
response
=
getWithAccepts
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
MediaType
.
MEDIA_TYPE_WILDCARD
,
"projects"
,
projectId
,
"repository"
,
"archive"
);
"projects"
,
getProjectIdOrPath
(
projectId
OrPath
)
,
"repository"
,
"archive"
);
try
{
try
{
...
@@ -518,16 +550,16 @@ public class RepositoryApi extends AbstractApi {
...
@@ -518,16 +550,16 @@ public class RepositoryApi extends AbstractApi {
*
*
* GET /projects/:id/repository/archive
* GET /projects/:id/repository/archive
*
*
* @param projectId
the ID of the project
* @param projectId
OrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param sha the SHA of the archive to get
* @param sha the SHA of the archive to get
* @param directory the File instance of the directory to save the archive to, if null will use "java.io.tmpdir"
* @param directory the File instance of the directory to save the archive to, if null will use "java.io.tmpdir"
* @param format The archive format, defaults to "tar.gz" if null
* @param format The archive format, defaults to "tar.gz" if null
* @return a File instance pointing to the downloaded instance
* @return a File instance pointing to the downloaded instance
* @throws GitLabApiException if format is not a valid archive format or any exception occurs
* @throws GitLabApiException if format is not a valid archive format or any exception occurs
*/
*/
public
File
getRepositoryArchive
(
Integer
projectId
,
String
sha
,
File
directory
,
String
format
)
throws
GitLabApiException
{
public
File
getRepositoryArchive
(
Object
projectId
OrPath
,
String
sha
,
File
directory
,
String
format
)
throws
GitLabApiException
{
ArchiveFormat
archiveFormat
=
ArchiveFormat
.
forValue
(
format
);
ArchiveFormat
archiveFormat
=
ArchiveFormat
.
forValue
(
format
);
return
(
getRepositoryArchive
(
projectId
,
sha
,
directory
,
archiveFormat
));
return
(
getRepositoryArchive
(
projectId
OrPath
,
sha
,
directory
,
archiveFormat
));
}
}
/**
/**
...
@@ -536,14 +568,14 @@ public class RepositoryApi extends AbstractApi {
...
@@ -536,14 +568,14 @@ public class RepositoryApi extends AbstractApi {
*
*
* GET /projects/:id/repository/archive
* GET /projects/:id/repository/archive
*
*
* @param projectId
the ID of the project
* @param projectId
OrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param sha the SHA of the archive to get
* @param sha the SHA of the archive to get
* @param directory the File instance of the directory to save the archive to, if null will use "java.io.tmpdir"
* @param directory the File instance of the directory to save the archive to, if null will use "java.io.tmpdir"
* @param format The archive format, defaults to TAR_GZ if null
* @param format The archive format, defaults to TAR_GZ if null
* @return a File instance pointing to the downloaded instance
* @return a File instance pointing to the downloaded instance
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
File
getRepositoryArchive
(
Integer
projectId
,
String
sha
,
File
directory
,
ArchiveFormat
format
)
throws
GitLabApiException
{
public
File
getRepositoryArchive
(
Object
projectId
OrPath
,
String
sha
,
File
directory
,
ArchiveFormat
format
)
throws
GitLabApiException
{
if
(
format
==
null
)
{
if
(
format
==
null
)
{
format
=
ArchiveFormat
.
TAR_GZ
;
format
=
ArchiveFormat
.
TAR_GZ
;
...
@@ -558,7 +590,7 @@ public class RepositoryApi extends AbstractApi {
...
@@ -558,7 +590,7 @@ public class RepositoryApi extends AbstractApi {
*/
*/
Form
formData
=
new
GitLabApiForm
().
withParam
(
"sha"
,
sha
);
Form
formData
=
new
GitLabApiForm
().
withParam
(
"sha"
,
sha
);
Response
response
=
getWithAccepts
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
MediaType
.
MEDIA_TYPE_WILDCARD
,
Response
response
=
getWithAccepts
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
MediaType
.
MEDIA_TYPE_WILDCARD
,
"projects"
,
projectId
,
"repository"
,
"archive"
+
"."
+
format
.
toString
());
"projects"
,
getProjectIdOrPath
(
projectId
OrPath
)
,
"repository"
,
"archive"
+
"."
+
format
.
toString
());
try
{
try
{
...
@@ -581,39 +613,16 @@ public class RepositoryApi extends AbstractApi {
...
@@ -581,39 +613,16 @@ public class RepositoryApi extends AbstractApi {
* Compare branches, tags or commits. This can be accessed without authentication
* Compare branches, tags or commits. This can be accessed without authentication
* if the repository is publicly accessible.
* if the repository is publicly accessible.
*
*
* @param projectId
the ID of
the project
owned by the authenticated user
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param from the commit SHA or branch name
* @param from the commit SHA or branch name
* @param to the commit SHA or branch name
* @param to the commit SHA or branch name
* @return a CompareResults containing the results of the comparison
* @return a CompareResults containing the results of the comparison
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
CompareResults
compare
(
Integer
projectId
,
String
from
,
String
to
)
throws
GitLabApiException
{
public
CompareResults
compare
(
Object
projectId
OrPath
,
String
from
,
String
to
)
throws
GitLabApiException
{
Form
formData
=
new
GitLabApiForm
().
withParam
(
"from"
,
from
,
true
).
withParam
(
"to"
,
to
,
true
);
Form
formData
=
new
GitLabApiForm
().
withParam
(
"from"
,
from
,
true
).
withParam
(
"to"
,
to
,
true
);
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"projects"
,
projectId
,
"repository"
,
"compare"
);
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"projects"
,
return
(
response
.
readEntity
(
CompareResults
.
class
));
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"compare"
);
}
/**
* Compare branches, tags or commits. This can be accessed without authentication
* if the repository is publicly accessible.
*
* @param projectPath the path of the project owned by the authenticated user
* @param from the commit SHA or branch name
* @param to the commit SHA or branch name
* @return a CompareResults containing the results of the comparison
* @throws GitLabApiException if any exception occurs
*/
public
CompareResults
compare
(
String
projectPath
,
String
from
,
String
to
)
throws
GitLabApiException
{
Form
formData
=
new
GitLabApiForm
().
withParam
(
"from"
,
from
,
true
).
withParam
(
"to"
,
to
,
true
);
try
{
projectPath
=
URLEncoder
.
encode
(
projectPath
,
"UTF-8"
);
}
catch
(
UnsupportedEncodingException
uee
)
{
throw
(
new
GitLabApiException
(
uee
));
}
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"projects"
,
projectPath
,
"repository"
,
"compare"
);
return
(
response
.
readEntity
(
CompareResults
.
class
));
return
(
response
.
readEntity
(
CompareResults
.
class
));
}
}
...
@@ -622,12 +631,12 @@ public class RepositoryApi extends AbstractApi {
...
@@ -622,12 +631,12 @@ public class RepositoryApi extends AbstractApi {
*
*
* GET /projects/:id/repository/contributors
* GET /projects/:id/repository/contributors
*
*
* @param projectId the project
to get the list of contributors for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @return a List containing the contributors for the specified project ID
* @return a List containing the contributors for the specified project ID
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
Contributor
>
getContributors
(
Integer
projectId
)
throws
GitLabApiException
{
public
List
<
Contributor
>
getContributors
(
Object
projectId
OrPath
)
throws
GitLabApiException
{
return
(
getContributors
(
projectId
,
1
,
getDefaultPerPage
()));
return
(
getContributors
(
projectId
OrPath
,
1
,
getDefaultPerPage
()));
}
}
/**
/**
...
@@ -635,15 +644,15 @@ public class RepositoryApi extends AbstractApi {
...
@@ -635,15 +644,15 @@ public class RepositoryApi extends AbstractApi {
*
*
* GET /projects/:id/repository/contributors
* GET /projects/:id/repository/contributors
*
*
* @param projectId the project
to get the list of contributors for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param page the page to get
* @param page the page to get
* @param perPage the number of projects per page
* @param perPage the number of projects per page
* @return a List containing the contributors for the specified project ID
* @return a List containing the contributors for the specified project ID
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
Contributor
>
getContributors
(
Integer
projectId
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
public
List
<
Contributor
>
getContributors
(
Object
projectId
OrPath
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
getPageQueryParams
(
page
,
perPage
),
Response
response
=
get
(
Response
.
Status
.
OK
,
getPageQueryParams
(
page
,
perPage
),
"projects"
,
projectId
,
"repository"
,
"contributors"
);
"projects"
,
getProjectIdOrPath
(
projectId
OrPath
)
,
"repository"
,
"contributors"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Contributor
>>()
{
}));
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Contributor
>>()
{
}));
}
}
...
@@ -652,12 +661,13 @@ public class RepositoryApi extends AbstractApi {
...
@@ -652,12 +661,13 @@ public class RepositoryApi extends AbstractApi {
*
*
* GET /projects/:id/repository/contributors
* GET /projects/:id/repository/contributors
*
*
* @param projectId the project
to get the list of contributors for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param itemsPerPage the number of Project instances that will be fetched per page
* @param itemsPerPage the number of Project instances that will be fetched per page
* @return a Pager containing the contributors for the specified project ID
* @return a Pager containing the contributors for the specified project ID
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Pager
<
Contributor
>
getContributors
(
Integer
projectId
,
int
itemsPerPage
)
throws
GitLabApiException
{
public
Pager
<
Contributor
>
getContributors
(
Object
projectIdOrPath
,
int
itemsPerPage
)
throws
GitLabApiException
{
return
new
Pager
<
Contributor
>(
this
,
Contributor
.
class
,
itemsPerPage
,
null
,
"projects"
,
projectId
,
"repository"
,
"contributors"
);
return
new
Pager
<
Contributor
>(
this
,
Contributor
.
class
,
itemsPerPage
,
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"contributors"
);
}
}
}
}
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