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
b1f9763e
Commit
b1f9763e
authored
Sep 23, 2017
by
Greg Messner
Browse files
Added overloaded time duration related methods.
parent
fd0b8825
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/IssuesApi.java
View file @
b1f9763e
...
@@ -30,11 +30,12 @@ import javax.ws.rs.core.GenericType;
...
@@ -30,11 +30,12 @@ import javax.ws.rs.core.GenericType;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response
;
import
org.gitlab4j.api.GitLabApi.ApiVersion
;
import
org.gitlab4j.api.GitLabApi.ApiVersion
;
import
org.gitlab4j.api.models.Duration
;
import
org.gitlab4j.api.models.Issue
;
import
org.gitlab4j.api.models.Issue
;
import
org.gitlab4j.api.models.TimeStats
;
import
org.gitlab4j.api.models.TimeStats
;
/**
/**
* This class provides an entry point to all the GitLab API
project
calls.
* This class provides an entry point to all the GitLab API
Issue
calls.
*/
*/
public
class
IssuesApi
extends
AbstractApi
implements
Constants
{
public
class
IssuesApi
extends
AbstractApi
implements
Constants
{
...
@@ -294,19 +295,50 @@ public class IssuesApi extends AbstractApi implements Constants {
...
@@ -294,19 +295,50 @@ public class IssuesApi extends AbstractApi implements Constants {
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
,
getDefaultPerPageParam
(),
"projects"
,
projectId
,
"issues"
,
issueIid
);
delete
(
expectedStatus
,
getDefaultPerPageParam
(),
"projects"
,
projectId
,
"issues"
,
issueIid
);
}
}
/**
/**
* Sets an estimated time of work in this issue
* Sets an estimated time of work in this issue
*
*
* POST /projects/:id/issues/:issue_iid/time_estimate
* POST /projects/:id/issues/:issue_iid/time_estimate
*
*
* @param projectId the project ID to delete the issue from
* @param projectId the project ID that owns the issue
* @param issueIid the internal ID of a project's issue
* @param duration estimated time in seconds
* @return a TimeSTats instance
* @throws GitLabApiException if any exception occurs
*/
public
TimeStats
estimateTime
(
Integer
projectId
,
Integer
issueIid
,
int
duration
)
throws
GitLabApiException
{
return
(
estimateTime
(
projectId
,
issueIid
,
new
Duration
(
duration
)));
}
/**
* Sets an estimated time of work in this issue
*
* POST /projects/:id/issues/:issue_iid/time_estimate
*
* @param projectId the project ID that owns the issue
* @param issueIid the internal ID of a project's issue
* @param issueIid the internal ID of a project's issue
* @param duration Human readable format, e.g. 3h30m
* @param duration Human readable format, e.g. 3h30m
* @return a TimeSTats instance
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
TimeStats
estimateTime
(
Integer
projectId
,
Integer
issueIid
,
String
duration
)
throws
GitLabApiException
{
public
TimeStats
estimateTime
(
Integer
projectId
,
Integer
issueIid
,
String
duration
)
throws
GitLabApiException
{
return
(
estimateTime
(
projectId
,
issueIid
,
new
Duration
(
duration
)));
}
/**
* Sets an estimated time of work in this issue
*
* POST /projects/:id/issues/:issue_iid/time_estimate
*
* @param projectId the project ID that owns the issue
* @param issueIid the internal ID of a project's issue
* @param duration set the estimate of time to this duration
* @return a TimeSTats instance
* @throws GitLabApiException if any exception occurs
*/
public
TimeStats
estimateTime
(
Integer
projectId
,
Integer
issueIid
,
Duration
duration
)
throws
GitLabApiException
{
if
(
projectId
==
null
)
{
if
(
projectId
==
null
)
{
throw
new
RuntimeException
(
"projectId cannot be null"
);
throw
new
RuntimeException
(
"projectId cannot be null"
);
}
}
...
@@ -314,25 +346,25 @@ public class IssuesApi extends AbstractApi implements Constants {
...
@@ -314,25 +346,25 @@ public class IssuesApi extends AbstractApi implements Constants {
if
(
issueIid
==
null
)
{
if
(
issueIid
==
null
)
{
throw
new
RuntimeException
(
"issue IID cannot be null"
);
throw
new
RuntimeException
(
"issue IID cannot be null"
);
}
}
GitLabApiForm
formData
=
new
GitLabApiForm
()
GitLabApiForm
formData
=
new
GitLabApiForm
().
withParam
(
"duration"
,
duration
,
true
);
.
withParam
(
"duration"
,
duration
,
true
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
.
asMap
(),
"projects"
,
projectId
,
"issues"
,
issueIid
,
"time_estimate"
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
.
asMap
(),
"projects"
,
projectId
,
"issues"
,
issueIid
,
"time_estimate"
);
return
(
response
.
readEntity
(
TimeStats
.
class
));
return
(
response
.
readEntity
(
TimeStats
.
class
));
}
}
/**
/**
* Resets the estimated time for this issue to 0 seconds.
* Resets the estimated time for this issue to 0 seconds.
*
*
* POST /projects/:id/issues/:issue_iid/reset_time_estimate
* POST /projects/:id/issues/:issue_iid/reset_time_estimate
*
*
* @param projectId the project ID t
o delete
the issue
from
* @param projectId the project ID t
hat owns
the issue
* @param issueIid the internal ID of a project's issue
* @param issueIid the internal ID of a project's issue
* @return a TimeSTats instance
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
TimeStats
resetEstimatedTime
(
Integer
projectId
,
Integer
issueIid
)
throws
GitLabApiException
{
public
TimeStats
resetEstimatedTime
(
Integer
projectId
,
Integer
issueIid
)
throws
GitLabApiException
{
if
(
projectId
==
null
)
{
if
(
projectId
==
null
)
{
throw
new
RuntimeException
(
"projectId cannot be null"
);
throw
new
RuntimeException
(
"projectId cannot be null"
);
}
}
...
@@ -340,11 +372,26 @@ public class IssuesApi extends AbstractApi implements Constants {
...
@@ -340,11 +372,26 @@ public class IssuesApi extends AbstractApi implements Constants {
if
(
issueIid
==
null
)
{
if
(
issueIid
==
null
)
{
throw
new
RuntimeException
(
"issue IID cannot be null"
);
throw
new
RuntimeException
(
"issue IID cannot be null"
);
}
}
Response
response
=
post
(
Response
.
Status
.
OK
,
new
GitLabApiForm
().
asMap
(),
"projects"
,
projectId
,
"issues"
,
issueIid
,
"reset_time_estimate"
);
Response
response
=
post
(
Response
.
Status
.
OK
,
new
GitLabApiForm
().
asMap
(),
"projects"
,
projectId
,
"issues"
,
issueIid
,
"reset_time_estimate"
);
return
(
response
.
readEntity
(
TimeStats
.
class
));
return
(
response
.
readEntity
(
TimeStats
.
class
));
}
}
/**
* Adds spent time for this issue
*
* POST /projects/:id/issues/:issue_iid/add_spent_time
*
* @param projectId the project ID that owns the issue
* @param issueIid the internal ID of a project's issue
* @param duration the duration in seconds
* @return a TimeSTats instance
* @throws GitLabApiException if any exception occurs
*/
public
TimeStats
addSpentTime
(
Integer
projectId
,
Integer
issueIid
,
int
duration
)
throws
GitLabApiException
{
return
(
addSpentTime
(
projectId
,
issueIid
,
new
Duration
(
duration
)));
}
/**
/**
* Adds spent time for this issue
* Adds spent time for this issue
*
*
...
@@ -353,10 +400,26 @@ public class IssuesApi extends AbstractApi implements Constants {
...
@@ -353,10 +400,26 @@ public class IssuesApi extends AbstractApi implements Constants {
* @param projectId the project ID to delete the issue from
* @param projectId the project ID to delete the issue from
* @param issueIid the internal ID of a project's issue
* @param issueIid the internal ID of a project's issue
* @param duration Human readable format, e.g. 3h30m
* @param duration Human readable format, e.g. 3h30m
* @return a TimeSTats instance
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
TimeStats
addSpentTime
(
Integer
projectId
,
Integer
issueIid
,
String
duration
)
throws
GitLabApiException
{
public
TimeStats
addSpentTime
(
Integer
projectId
,
Integer
issueIid
,
String
duration
)
throws
GitLabApiException
{
return
(
addSpentTime
(
projectId
,
issueIid
,
new
Duration
(
duration
)));
}
/**
* Adds spent time for this issue
*
* POST /projects/:id/issues/:issue_iid/add_spent_time
*
* @param projectId the project ID to delete the issue from
* @param issueIid the internal ID of a project's issue
* @param duration the duration of time spent
* @return a TimeSTats instance
* @throws GitLabApiException if any exception occurs
*/
public
TimeStats
addSpentTime
(
Integer
projectId
,
Integer
issueIid
,
Duration
duration
)
throws
GitLabApiException
{
if
(
projectId
==
null
)
{
if
(
projectId
==
null
)
{
throw
new
RuntimeException
(
"projectId cannot be null"
);
throw
new
RuntimeException
(
"projectId cannot be null"
);
}
}
...
@@ -364,25 +427,25 @@ public class IssuesApi extends AbstractApi implements Constants {
...
@@ -364,25 +427,25 @@ public class IssuesApi extends AbstractApi implements Constants {
if
(
issueIid
==
null
)
{
if
(
issueIid
==
null
)
{
throw
new
RuntimeException
(
"issue IID cannot be null"
);
throw
new
RuntimeException
(
"issue IID cannot be null"
);
}
}
GitLabApiForm
formData
=
new
GitLabApiForm
()
GitLabApiForm
formData
=
new
GitLabApiForm
().
withParam
(
"duration"
,
duration
,
true
);
.
withParam
(
"duration"
,
duration
,
true
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
.
asMap
(),
"projects"
,
projectId
,
"issues"
,
issueIid
,
"add_spent_time"
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
.
asMap
(),
"projects"
,
projectId
,
"issues"
,
issueIid
,
"add_spent_time"
);
return
(
response
.
readEntity
(
TimeStats
.
class
));
return
(
response
.
readEntity
(
TimeStats
.
class
));
}
}
/**
/**
* Resets the total spent time for this issue to 0 seconds.
* Resets the total spent time for this issue to 0 seconds.
*
*
* POST /projects/:id/issues/:issue_iid/reset_spent_time
* POST /projects/:id/issues/:issue_iid/reset_spent_time
*
*
* @param projectId
* @param projectId the project ID that owns the issue
* @param issueIId
* @param issueIid the internal ID of a project's issue
* @throws GitLabApiException
* @return a TimeSTats instance
* @throws GitLabApiException if any exception occurs
*/
*/
public
TimeStats
resetSpentTime
(
Integer
projectId
,
Integer
issueIid
)
throws
GitLabApiException
{
public
TimeStats
resetSpentTime
(
Integer
projectId
,
Integer
issueIid
)
throws
GitLabApiException
{
if
(
projectId
==
null
)
{
if
(
projectId
==
null
)
{
throw
new
RuntimeException
(
"projectId cannot be null"
);
throw
new
RuntimeException
(
"projectId cannot be null"
);
}
}
...
@@ -390,22 +453,24 @@ public class IssuesApi extends AbstractApi implements Constants {
...
@@ -390,22 +453,24 @@ public class IssuesApi extends AbstractApi implements Constants {
if
(
issueIid
==
null
)
{
if
(
issueIid
==
null
)
{
throw
new
RuntimeException
(
"issue IID cannot be null"
);
throw
new
RuntimeException
(
"issue IID cannot be null"
);
}
}
Response
response
=
post
(
Response
.
Status
.
OK
,
new
GitLabApiForm
().
asMap
(),
"projects"
,
projectId
,
"issues"
,
issueIid
,
"reset_spent_time"
);
Response
response
=
post
(
Response
.
Status
.
OK
,
new
GitLabApiForm
().
asMap
(),
"projects"
,
projectId
,
"issues"
,
issueIid
,
"reset_spent_time"
);
return
(
response
.
readEntity
(
TimeStats
.
class
));
return
(
response
.
readEntity
(
TimeStats
.
class
));
}
}
/**
/**
* Get time tracking stats
* Get time tracking stats
*
*
* GET /projects/:id/issues/:issue_iid/time_stats
* GET /projects/:id/issues/:issue_iid/time_stats
*
*
* @param projectId
* @param projectId the project ID that owns the issue
* @param issueIId
* @param issueIid the internal ID of a project's issue
* @throws GitLabApiException
* @return a TimeSTats instance
* @throws GitLabApiException if any exception occurs
*/
*/
public
TimeStats
getTimeTrackingStats
(
Integer
projectId
,
Integer
issueIid
)
throws
GitLabApiException
{
public
TimeStats
getTimeTrackingStats
(
Integer
projectId
,
Integer
issueIid
)
throws
GitLabApiException
{
if
(
projectId
==
null
)
{
if
(
projectId
==
null
)
{
throw
new
RuntimeException
(
"projectId cannot be null"
);
throw
new
RuntimeException
(
"projectId cannot be null"
);
}
}
...
...
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