Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
java-gitlab-api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
沈俊林
java-gitlab-api
Commits
33b7b6d3
Commit
33b7b6d3
authored
Nov 11, 2015
by
Tim Olshansky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #94 from mpatkisson/milestones_post_put_support
Adds create / edit support for milestones
parents
1ae3f82a
53795e65
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
127 additions
and
0 deletions
+127
-0
GitlabAPI.java
src/main/java/org/gitlab/api/GitlabAPI.java
+122
-0
GitlabMilestone.java
src/main/java/org/gitlab/api/models/GitlabMilestone.java
+5
-0
No files found.
src/main/java/org/gitlab/api/GitlabAPI.java
View file @
33b7b6d3
...
@@ -12,7 +12,9 @@ import java.io.Serializable;
...
@@ -12,7 +12,9 @@ import java.io.Serializable;
import
java.io.UnsupportedEncodingException
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URL
;
import
java.net.URL
;
import
java.net.URLEncoder
;
import
java.net.URLEncoder
;
import
java.text.SimpleDateFormat
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
...
@@ -1067,6 +1069,126 @@ public class GitlabAPI {
...
@@ -1067,6 +1069,126 @@ public class GitlabAPI {
return
Arrays
.
asList
(
retrieve
().
to
(
tailUrl
,
GitlabMilestone
[].
class
));
return
Arrays
.
asList
(
retrieve
().
to
(
tailUrl
,
GitlabMilestone
[].
class
));
}
}
/**
* Cretaes a new project milestone.
* @param projectId The ID of the project.
* @param title The title of the milestone.
* @param description The description of the milestone. (Optional)
* @param dueDate The date the milestone is due. (Optional)
* @return The newly created, de-serialized milestone.
* @throws IOException
*/
public
GitlabMilestone
createMilestone
(
Serializable
projectId
,
String
title
,
String
description
,
Date
dueDate
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
projectId
+
GitlabMilestone
.
URL
;
GitlabHTTPRequestor
requestor
=
dispatch
().
with
(
"title"
,
title
);
if
(
description
!=
null
)
{
requestor
=
requestor
.
with
(
"description"
,
description
);
}
if
(
dueDate
!=
null
)
{
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
formatted
=
formatter
.
format
(
dueDate
);
requestor
=
requestor
.
with
(
"due_date"
,
formatted
);
}
return
requestor
.
to
(
tailUrl
,
GitlabMilestone
.
class
);
}
/**
* Creates a new project milestone.
* @param projectId The ID of the project.
* @param milestone The milestone to create.
* @return The newly created, de-serialized milestone.
* @throws IOException
*/
public
GitlabMilestone
createMilestone
(
Serializable
projectId
,
GitlabMilestone
milestone
)
throws
IOException
{
String
title
=
milestone
.
getTitle
();
String
description
=
milestone
.
getDescription
();
Date
dateDue
=
milestone
.
getDueDate
();
return
createMilestone
(
projectId
,
title
,
description
,
dateDue
);
}
/**
* Updates an existing project milestone.
* @param projectId The ID of the project.
* @param milestoneId The ID of the milestone.
* @param title The title of the milestone. (Optional)
* @param description The description of the milestone. (Optional)
* @param dueDate The date the milestone is due. (Optional)
* @param stateEvent A value used to update the state of the milestone.
* (Optional) (activate | close)
* @return The updated, de-serialized milestone.
* @throws IOException
*/
public
GitlabMilestone
updateMilestone
(
Serializable
projectId
,
int
milestoneId
,
String
title
,
String
description
,
Date
dueDate
,
String
stateEvent
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
projectId
+
GitlabMilestone
.
URL
+
"/"
+
milestoneId
;
GitlabHTTPRequestor
requestor
=
retrieve
().
method
(
"PUT"
);
if
(
title
!=
null
)
{
requestor
.
with
(
"title"
,
title
);
}
if
(
description
!=
null
)
{
requestor
=
requestor
.
with
(
"description"
,
description
);
}
if
(
dueDate
!=
null
)
{
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
formatted
=
formatter
.
format
(
dueDate
);
requestor
=
requestor
.
with
(
"due_date"
,
formatted
);
}
if
(
stateEvent
!=
null
)
{
requestor
.
with
(
"state_event"
,
stateEvent
);
}
return
requestor
.
to
(
tailUrl
,
GitlabMilestone
.
class
);
}
/**
* Updates an existing project milestone.
* @param projectId The ID of the project.
* @param edited The already edited milestone.
* @param stateEvent A value used to update the state of the milestone.
* (Optional) (activate | close)
* @return The updated, de-serialized milestone.
* @throws IOException
*/
public
GitlabMilestone
updateMilestone
(
Serializable
projectId
,
GitlabMilestone
edited
,
String
stateEvent
)
throws
IOException
{
return
updateMilestone
(
projectId
,
edited
.
getId
(),
edited
.
getTitle
(),
edited
.
getDescription
(),
edited
.
getDueDate
(),
stateEvent
);
}
/**
* Updates an existing project milestone.
* @param edited The already edited milestone.
* @return The updated, de-serialized milestone.
* @param stateEvent A value used to update the state of the milestone.
* (Optional) (activate | close)
* @throws IOException
*/
public
GitlabMilestone
updateMilestone
(
GitlabMilestone
edited
,
String
stateEvent
)
throws
IOException
{
return
updateMilestone
(
edited
.
getProjectId
(),
edited
,
stateEvent
);
}
/**
/**
* Add a project member.
* Add a project member.
*
*
...
...
src/main/java/org/gitlab/api/models/GitlabMilestone.java
View file @
33b7b6d3
...
@@ -9,9 +9,14 @@ public class GitlabMilestone {
...
@@ -9,9 +9,14 @@ public class GitlabMilestone {
public
static
final
String
URL
=
"/milestones"
;
public
static
final
String
URL
=
"/milestones"
;
private
int
id
;
private
int
id
;
private
int
iid
;
private
int
iid
;
@JsonProperty
(
"project_id"
)
private
int
projectId
;
private
int
projectId
;
private
String
title
;
private
String
title
;
private
String
description
;
private
String
description
;
@JsonProperty
(
"due_date"
)
@JsonProperty
(
"due_date"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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