diff --git a/TechTalk.JiraRestClient/Compatibility.cs b/TechTalk.JiraRestClient/Compatibility.cs
index 9089172..79254a4 100644
--- a/TechTalk.JiraRestClient/Compatibility.cs
+++ b/TechTalk.JiraRestClient/Compatibility.cs
@@ -7,6 +7,9 @@ namespace TechTalk.JiraRestClient
{
public interface IJiraClient
{
+ /// Returns a list of projects
+ IEnumerable GetProjects();
+
/// Returns all issues for the given project
IEnumerable GetIssues(String projectKey);
/// Returns all issues of the specified type for the given project
@@ -76,6 +79,11 @@ public interface IJiraClient
/// Removes the given remote link (attached url) of the specified issue
void DeleteRemoteLink(IssueRef issue, RemoteLink remoteLink);
+ /// Returns worklogs id and update time of worklogs that was updated since given time.
+ WorklogUpdated GetWorklogUpdated(DateTime since);
+ /// Returns worklogs for given worklog ids
+ IEnumerable GetWorklogList(int[] ids);
+
/// Returns all issue types
IEnumerable GetIssueTypes();
@@ -91,6 +99,11 @@ public JiraClient(string baseUrl, string username, string password)
client = new JiraClient(baseUrl, username, password);
}
+ public IEnumerable GetProjects()
+ {
+ return client.GetProjects();
+ }
+
public IEnumerable GetIssues(String projectKey)
{
return client.GetIssues(projectKey).Select(Issue.From).ToArray();
@@ -238,6 +251,16 @@ public void DeleteRemoteLink(IssueRef issue, RemoteLink remoteLink)
client.DeleteRemoteLink(issue, remoteLink);
}
+ public WorklogUpdated GetWorklogUpdated(DateTime since)
+ {
+ return client.GetWorklogUpdated(since);
+ }
+
+ public IEnumerable GetWorklogList(int[] ids)
+ {
+ return client.GetWorklogList(ids);
+ }
+
public IEnumerable GetIssueTypes()
{
return client.GetIssueTypes();
diff --git a/TechTalk.JiraRestClient/IJiraClient.cs b/TechTalk.JiraRestClient/IJiraClient.cs
index 5205faa..4b3a090 100644
--- a/TechTalk.JiraRestClient/IJiraClient.cs
+++ b/TechTalk.JiraRestClient/IJiraClient.cs
@@ -7,6 +7,9 @@ namespace TechTalk.JiraRestClient
{
public interface IJiraClient where TIssueFields : IssueFields, new()
{
+ /// Returns a list of projects
+ IEnumerable GetProjects();
+
/// Returns all issues for the given project
IEnumerable> GetIssues(String projectKey);
/// Returns all issues of the specified type for the given project
@@ -80,6 +83,11 @@ namespace TechTalk.JiraRestClient
/// Removes the given remote link (attached url) of the specified issue
void DeleteRemoteLink(IssueRef issue, RemoteLink remoteLink);
+ /// Returns worklogs id and update time of worklogs that was updated since given time
+ WorklogUpdated GetWorklogUpdated(DateTime since);
+ /// Returns worklogs for given worklog ids
+ IEnumerable GetWorklogList(int[] ids);
+
/// Returns all issue types
IEnumerable GetIssueTypes();
diff --git a/TechTalk.JiraRestClient/IssueFields.cs b/TechTalk.JiraRestClient/IssueFields.cs
index 1790e6a..0e0b034 100644
--- a/TechTalk.JiraRestClient/IssueFields.cs
+++ b/TechTalk.JiraRestClient/IssueFields.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Runtime.Remoting.Messaging;
namespace TechTalk.JiraRestClient
{
@@ -10,6 +11,9 @@ public IssueFields()
status = new Status();
timetracking = new Timetracking();
+ project = new Project();
+ issuetype = new IssueType();
+
labels = new List();
comments = new List();
issuelinks = new List();
@@ -19,6 +23,8 @@ public IssueFields()
public String summary { get; set; }
public String description { get; set; }
+ public Project project { get; set; }
+ public IssueType issuetype { get; set; }
public Timetracking timetracking { get; set; }
public Status status { get; set; }
diff --git a/TechTalk.JiraRestClient/JiraClient.cs b/TechTalk.JiraRestClient/JiraClient.cs
index 42fc27e..1fc6bbf 100644
--- a/TechTalk.JiraRestClient/JiraClient.cs
+++ b/TechTalk.JiraRestClient/JiraClient.cs
@@ -7,6 +7,7 @@
using System.Text;
using RestSharp;
using RestSharp.Deserializers;
+using TechTalk.JiraRestClient.Utils;
namespace TechTalk.JiraRestClient
{
@@ -49,6 +50,26 @@ private void AssertStatus(IRestResponse response, HttpStatusCode status)
}
+ public IEnumerable GetProjects()
+ {
+ try
+ {
+ var request = CreateRequest(Method.GET, "project");
+ request.AddHeader("ContentType", "application/json");
+
+ var response = ExecuteRequest(request);
+ AssertStatus(response, HttpStatusCode.OK);
+
+ var data = deserializer.Deserialize>(response);
+ return data;
+ }
+ catch (Exception ex)
+ {
+ Trace.TraceError("GetProjects() error: {0}", ex);
+ throw new JiraClientException("Could not load projects", ex);
+ }
+ }
+
public IEnumerable> GetIssues(String projectKey)
{
return EnumerateIssues(projectKey, null).ToArray();
@@ -616,6 +637,49 @@ public void DeleteRemoteLink(IssueRef issue, RemoteLink remoteLink)
}
}
+ public WorklogUpdated GetWorklogUpdated(DateTime since)
+ {
+ try
+ {
+ var unixSince = TimeUtils.ToUnixTime(since);
+ var path = string.Format("worklog/updated?since={0}", unixSince);
+ var request = CreateRequest(Method.GET, path);
+ request.AddHeader("ContentType", "application/json");
+
+ var response = ExecuteRequest(request);
+ AssertStatus(response, HttpStatusCode.OK);
+
+ var data = deserializer.Deserialize(response);
+ return data;
+ }
+ catch (Exception ex)
+ {
+ Trace.TraceError("GetWorklogUpdated() error: {0}", ex);
+ throw new JiraClientException("Could not load worklog updated", ex);
+ }
+ }
+
+ public IEnumerable GetWorklogList(int[] ids)
+ {
+ try
+ {
+ var request = CreateRequest(Method.POST, "worklog/list");
+ request.AddHeader("ContentType", "application/json");
+ request.AddBody(new { ids = ids });
+
+ var response = ExecuteRequest(request);
+ AssertStatus(response, HttpStatusCode.OK);
+
+ var data = deserializer.Deserialize>(response);
+ return data;
+ }
+ catch (Exception ex)
+ {
+ Trace.TraceError("GetWorklogList() error: {0}", ex);
+ throw new JiraClientException("Could not load worklog list", ex);
+ }
+ }
+
public IEnumerable GetIssueTypes()
{
try
diff --git a/TechTalk.JiraRestClient/Project.cs b/TechTalk.JiraRestClient/Project.cs
new file mode 100644
index 0000000..14baafc
--- /dev/null
+++ b/TechTalk.JiraRestClient/Project.cs
@@ -0,0 +1,11 @@
+using System;
+
+namespace TechTalk.JiraRestClient
+{
+ public class Project
+ {
+ public string id { get; set; }
+ public string key { get; set; }
+ public string name { get; set; }
+ }
+}
diff --git a/TechTalk.JiraRestClient/TechTalk.JiraRestClient.csproj b/TechTalk.JiraRestClient/TechTalk.JiraRestClient.csproj
index bd93afe..b053b05 100644
--- a/TechTalk.JiraRestClient/TechTalk.JiraRestClient.csproj
+++ b/TechTalk.JiraRestClient/TechTalk.JiraRestClient.csproj
@@ -41,9 +41,13 @@
QueryableIssueCollection.cs
+
+
+
+
diff --git a/TechTalk.JiraRestClient/Utils/TimeUtils.cs b/TechTalk.JiraRestClient/Utils/TimeUtils.cs
new file mode 100644
index 0000000..930a6d9
--- /dev/null
+++ b/TechTalk.JiraRestClient/Utils/TimeUtils.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace TechTalk.JiraRestClient.Utils
+{
+ public static class TimeUtils
+ {
+ public static readonly DateTime unixStart = new DateTime(1970, 1, 1, 0, 0, 0);
+
+ public static DateTime FromUnixTime(long unixTime)
+ {
+ return unixStart.AddMilliseconds(unixTime);
+ }
+
+ public static long ToUnixTime(DateTime time)
+ {
+ return (long)(time - unixStart).TotalMilliseconds;
+ }
+ }
+}
diff --git a/TechTalk.JiraRestClient/Worklog.cs b/TechTalk.JiraRestClient/Worklog.cs
new file mode 100644
index 0000000..f595c48
--- /dev/null
+++ b/TechTalk.JiraRestClient/Worklog.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+
+namespace TechTalk.JiraRestClient
+{
+ public class Worklog
+ {
+ public JiraUser author { get; set; }
+ public JiraUser updateAuthor { get; set; }
+ public string comment { get; set; }
+ public DateTime created { get; set; }
+ public DateTime updated { get; set; }
+ public DateTime started { get; set; }
+ public string timeSpent { get; set; }
+ public int timeSpentSeconds { get; set; }
+ public string id { get; set; }
+ public string issueId { get; set; }
+ }
+}
diff --git a/TechTalk.JiraRestClient/WorklogUpdated.cs b/TechTalk.JiraRestClient/WorklogUpdated.cs
new file mode 100644
index 0000000..aa8ff34
--- /dev/null
+++ b/TechTalk.JiraRestClient/WorklogUpdated.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using TechTalk.JiraRestClient.Utils;
+
+namespace TechTalk.JiraRestClient
+{
+ public class WorklogUpdated
+ {
+ public List values { get; set; }
+ public long since { get; set; }
+ public long until { get; set; }
+ public bool lastPage { get; set; }
+
+ public DateTime Since
+ {
+ get
+ {
+ return TimeUtils.FromUnixTime(since);
+ }
+ }
+
+ public DateTime Until
+ {
+ get
+ {
+ return TimeUtils.FromUnixTime(until);
+ }
+ }
+ }
+
+ public class WorklogUpdatedValue
+ {
+ public int worklogId { get; set; }
+ public long updatedTime { get; set; }
+
+ public DateTime UpdatedTime
+ {
+ get
+ {
+ return TimeUtils.FromUnixTime(updatedTime);
+ }
+ }
+ }
+}