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
48804220
Unverified
Commit
48804220
authored
Jul 05, 2021
by
Gautier de Saint Martin Lacaze
Committed by
GitHub
Jul 05, 2021
Browse files
Merge branch 'master' into master
parents
28c40be0
ebaf80e6
Changes
43
Expand all
Hide whitespace changes
Inline
Side-by-side
.editorconfig
0 → 100644
View file @
48804220
root = true
[*]
insert_final_newline = true
[*.java]
indent_size = 4
indent_style = space
trim_trailing_whitespace = true
.github/workflows/build.yml
0 → 100644
View file @
48804220
name
:
Build
on
:
push
:
branches
:
-
master
pull_request
:
types
:
[
opened
,
synchronize
,
reopened
]
jobs
:
build
:
name
:
Build
runs-on
:
ubuntu-latest
steps
:
-
uses
:
actions/checkout@v2
with
:
fetch-depth
:
0
# Shallow clones should be disabled for a better relevancy of analysis
-
name
:
Set up JDK
11
uses
:
actions/setup-java@v1
with
:
java-version
:
11
-
name
:
Cache SonarCloud packages
uses
:
actions/cache@v1
with
:
path
:
~/.sonar/cache
key
:
${{ runner.os }}-sonar
restore-keys
:
${{ runner.os }}-sonar
-
name
:
Cache Maven packages
uses
:
actions/cache@v1
with
:
path
:
~/.m2
key
:
${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys
:
${{ runner.os }}-m2
-
name
:
Build and analyze
env
:
GITHUB_TOKEN
:
${{ secrets.GITHUB_TOKEN }}
# Needed to get PR information, if any
SONAR_TOKEN
:
${{ secrets.SONAR_TOKEN }}
run
:
mvn -B test org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
README.md
View file @
48804220
# Git
l
Lab4J™ API (gitlab4j-api)<br />Java Client Library for the GitLab REST API
# GitLab4J™ API (gitlab4j-api)<br />Java Client Library for the GitLab REST API
[

](http://mvnrepository.com/artifact/org.gitlab4j/gitlab4j-api)
[

](http://mvnrepository.com/artifact/org.gitlab4j/gitlab4j-api)
[

](https://travis-ci.org/gitlab4j/gitlab4j-api)
[

](https://travis-ci.org/gitlab4j/gitlab4j-api)
...
@@ -54,7 +54,7 @@ To utilize GitLab4J™ API in your Java project, simply add the following de
...
@@ -54,7 +54,7 @@ To utilize GitLab4J™ API in your Java project, simply add the following de
```
java
```
java
dependencies
{
dependencies
{
...
...
compile
group:
'
org
.
gitlab4j
'
,
name:
'
gitlab4j
-
api
'
,
version:
'
4.1
5
.
7
'
compile
group:
'
org
.
gitlab4j
'
,
name:
'
gitlab4j
-
api
'
,
version:
'
4.1
6
.
0
'
}
}
```
```
...
@@ -65,7 +65,7 @@ dependencies {
...
@@ -65,7 +65,7 @@ dependencies {
<dependency>
<dependency>
<groupId>
org.gitlab4j
</groupId>
<groupId>
org.gitlab4j
</groupId>
<artifactId>
gitlab4j-api
</artifactId>
<artifactId>
gitlab4j-api
</artifactId>
<version>
4.1
5.7
</version>
<version>
4.1
6.0
</version>
</dependency>
</dependency>
```
```
...
...
pom.xml
View file @
48804220
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/Constants.java
View file @
48804220
...
@@ -243,6 +243,28 @@ public interface Constants {
...
@@ -243,6 +243,28 @@ public interface Constants {
}
}
}
}
/** Enum to use for ordering the results of getDeployments. */
public
static
enum
DeploymentOrderBy
{
ID
,
IID
,
CREATED_AT
,
UPDATED_AT
,
REF
;
private
static
JacksonJsonEnumHelper
<
DeploymentOrderBy
>
enumHelper
=
new
JacksonJsonEnumHelper
<>(
DeploymentOrderBy
.
class
);
@JsonCreator
public
static
DeploymentOrderBy
forValue
(
String
value
)
{
return
enumHelper
.
forValue
(
value
);
}
@JsonValue
public
String
toValue
()
{
return
(
enumHelper
.
toString
(
this
));
}
@Override
public
String
toString
()
{
return
(
enumHelper
.
toString
(
this
));
}
}
/** Enum to use for specifying the scope when calling getPipelines(). */
/** Enum to use for specifying the scope when calling getPipelines(). */
public
enum
PipelineScope
{
public
enum
PipelineScope
{
...
@@ -783,7 +805,9 @@ public interface Constants {
...
@@ -783,7 +805,9 @@ public interface Constants {
/** Enum to use for specifying the status of a deployment. */
/** Enum to use for specifying the status of a deployment. */
public
enum
DeploymentStatus
{
public
enum
DeploymentStatus
{
/**
* After some tests, {@link #CREATED} value is not a valid value.
*/
CREATED
,
RUNNING
,
SUCCESS
,
FAILED
,
CANCELED
;
CREATED
,
RUNNING
,
SUCCESS
,
FAILED
,
CANCELED
;
private
static
JacksonJsonEnumHelper
<
DeploymentStatus
>
enumHelper
=
new
JacksonJsonEnumHelper
<>(
DeploymentStatus
.
class
);
private
static
JacksonJsonEnumHelper
<
DeploymentStatus
>
enumHelper
=
new
JacksonJsonEnumHelper
<>(
DeploymentStatus
.
class
);
...
@@ -848,5 +872,26 @@ public interface Constants {
...
@@ -848,5 +872,26 @@ public interface Constants {
return
(
enumHelper
.
toString
(
this
));
return
(
enumHelper
.
toString
(
this
));
}
}
}
}
enum
AutoDevopsDeployStrategy
{
CONTINUOUS
,
MANUAL
,
TIMED_INCREMENTAL
;
private
static
JacksonJsonEnumHelper
<
AutoDevopsDeployStrategy
>
enumHelper
=
new
JacksonJsonEnumHelper
<>(
AutoDevopsDeployStrategy
.
class
);
@JsonCreator
public
static
AutoDevopsDeployStrategy
forValue
(
String
value
)
{
return
enumHelper
.
forValue
(
value
);
}
@JsonValue
public
String
toValue
()
{
return
(
enumHelper
.
toString
(
this
));
}
@Override
public
String
toString
()
{
return
(
enumHelper
.
toString
(
this
));
}
}
}
}
src/main/java/org/gitlab4j/api/DeploymentsApi.java
0 → 100644
View file @
48804220
package
org.gitlab4j.api
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.stream.Stream
;
import
javax.ws.rs.core.Response
;
import
org.gitlab4j.api.models.Deployment
;
import
org.gitlab4j.api.models.DeploymentFilter
;
import
org.gitlab4j.api.models.MergeRequest
;
/**
* This class implements the client side API for the GitLab Deployments API calls.
* See https://docs.gitlab.com/ee/api/deployments.html
*
*/
public
class
DeploymentsApi
extends
AbstractApi
{
public
DeploymentsApi
(
GitLabApi
gitLabApi
)
{
super
(
gitLabApi
);
}
/**
* Get a list of deployments for the specified project.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/deployments</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @return a list of Deployments
* @throws GitLabApiException if any exception occurs
*/
public
List
<
Deployment
>
getProjectDeployments
(
Object
projectIdOrPath
)
throws
GitLabApiException
{
return
(
getProjectDeployments
(
projectIdOrPath
,
null
,
getDefaultPerPage
()).
all
());
}
/**
* Get a Pager of all deployments for the specified project.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/deployments</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param itemsPerPage the number of Deployments instances that will be fetched per page
* @return a Pager of Deployment
* @throws GitLabApiException if any exception occurs
*/
public
Pager
<
Deployment
>
getProjectDeployments
(
Object
projectIdOrPath
,
int
itemsPerPage
)
throws
GitLabApiException
{
return
(
getProjectDeployments
(
projectIdOrPath
,
null
,
itemsPerPage
));
}
/**
* Get a Pager of all deployments for the specified project.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/deployments</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param filter {@link DeploymentFilter} a DeploymentFilter instance with the filter settings
* @return a Pager of Deployment
* @throws GitLabApiException if any exception occurs
*/
public
Pager
<
Deployment
>
getProjectDeployments
(
Object
projectIdOrPath
,
DeploymentFilter
filter
)
throws
GitLabApiException
{
return
(
getProjectDeployments
(
projectIdOrPath
,
filter
,
getDefaultPerPage
()));
}
/**
* Get a Pager of all deployments for the specified project.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/deployments</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param filter {@link DeploymentFilter} a DeploymentFilter instance with the filter settings
* @param itemsPerPage the number of Deployments instances that will be fetched per page
* @return a Pager of Deployment
* @throws GitLabApiException if any exception occurs
*/
public
Pager
<
Deployment
>
getProjectDeployments
(
Object
projectIdOrPath
,
DeploymentFilter
filter
,
int
itemsPerPage
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
(
filter
!=
null
?
filter
.
getQueryParams
()
:
new
GitLabApiForm
());
return
(
new
Pager
<
Deployment
>(
this
,
Deployment
.
class
,
itemsPerPage
,
formData
.
asMap
(),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"deployments"
));
}
/**
* Get a Stream of all deployments for the specified project.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/deployments</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @return a list of Deployment
* @throws GitLabApiException if any exception occurs
*/
public
Stream
<
Deployment
>
getProjectDeploymentsStream
(
Object
projectIdOrPath
)
throws
GitLabApiException
{
return
(
getProjectDeployments
(
projectIdOrPath
,
null
,
getDefaultPerPage
()).
stream
());
}
/**
* Get a Stream of all deployments for the specified project.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/deployments</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param filter {@link DeploymentFilter} a DeploymentFilter instance with the filter settings
* @return a list of Deployment
* @throws GitLabApiException if any exception occurs
*/
public
Stream
<
Deployment
>
getProjectDeploymentsStream
(
Object
projectIdOrPath
,
DeploymentFilter
filter
)
throws
GitLabApiException
{
return
(
getProjectDeployments
(
projectIdOrPath
,
filter
,
getDefaultPerPage
()).
stream
());
}
/**
* Get a specific deployment.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/deployments/:deployment_id</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param deploymentId the ID of a project's deployment
* @return the specified Deployment instance
* @throws GitLabApiException if any exception occurs
*/
public
Deployment
getDeployment
(
Object
projectIdOrPath
,
Integer
deploymentId
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
getDefaultPerPageParam
(),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"deployments"
,
deploymentId
);
return
(
response
.
readEntity
(
Deployment
.
class
));
}
/**
* Get a specific deployment as an Optional instance.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/deployments/:deployment_id</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param deploymentId the ID of a project's deployment
* @return the specified Deployment as an Optional instance
*/
public
Optional
<
Deployment
>
getOptionalDeployment
(
Object
projectIdOrPath
,
Integer
deploymentId
)
{
try
{
return
(
Optional
.
ofNullable
(
getDeployment
(
projectIdOrPath
,
deploymentId
)));
}
catch
(
GitLabApiException
glae
)
{
return
(
GitLabApi
.
createOptionalFromException
(
glae
));
}
}
/**
* Creates a new deployment for a project.
*
* <pre><code>GitLab Endpoint: POST /projects/:id/deployments</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param environment The name of the environment to create the deployment for, required
* @param sha The SHA of the commit that is deployed, required
* @param ref The name of the branch or tag that is deployed, required
* @param tag A boolean that indicates if the deployed ref is a tag (true) or not (false), required
* @param status The status to filter deployments by, required
* @return a Deployment instance with info on the added deployment
* @throws GitLabApiException if any exception occurs
*/
public
Deployment
addDeployment
(
Object
projectIdOrPath
,
String
environment
,
String
sha
,
String
ref
,
Boolean
tag
,
DeploymentStatus
status
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
new
GitLabApiForm
()
.
withParam
(
"environment"
,
environment
,
true
)
.
withParam
(
"sha"
,
sha
,
true
)
.
withParam
(
"ref"
,
ref
,
true
)
.
withParam
(
"tag"
,
tag
,
true
)
.
withParam
(
"status"
,
status
,
true
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"deployments"
);
return
(
response
.
readEntity
(
Deployment
.
class
));
}
/**
* Updates an existing project deploy key.
*
* <pre><code>GitLab Endpoint: PUT /projects/:id/deployments/:key_id</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param deploymentId The ID of the deployment to update, required
* @param status The new status of the deployment, required
* @return an updated Deployment instance
* @throws GitLabApiException if any exception occurs
*/
public
Deployment
updateDeployment
(
Object
projectIdOrPath
,
Integer
deploymentId
,
DeploymentStatus
status
)
throws
GitLabApiException
{
if
(
deploymentId
==
null
)
{
throw
new
RuntimeException
(
"deploymentId cannot be null"
);
}
final
Deployment
deployment
=
new
Deployment
();
deployment
.
setStatus
(
status
);
final
Response
response
=
put
(
Response
.
Status
.
OK
,
deployment
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"deployments"
,
deploymentId
);
return
(
response
.
readEntity
(
Deployment
.
class
));
}
/**
* Get a list of Merge Requests shipped with a given deployment.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/deployments/:deployment_id/merge_requests</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param deploymentId The ID of the deployment to update, required
* @return a list containing the MergeRequest instances shipped with a given deployment
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
*/
public
List
<
MergeRequest
>
getMergeRequests
(
Object
projectIdOrPath
,
Integer
deploymentId
)
throws
GitLabApiException
{
return
(
getMergeRequests
(
projectIdOrPath
,
deploymentId
,
getDefaultPerPage
()).
all
());
}
/**
* Get a Pager of Merge Requests shipped with a given deployment.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/deployments/:deployment_id/merge_requests</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param deploymentId The ID of the deployment to update, required
* @param itemsPerPage the number of Commit instances that will be fetched per page
* @return a Pager containing the MergeRequest instances shipped with a given deployment
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
*/
public
Pager
<
MergeRequest
>
getMergeRequests
(
Object
projectIdOrPath
,
Integer
deploymentId
,
int
itemsPerPage
)
throws
GitLabApiException
{
return
(
new
Pager
<
MergeRequest
>(
this
,
MergeRequest
.
class
,
itemsPerPage
,
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"commits"
,
deploymentId
,
"merge_requests"
));
}
/**
* Get a Stream of Merge Requests shipped with a given deployment.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/deployments/:deployment_id/merge_requests</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param deploymentId The ID of the deployment to update, required
* @return a Stream containing the MergeRequest instances shipped with a given deployment
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
*/
public
Stream
<
MergeRequest
>
getMergeRequestsStream
(
Object
projectIdOrPath
,
Integer
deploymentId
)
throws
GitLabApiException
{
return
(
getMergeRequests
(
projectIdOrPath
,
deploymentId
,
getDefaultPerPage
()).
stream
());
}
}
src/main/java/org/gitlab4j/api/DiscussionsApi.java
View file @
48804220
...
@@ -603,7 +603,7 @@ public class DiscussionsApi extends AbstractApi {
...
@@ -603,7 +603,7 @@ public class DiscussionsApi extends AbstractApi {
public
void
deleteCommitDiscussionNote
(
Object
projectIdOrPath
,
String
commitSha
,
public
void
deleteCommitDiscussionNote
(
Object
projectIdOrPath
,
String
commitSha
,
String
discussionId
,
Integer
noteId
)
throws
GitLabApiException
{
String
discussionId
,
Integer
noteId
)
throws
GitLabApiException
{
delete
(
Response
.
Status
.
OK
,
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
delete
(
Response
.
Status
.
OK
,
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
commitSha
,
"discussions"
,
discussionId
,
"notes"
,
noteId
);
"repository"
,
"commits"
,
commitSha
,
"discussions"
,
discussionId
,
"notes"
,
noteId
);
}
}
/**
/**
...
...
src/main/java/org/gitlab4j/api/GitLabApi.java
View file @
48804220
...
@@ -58,6 +58,7 @@ public class GitLabApi implements AutoCloseable {
...
@@ -58,6 +58,7 @@ public class GitLabApi implements AutoCloseable {
private
ContainerRegistryApi
containerRegistryApi
;
private
ContainerRegistryApi
containerRegistryApi
;
private
DiscussionsApi
discussionsApi
;
private
DiscussionsApi
discussionsApi
;
private
DeployKeysApi
deployKeysApi
;
private
DeployKeysApi
deployKeysApi
;
private
DeploymentsApi
deploymentsApi
;
private
DeployTokensApi
deployTokensApi
;
private
DeployTokensApi
deployTokensApi
;
private
EnvironmentsApi
environmentsApi
;
private
EnvironmentsApi
environmentsApi
;
private
EpicsApi
epicsApi
;
private
EpicsApi
epicsApi
;
...
@@ -961,6 +962,25 @@ public class GitLabApi implements AutoCloseable {
...
@@ -961,6 +962,25 @@ public class GitLabApi implements AutoCloseable {
return
(
deployKeysApi
);
return
(
deployKeysApi
);
}
}
/**
* Gets the DeployKeysApi instance owned by this GitLabApi instance. The DeploymentsApi is used
* to perform all deployment related API calls.
*
* @return the DeploymentsApi instance owned by this GitLabApi instance
*/
public
DeploymentsApi
getDeploymentsApi
()
{
if
(
deploymentsApi
==
null
)
{
synchronized
(
this
)
{
if
(
deploymentsApi
==
null
)
{
deploymentsApi
=
new
DeploymentsApi
(
this
);
}
}
}
return
(
deploymentsApi
);
}
/**
/**
* Gets the DeployTokensApi instance owned by this GitLabApi instance. The DeployTokensApi is used
* Gets the DeployTokensApi instance owned by this GitLabApi instance. The DeployTokensApi is used
* to perform all deploy token related API calls.
* to perform all deploy token related API calls.
...
...
src/main/java/org/gitlab4j/api/GroupApi.java
View file @
48804220
...
@@ -1310,9 +1310,28 @@ public class GroupApi extends AbstractApi {
...
@@ -1310,9 +1310,28 @@ public class GroupApi extends AbstractApi {
*/
*/
public
Variable
createVariable
(
Object
groupIdOrPath
,
String
key
,
String
value
,
Boolean
isProtected
)
throws
GitLabApiException
{
public
Variable
createVariable
(
Object
groupIdOrPath
,
String
key
,
String
value
,
Boolean
isProtected
)
throws
GitLabApiException
{
return
createVariable
(
groupIdOrPath
,
key
,
value
,
isProtected
,
false
);
}
/**
* Create a new group variable.
*
* <pre><code>GitLab Endpoint: POST /groups/:id/variables</code></pre>
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path, required
* @param key the key of a variable; must have no more than 255 characters; only A-Z, a-z, 0-9, and _ are allowed, required
* @param value the value for the variable, required
* @param isProtected whether the variable is protected, optional
* @param masked whether the variable is masked, optional
* @return a Variable instance with the newly created variable
* @throws GitLabApiException if any exception occurs during execution
*/
public
Variable
createVariable
(
Object
groupIdOrPath
,
String
key
,
String
value
,
Boolean
isProtected
,
Boolean
masked
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
new
GitLabApiForm
()
GitLabApiForm
formData
=
new
GitLabApiForm
()
.
withParam
(
"key"
,
key
,
true
)
.
withParam
(
"key"
,
key
,
true
)
.
withParam
(
"value"
,
value
,
true
)
.
withParam
(
"value"
,
value
,
true
)
.
withParam
(
"masked"
,
masked
)
.
withParam
(
"protected"
,
isProtected
);
.
withParam
(
"protected"
,
isProtected
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"variables"
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"variables"
);
return
(
response
.
readEntity
(
Variable
.
class
));
return
(
response
.
readEntity
(
Variable
.
class
));
...
@@ -1332,8 +1351,27 @@ public class GroupApi extends AbstractApi {
...
@@ -1332,8 +1351,27 @@ public class GroupApi extends AbstractApi {
*/
*/
public
Variable
updateVariable
(
Object
groupIdOrPath
,
String
key
,
String
value
,
Boolean
isProtected
)
throws
GitLabApiException
{
public
Variable
updateVariable
(
Object
groupIdOrPath
,
String
key
,
String
value
,
Boolean
isProtected
)
throws
GitLabApiException
{
return
updateVariable
(
groupIdOrPath
,
key
,
value
,
isProtected
,
false
);
}
/**
* Update a group variable.
*
* <pre><code>GitLab Endpoint: PUT /groups/:id/variables/:key</code></pre>
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path, required
* @param key the key of an existing variable, required
* @param value the value for the variable, required
* @param isProtected whether the variable is protected, optional
* @param masked whether the variable is masked, optional
* @return a Variable instance with the updated variable
* @throws GitLabApiException if any exception occurs during execution
*/
public
Variable
updateVariable
(
Object
groupIdOrPath
,
String
key
,
String
value
,
Boolean
isProtected
,
Boolean
masked
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
new
GitLabApiForm
()
GitLabApiForm
formData
=
new
GitLabApiForm
()
.
withParam
(
"value"
,
value
,
true
)
.
withParam
(
"value"
,
value
,
true
)
.
withParam
(
"masked"
,
masked
)
.
withParam
(
"protected"
,
isProtected
);
.
withParam
(
"protected"
,
isProtected
);
Response
response
=
putWithFormData
(
Response
.
Status
.
CREATED
,
formData
,
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"variables"
,
key
);
Response
response
=
putWithFormData
(
Response
.
Status
.
CREATED
,
formData
,
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"variables"
,
key
);
return
(
response
.
readEntity
(
Variable
.
class
));
return
(
response
.
readEntity
(
Variable
.
class
));
...
...
src/main/java/org/gitlab4j/api/Pager.java
View file @
48804220
...
@@ -306,12 +306,6 @@ public class Pager<T> implements Iterator<List<T>>, Constants {
...
@@ -306,12 +306,6 @@ public class Pager<T> implements Iterator<List<T>>, Constants {
*/
*/
public
List
<
T
>
page
(
int
pageNumber
)
{
public
List
<
T
>
page
(
int
pageNumber
)
{
if
(
pageNumber
>
totalPages
&&
pageNumber
>
kaminariNextPage
)
{
throw
new
NoSuchElementException
();
}
else
if
(
pageNumber
<
1
)
{
throw
new
NoSuchElementException
();
}
if
(
currentPage
==
0
&&
pageNumber
==
1
)
{
if
(
currentPage
==
0
&&
pageNumber
==
1
)
{
currentPage
=
1
;
currentPage
=
1
;
return
(
currentItems
);
return
(
currentItems
);
...
@@ -321,6 +315,12 @@ public class Pager<T> implements Iterator<List<T>>, Constants {
...
@@ -321,6 +315,12 @@ public class Pager<T> implements Iterator<List<T>>, Constants {
return
(
currentItems
);
return
(
currentItems
);
}
}
if
(
pageNumber
>
totalPages
&&
pageNumber
>
kaminariNextPage
)
{
throw
new
NoSuchElementException
();
}
else
if
(
pageNumber
<
1
)
{
throw
new
NoSuchElementException
();
}
try
{
try
{
setPageParam
(
pageNumber
);
setPageParam
(
pageNumber
);
...
...
src/main/java/org/gitlab4j/api/PagerSpliterator.java
View file @
48804220
...
@@ -30,8 +30,10 @@ class PagerSpliterator<T> implements Spliterator<T> {
...
@@ -30,8 +30,10 @@ class PagerSpliterator<T> implements Spliterator<T> {
return
true
;
return
true
;
}
else
if
(
pager
.
hasNext
())
{
}
else
if
(
pager
.
hasNext
())
{
elements
=
pager
.
next
().
iterator
();
elements
=
pager
.
next
().
iterator
();
action
.
accept
(
elements
.
next
());
if
(
elements
.
hasNext
())
{
return
true
;
action
.
accept
(
elements
.
next
());
return
true
;
}
}
}
return
false
;
return
false
;
}
}
...
...
src/main/java/org/gitlab4j/api/ProjectApi.java
View file @
48804220
...
@@ -1022,7 +1022,9 @@ public class ProjectApi extends AbstractApi implements Constants {
...
@@ -1022,7 +1022,9 @@ public class ProjectApi extends AbstractApi implements Constants {
.
withParam
(
"initialize_with_readme"
,
project
.
getInitializeWithReadme
())
.
withParam
(
"initialize_with_readme"
,
project
.
getInitializeWithReadme
())
.
withParam
(
"packages_enabled"
,
project
.
getPackagesEnabled
())
.
withParam
(
"packages_enabled"
,
project
.
getPackagesEnabled
())
.
withParam
(
"build_git_strategy"
,
project
.
getBuildGitStrategy
())
.
withParam
(
"build_git_strategy"
,
project
.
getBuildGitStrategy
())
.
withParam
(
"build_coverage_regex"
,
project
.
getBuildCoverageRegex
());
.
withParam
(
"build_coverage_regex"
,
project
.
getBuildCoverageRegex
())
.
withParam
(
"suggestion_commit_message"
,
project
.
getSuggestionCommitMessage
())
.
withParam
(
"remove_source_branch_after_merge"
,
project
.
getRemoveSourceBranchAfterMerge
());
Namespace
namespace
=
project
.
getNamespace
();
Namespace
namespace
=
project
.
getNamespace
();
if
(
namespace
!=
null
&&
namespace
.
getId
()
!=
null
)
{
if
(
namespace
!=
null
&&
namespace
.
getId
()
!=
null
)
{
...
@@ -1046,10 +1048,6 @@ public class ProjectApi extends AbstractApi implements Constants {
...
@@ -1046,10 +1048,6 @@ public class ProjectApi extends AbstractApi implements Constants {
}
}
}
}
if
(
project
.
getNamespace
()
!=
null
)
{
formData
.
withParam
(
"namespace_id"
,
project
.
getNamespace
().
getId
());
}
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
);
return
(
response
.
readEntity
(
Project
.
class
));
return
(
response
.
readEntity
(
Project
.
class
));
}
}
...
@@ -1269,7 +1267,10 @@ public class ProjectApi extends AbstractApi implements Constants {
...
@@ -1269,7 +1267,10 @@ public class ProjectApi extends AbstractApi implements Constants {
.
withParam
(
"resolve_outdated_diff_discussions"
,
project
.
getResolveOutdatedDiffDiscussions
())
.
withParam
(
"resolve_outdated_diff_discussions"
,
project
.
getResolveOutdatedDiffDiscussions
())
.
withParam
(
"packages_enabled"
,
project
.
getPackagesEnabled
())
.
withParam
(
"packages_enabled"
,
project
.
getPackagesEnabled
())
.
withParam
(
"build_git_strategy"
,
project
.
getBuildGitStrategy
())
.
withParam
(
"build_git_strategy"
,
project
.
getBuildGitStrategy
())
.
withParam
(
"build_coverage_regex"
,
project
.
getBuildCoverageRegex
());
.
withParam
(
"build_coverage_regex"
,
project
.
getBuildCoverageRegex
())
.
withParam
(
"merge_method"
,
project
.
getMergeMethod
())
.
withParam
(
"suggestion_commit_message"
,
project
.
getSuggestionCommitMessage
())
.
withParam
(
"remove_source_branch_after_merge"
,
project
.
getRemoveSourceBranchAfterMerge
());
if
(
isApiVersion
(
ApiVersion
.
V3
))
{
if
(
isApiVersion
(
ApiVersion
.
V3
))
{
formData
.
withParam
(
"visibility_level"
,
project
.
getVisibilityLevel
());
formData
.
withParam
(
"visibility_level"
,
project
.
getVisibilityLevel
());
...
@@ -2065,7 +2066,7 @@ public class ProjectApi extends AbstractApi implements Constants {
...
@@ -2065,7 +2066,7 @@ public class ProjectApi extends AbstractApi implements Constants {
.
withParam
(
"confidential_note_events"
,
enabledHooks
.
getConfidentialNoteEvents
(),
false
)
.
withParam
(
"confidential_note_events"
,
enabledHooks
.
getConfidentialNoteEvents
(),
false
)
.
withParam
(
"job_events"
,
enabledHooks
.
getJobEvents
(),
false
)
.
withParam
(
"job_events"
,
enabledHooks
.
getJobEvents
(),
false
)
.
withParam
(
"pipeline_events"
,
enabledHooks
.
getPipelineEvents
(),
false
)
.
withParam
(
"pipeline_events"
,
enabledHooks
.
getPipelineEvents
(),
false
)
.
withParam
(
"wiki_events"
,
enabledHooks
.
getWikiPageEvents
(),
false
)
.
withParam
(
"wiki_
page_
events"
,
enabledHooks
.
getWikiPageEvents
(),
false
)
.
withParam
(
"enable_ssl_verification"
,
enableSslVerification
,
false
)
.
withParam
(
"enable_ssl_verification"
,
enableSslVerification
,
false
)
.
withParam
(
"repository_update_events"
,
enabledHooks
.
getRepositoryUpdateEvents
(),
false
)
.
withParam
(
"repository_update_events"
,
enabledHooks
.
getRepositoryUpdateEvents
(),
false
)
.
withParam
(
"token"
,
secretToken
,
false
);
.
withParam
(
"token"
,
secretToken
,
false
);
...
@@ -2145,7 +2146,7 @@ public class ProjectApi extends AbstractApi implements Constants {
...
@@ -2145,7 +2146,7 @@ public class ProjectApi extends AbstractApi implements Constants {
.
withParam
(
"note_events"
,
hook
.
getNoteEvents
(),
false
)
.
withParam
(
"note_events"
,
hook
.
getNoteEvents
(),
false
)
.
withParam
(
"job_events"
,
hook
.
getJobEvents
(),
false
)
.
withParam
(
"job_events"
,
hook
.
getJobEvents
(),
false
)
.
withParam
(
"pipeline_events"
,
hook
.
getPipelineEvents
(),
false
)
.
withParam
(
"pipeline_events"
,
hook
.
getPipelineEvents
(),
false
)
.
withParam
(
"wiki_events"
,
hook
.
getWikiPageEvents
(),
false
)
.
withParam
(
"wiki_
page_
events"
,
hook
.
getWikiPageEvents
(),
false
)
.
withParam
(
"enable_ssl_verification"
,
hook
.
getEnableSslVerification
(),
false
)
.
withParam
(
"enable_ssl_verification"
,
hook
.
getEnableSslVerification
(),
false
)
.
withParam
(
"token"
,
hook
.
getToken
(),
false
);
.
withParam
(
"token"
,
hook
.
getToken
(),
false
);
...
...
src/main/java/org/gitlab4j/api/RepositoryApi.java
View file @
48804220
...
@@ -18,6 +18,7 @@ import javax.ws.rs.core.Response;
...
@@ -18,6 +18,7 @@ import javax.ws.rs.core.Response;
import
org.gitlab4j.api.GitLabApi.ApiVersion
;
import
org.gitlab4j.api.GitLabApi.ApiVersion
;
import
org.gitlab4j.api.models.Branch
;
import
org.gitlab4j.api.models.Branch
;
import
org.gitlab4j.api.models.ChangelogPayload
;
import
org.gitlab4j.api.models.Commit
;
import
org.gitlab4j.api.models.Commit
;
import
org.gitlab4j.api.models.CompareResults
;
import
org.gitlab4j.api.models.CompareResults
;
import
org.gitlab4j.api.models.Contributor
;
import
org.gitlab4j.api.models.Contributor
;
...
@@ -749,4 +750,32 @@ public class RepositoryApi extends AbstractApi {
...
@@ -749,4 +750,32 @@ public class RepositoryApi extends AbstractApi {
delete
(
Response
.
Status
.
NO_CONTENT
,
null
,
"projects"
,
delete
(
Response
.
Status
.
NO_CONTENT
,
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"merged_branches"
);
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"merged_branches"
);
}
}
/**
* Generate changelog data based on commits in a repository.
*
* <pre><code>GitLab Endpoint: POST /projects/:id/repository/changelog</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param version the version to generate the changelog for
* @throws GitLabApiException if any exception occurs
*/
public
void
generateChangelog
(
Object
projectIdOrPath
,
String
version
)
throws
GitLabApiException
{
generateChangelog
(
projectIdOrPath
,
new
ChangelogPayload
(
version
));
}
/**
* Generate changelog data based on commits in a repository.
*
* <pre><code>GitLab Endpoint: POST /projects/:id/repository/changelog</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param payload the payload to generate the changelog for
* @throws GitLabApiException if any exception occurs
*/
public
void
generateChangelog
(
Object
projectIdOrPath
,
ChangelogPayload
payload
)
throws
GitLabApiException
{
post
(
Response
.
Status
.
OK
,
payload
.
getFormData
(),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"changelog"
);
}
}
}
src/main/java/org/gitlab4j/api/ServicesApi.java
View file @
48804220
...
@@ -3,6 +3,7 @@ package org.gitlab4j.api;
...
@@ -3,6 +3,7 @@ package org.gitlab4j.api;
import
org.gitlab4j.api.GitLabApi.ApiVersion
;
import
org.gitlab4j.api.GitLabApi.ApiVersion
;
import
org.gitlab4j.api.services.BugzillaService
;
import
org.gitlab4j.api.services.BugzillaService
;
import
org.gitlab4j.api.services.CustomIssueTrackerService
;
import
org.gitlab4j.api.services.CustomIssueTrackerService
;
import
org.gitlab4j.api.services.EmailOnPushService
;
import
org.gitlab4j.api.services.ExternalWikiService
;
import
org.gitlab4j.api.services.ExternalWikiService
;
import
org.gitlab4j.api.services.HipChatService
;
import
org.gitlab4j.api.services.HipChatService
;
import
org.gitlab4j.api.services.JiraService
;
import
org.gitlab4j.api.services.JiraService
;
...
@@ -493,4 +494,60 @@ public class ServicesApi extends AbstractApi {
...
@@ -493,4 +494,60 @@ public class ServicesApi extends AbstractApi {
delete
(
Response
.
Status
.
OK
,
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"services"
,
"custom-issue-tracker"
);
delete
(
Response
.
Status
.
OK
,
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"services"
,
"custom-issue-tracker"
);
}
}
/**
* Get Emails on push service settings for a project.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/services/emails-on-push</code></pre>
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @return a EmailOnPushService instance holding the Email on push settings
* @throws GitLabApiException if any exception occurs
*/
public
EmailOnPushService
getEmailOnPushService
(
Object
projectIdOrPath
)
throws
GitLabApiException
{
Response
response
=
this
.
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"services"
,
"emails-on-push"
);
return
(
response
.
readEntity
(
EmailOnPushService
.
class
));
}
/**
* Updates the EmailsOnPush service settings for a project.
*
* <pre><code>GitLab Endpoint: PUT /projects/:id/services/emails-on-push</code></pre>
*
* The following properties on the EmailOnPushService instance are utilized in the update of the settings:
* <p>
* recipients (required), Emails separated by whitespace
* disable_diffs (optional), Disable code diffs
* send_from_committer_email (optional), Send from committer
* push_events (optional), Enable notifications for push events
* tag_push_events(optional), Enable notifications for tag push events
* branches_to_be_notified (optional), Branches to send notifications for. Valid options are "all", "default",
* "protected", and "default_and_protected". Notifications are always fired
* for tag pushes. The default value is "all"
* </p>
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param emailsOnPush the EmailOnPushService instance holding the settings
* @return a EmailOnPushService instance holding the newly updated settings
* @throws GitLabApiException if any exception occurs
*/
public
EmailOnPushService
updateEmailOnPushService
(
Object
projectIdOrPath
,
EmailOnPushService
emailsOnPush
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
emailsOnPush
.
servicePropertiesForm
();
Response
response
=
put
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"services"
,
"emails-on-push"
);
return
(
response
.
readEntity
(
EmailOnPushService
.
class
));
}
/**
* Deletes the Emails on push service for a project.
*
* <pre><code>GitLab Endpoint: DELETE /projects/:id/services/emails-on-push</code></pre>
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @throws GitLabApiException if any exception occurs
*/
public
void
deleteEmailonPushService
(
Object
projectIdOrPath
)
throws
GitLabApiException
{
delete
(
Response
.
Status
.
OK
,
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"services"
,
"emails-on-push"
);
}
}
}
src/main/java/org/gitlab4j/api/SystemHooksApi.java
View file @
48804220
...
@@ -80,12 +80,32 @@ public class SystemHooksApi extends AbstractApi {
...
@@ -80,12 +80,32 @@ public class SystemHooksApi extends AbstractApi {
* @param token secret token to validate received payloads, optional
* @param token secret token to validate received payloads, optional
* @param pushEvents when true, the hook will fire on push events, optional
* @param pushEvents when true, the hook will fire on push events, optional
* @param tagPushEvents when true, the hook will fire on new tags being pushed, optional
* @param tagPushEvents when true, the hook will fire on new tags being pushed, optional
* @param enablS
s
slVerification do SSL verification when triggering the hook, optional
* @param enabl
e
SslVerification do SSL verification when triggering the hook, optional
* @return an SystemHookEvent instance with info on the added system hook
* @return an SystemHookEvent instance with info on the added system hook
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
SystemHook
addSystemHook
(
String
url
,
String
token
,
Boolean
pushEvents
,
public
SystemHook
addSystemHook
(
String
url
,
String
token
,
Boolean
pushEvents
,
Boolean
tagPushEvents
,
Boolean
enablSsslVerification
)
throws
GitLabApiException
{
Boolean
tagPushEvents
,
Boolean
enableSslVerification
)
throws
GitLabApiException
{
SystemHook
systemHook
=
new
SystemHook
().
withPushEvents
(
pushEvents
)
.
withTagPushEvents
(
tagPushEvents
)
.
withEnableSslVerification
(
enableSslVerification
);
return
addSystemHook
(
url
,
token
,
systemHook
);
}
/**
* Add a new system hook. This method requires admin access.
*
* <pre><code>GitLab Endpoint: POST /hooks</code></pre>
*
* @param url the hook URL, required
* @param token secret token to validate received payloads, optional
* @param systemHook the systemHook to create
* @return an SystemHookEvent instance with info on the added system hook
* @throws GitLabApiException if any exception occurs
*/
public
SystemHook
addSystemHook
(
String
url
,
String
token
,
SystemHook
systemHook
)
throws
GitLabApiException
{
if
(
url
==
null
)
{
if
(
url
==
null
)
{
throw
new
RuntimeException
(
"url cannot be null"
);
throw
new
RuntimeException
(
"url cannot be null"
);
...
@@ -94,9 +114,11 @@ public class SystemHooksApi extends AbstractApi {
...
@@ -94,9 +114,11 @@ public class SystemHooksApi extends AbstractApi {
GitLabApiForm
formData
=
new
GitLabApiForm
()
GitLabApiForm
formData
=
new
GitLabApiForm
()
.
withParam
(
"url"
,
url
,
true
)
.
withParam
(
"url"
,
url
,
true
)
.
withParam
(
"token"
,
token
)
.
withParam
(
"token"
,
token
)
.
withParam
(
"push_events"
,
pushEvents
)
.
withParam
(
"push_events"
,
systemHook
.
getPushEvents
())
.
withParam
(
"tag_push_events"
,
tagPushEvents
)
.
withParam
(
"tag_push_events"
,
systemHook
.
getTagPushEvents
())
.
withParam
(
"enable_ssl_verification"
,
enablSsslVerification
);
.
withParam
(
"merge_requests_events"
,
systemHook
.
getMergeRequestsEvents
())
.
withParam
(
"repository_update_events"
,
systemHook
.
getRepositoryUpdateEvents
())
.
withParam
(
"enable_ssl_verification"
,
systemHook
.
getEnableSslVerification
());
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"hooks"
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"hooks"
);
return
(
response
.
readEntity
(
SystemHook
.
class
));
return
(
response
.
readEntity
(
SystemHook
.
class
));
}
}
...
...
src/main/java/org/gitlab4j/api/UserApi.java
View file @
48804220
...
@@ -17,6 +17,7 @@ import org.gitlab4j.api.models.Email;
...
@@ -17,6 +17,7 @@ import org.gitlab4j.api.models.Email;
import
org.gitlab4j.api.models.GpgKey
;
import
org.gitlab4j.api.models.GpgKey
;
import
org.gitlab4j.api.models.ImpersonationToken
;
import
org.gitlab4j.api.models.ImpersonationToken
;
import
org.gitlab4j.api.models.ImpersonationToken.Scope
;
import
org.gitlab4j.api.models.ImpersonationToken.Scope
;
import
org.gitlab4j.api.models.Membership
;
import
org.gitlab4j.api.models.SshKey
;
import
org.gitlab4j.api.models.SshKey
;
import
org.gitlab4j.api.models.User
;
import
org.gitlab4j.api.models.User
;
import
org.gitlab4j.api.utils.EmailChecker
;
import
org.gitlab4j.api.utils.EmailChecker
;
...
@@ -512,6 +513,7 @@ public class UserApi extends AbstractApi {
...
@@ -512,6 +513,7 @@ public class UserApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
* @deprecated Will be removed in version 5.0, replaced by {@link #createUser(User, CharSequence, boolean)}
* @deprecated Will be removed in version 5.0, replaced by {@link #createUser(User, CharSequence, boolean)}
*/
*/
@Deprecated
public
User
createUser
(
User
user
,
CharSequence
password
,
Integer
projectsLimit
)
throws
GitLabApiException
{
public
User
createUser
(
User
user
,
CharSequence
password
,
Integer
projectsLimit
)
throws
GitLabApiException
{
Form
formData
=
userToForm
(
user
,
projectsLimit
,
password
,
null
,
true
);
Form
formData
=
userToForm
(
user
,
projectsLimit
,
password
,
null
,
true
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"users"
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"users"
);
...
@@ -1293,4 +1295,20 @@ public class UserApi extends AbstractApi {
...
@@ -1293,4 +1295,20 @@ public class UserApi extends AbstractApi {
public
void
deleteGpgKey
(
final
Integer
userId
,
final
Integer
keyId
)
throws
GitLabApiException
{
public
void
deleteGpgKey
(
final
Integer
userId
,
final
Integer
keyId
)
throws
GitLabApiException
{
delete
(
Response
.
Status
.
NO_CONTENT
,
null
,
"users"
,
userId
,
"gpg_keys"
,
keyId
);
delete
(
Response
.
Status
.
NO_CONTENT
,
null
,
"users"
,
userId
,
"gpg_keys"
,
keyId
);
}
}
/**
* Lists all projects and groups a user is a member of. (admin only)
*
* <pre><code>GitLab Endpoint: GET /users/:id/memberships</code></pre>
*
* @param userId the ID of the user to get the memberships for
* @return the list of memberships of the given user
* @throws GitLabApiException if any exception occurs
* @since GitLab 12.8
*/
public
List
<
Membership
>
getMemberships
(
Integer
userId
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
new
GitLabApiForm
();
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"users"
,
userId
,
"memberships"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Membership
>>()
{}));
}
}
}
src/main/java/org/gitlab4j/api/models/Branch.java
View file @
48804220
...
@@ -11,6 +11,9 @@ public class Branch {
...
@@ -11,6 +11,9 @@ public class Branch {
private
Boolean
merged
;
private
Boolean
merged
;
private
String
name
;
private
String
name
;
private
Boolean
isProtected
;
private
Boolean
isProtected
;
private
Boolean
isDefault
;
private
Boolean
canPush
;
private
String
webUrl
;
public
Commit
getCommit
()
{
public
Commit
getCommit
()
{
return
commit
;
return
commit
;
...
@@ -60,6 +63,30 @@ public class Branch {
...
@@ -60,6 +63,30 @@ public class Branch {
this
.
isProtected
=
isProtected
;
this
.
isProtected
=
isProtected
;
}
}
public
Boolean
getDefault
()
{
return
isDefault
;
}
public
void
setDefault
(
Boolean
isDefault
)
{
this
.
isDefault
=
isDefault
;
}
public
Boolean
getCanPush
()
{
return
canPush
;
}
public
void
setCanPush
(
Boolean
canPush
)
{
this
.
canPush
=
canPush
;
}
public
String
getWebUrl
()
{
return
webUrl
;
}
public
void
setWebUrl
(
String
webUrl
)
{
this
.
webUrl
=
webUrl
;
}
public
static
final
boolean
isValid
(
Branch
branch
)
{
public
static
final
boolean
isValid
(
Branch
branch
)
{
return
(
branch
!=
null
&&
branch
.
getName
()
!=
null
);
return
(
branch
!=
null
&&
branch
.
getName
()
!=
null
);
}
}
...
@@ -80,11 +107,23 @@ public class Branch {
...
@@ -80,11 +107,23 @@ public class Branch {
return
this
;
return
this
;
}
}
/**
* Set the merged attribute
* @param merged
* @deprecated Use {@link #withMerged(Boolean)} instead
* @return Current branch instance
*/
@Deprecated
public
Branch
withDerged
(
Boolean
merged
)
{
public
Branch
withDerged
(
Boolean
merged
)
{
this
.
merged
=
merged
;
this
.
merged
=
merged
;
return
this
;
return
this
;
}
}
public
Branch
withMerged
(
Boolean
merged
)
{
this
.
merged
=
merged
;
return
this
;
}
public
Branch
withName
(
String
name
)
{
public
Branch
withName
(
String
name
)
{
this
.
name
=
name
;
this
.
name
=
name
;
return
this
;
return
this
;
...
...
src/main/java/org/gitlab4j/api/models/ChangelogPayload.java
0 → 100644
View file @
48804220
package
org.gitlab4j.api.models
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
org.gitlab4j.api.GitLabApiForm
;
import
org.gitlab4j.api.utils.ISO8601
;
import
org.gitlab4j.api.utils.JacksonJson
;
import
java.util.Date
;
public
class
ChangelogPayload
{
private
String
version
;
private
String
from
;
private
String
to
;
private
Date
date
;
private
String
branch
;
private
String
trailer
;
private
String
file
;
private
String
message
;
public
ChangelogPayload
(
String
version
)
{
this
.
version
=
version
;
}
@JsonIgnore
public
GitLabApiForm
getFormData
()
{
return
new
GitLabApiForm
()
.
withParam
(
"version"
,
version
,
true
)
.
withParam
(
"from"
,
from
)
.
withParam
(
"to"
,
to
)
.
withParam
(
"date"
,
ISO8601
.
dateOnly
(
date
))
.
withParam
(
"branch"
,
branch
)
.
withParam
(
"trailer"
,
trailer
)
.
withParam
(
"file"
,
file
)
.
withParam
(
"message"
,
message
);
}
public
String
getVersion
()
{
return
version
;
}
public
void
setVersion
(
String
version
)
{
this
.
version
=
version
;
}
public
String
getFrom
()
{
return
from
;
}
public
void
setFrom
(
String
from
)
{
this
.
from
=
from
;
}
public
String
getTo
()
{
return
to
;
}
public
void
setTo
(
String
to
)
{
this
.
to
=
to
;
}
public
Date
getDate
()
{
return
date
;
}
public
void
setDate
(
Date
date
)
{
this
.
date
=
date
;
}
public
String
getBranch
()
{
return
branch
;
}
public
void
setBranch
(
String
branch
)
{
this
.
branch
=
branch
;
}
public
String
getTrailer
()
{
return
trailer
;
}
public
void
setTrailer
(
String
trailer
)
{
this
.
trailer
=
trailer
;
}
public
String
getFile
()
{
return
file
;
}
public
void
setFile
(
String
file
)
{
this
.
file
=
file
;
}
public
String
getMessage
()
{
return
message
;
}
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
@Override
public
String
toString
()
{
return
(
JacksonJson
.
toJsonString
(
this
));
}
}
src/main/java/org/gitlab4j/api/models/DeploymentFilter.java
0 → 100644
View file @
48804220
package
org.gitlab4j.api.models
;
import
java.util.Date
;
import
org.gitlab4j.api.Constants
;
import
org.gitlab4j.api.GitLabApiForm
;
import
org.gitlab4j.api.Constants.DeploymentOrderBy
;
import
org.gitlab4j.api.Constants.DeploymentStatus
;
import
org.gitlab4j.api.Constants.SortOrder
;
import
org.gitlab4j.api.utils.ISO8601
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
public
class
DeploymentFilter
{
/**
* Return deployments ordered by either one of id, iid, created_at, updated_at or ref fields. Default is id.
*/
private
DeploymentOrderBy
orderBy
;
/**
* Return deployments sorted in asc or desc order. Default is asc.
*/
private
SortOrder
sortOrder
;
/**
* Return deployments updated after the specified date. Expected in ISO 8601 format (2019-03-15T08:00:00Z).
*/
private
Date
finishedAfter
;
/**
* Return deployments updated before the specified date. Expected in ISO 8601 format (2019-03-15T08:00:00Z).
*/
private
Date
finishedBefore
;
/**
* The name of the environment to filter deployments by.
*/
private
String
environment
;
/**
* The status to filter deployments by.
*/
private
DeploymentStatus
status
;
public
DeploymentOrderBy
getOrderBy
()
{
return
orderBy
;
}
public
void
setOrderBy
(
DeploymentOrderBy
orderBy
)
{
this
.
orderBy
=
orderBy
;
}
public
SortOrder
getSortOrder
()
{
return
sortOrder
;
}
public
void
setSortOrder
(
SortOrder
sortOrder
)
{
this
.
sortOrder
=
sortOrder
;
}
public
Date
getFinishedAfter
()
{
return
finishedAfter
;
}
public
void
setFinishedAfter
(
Date
finishedAfter
)
{
this
.
finishedAfter
=
finishedAfter
;
}
public
Date
getFinishedBefore
()
{
return
finishedBefore
;
}
public
void
setFinishedBefore
(
Date
finishedBefore
)
{
this
.
finishedBefore
=
finishedBefore
;
}
public
String
getEnvironment
()
{
return
environment
;
}
public
void
setEnvironment
(
String
environment
)
{
this
.
environment
=
environment
;
}
public
DeploymentStatus
getStatus
()
{
return
status
;
}
public
void
setStatus
(
DeploymentStatus
status
)
{
this
.
status
=
status
;
}
public
DeploymentFilter
withOrderBy
(
DeploymentOrderBy
orderBy
)
{
this
.
orderBy
=
orderBy
;
return
(
this
);
}
public
DeploymentFilter
withSortOrder
(
SortOrder
sortOrder
)
{
this
.
sortOrder
=
sortOrder
;
return
(
this
);
}
public
DeploymentFilter
withFinishedAfter
(
Date
finishedAfter
)
{
this
.
finishedAfter
=
finishedAfter
;
return
(
this
);
}
public
DeploymentFilter
withFinishedBefore
(
Date
finishedBefore
)
{
this
.
finishedBefore
=
finishedBefore
;
return
(
this
);
}
public
DeploymentFilter
withEnvironment
(
String
environment
)
{
this
.
environment
=
environment
;
return
(
this
);
}
public
DeploymentFilter
withStatus
(
DeploymentStatus
status
)
{
this
.
status
=
status
;
return
(
this
);
}
@JsonIgnore
public
GitLabApiForm
getQueryParams
(
int
page
,
int
perPage
)
{
return
(
getQueryParams
()
.
withParam
(
Constants
.
PAGE_PARAM
,
page
)
.
withParam
(
Constants
.
PER_PAGE_PARAM
,
perPage
));
}
@JsonIgnore
public
GitLabApiForm
getQueryParams
()
{
return
(
new
GitLabApiForm
()
.
withParam
(
"order_by"
,
orderBy
)
.
withParam
(
"sort"
,
sortOrder
)
.
withParam
(
"finished_after"
,
ISO8601
.
toString
(
finishedAfter
,
false
))
.
withParam
(
"finished_before"
,
ISO8601
.
toString
(
finishedBefore
,
false
))
.
withParam
(
"environment"
,
environment
)
.
withParam
(
"status"
,
status
));
}
}
src/main/java/org/gitlab4j/api/models/Membership.java
0 → 100644
View file @
48804220
package
org.gitlab4j.api.models
;
import
org.gitlab4j.api.utils.JacksonJson
;
public
class
Membership
{
private
Integer
sourceId
;
private
String
sourceName
;
private
MembershipSourceType
sourceType
;
private
AccessLevel
accessLevel
;
public
Integer
getSourceId
()
{
return
sourceId
;
}
public
void
setSourceId
(
Integer
sourceId
)
{
this
.
sourceId
=
sourceId
;
}
public
String
getSourceName
()
{
return
sourceName
;
}
public
void
setSourceName
(
String
sourceName
)
{
this
.
sourceName
=
sourceName
;
}
public
MembershipSourceType
getSourceType
()
{
return
sourceType
;
}
public
void
setSourceType
(
MembershipSourceType
sourceType
)
{
this
.
sourceType
=
sourceType
;
}
public
AccessLevel
getAccessLevel
()
{
return
accessLevel
;
}
public
void
setAccessLevel
(
AccessLevel
accessLevel
)
{
this
.
accessLevel
=
accessLevel
;
}
@Override
public
String
toString
()
{
return
(
JacksonJson
.
toJsonString
(
this
));
}
}
Prev
1
2
3
Next
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