diff --git a/TechTalk.JiraRestClient/Compatibility.cs b/TechTalk.JiraRestClient/Compatibility.cs index 9089172..c227252 100644 --- a/TechTalk.JiraRestClient/Compatibility.cs +++ b/TechTalk.JiraRestClient/Compatibility.cs @@ -240,7 +240,7 @@ public void DeleteRemoteLink(IssueRef issue, RemoteLink remoteLink) public IEnumerable GetIssueTypes() { - return client.GetIssueTypes(); + return client.GetIssueTypes(); } public ServerInfo GetServerInfo() diff --git a/TechTalk.JiraRestClient/IJiraClient.cs b/TechTalk.JiraRestClient/IJiraClient.cs index 5205faa..f89e1f1 100644 --- a/TechTalk.JiraRestClient/IJiraClient.cs +++ b/TechTalk.JiraRestClient/IJiraClient.cs @@ -48,6 +48,12 @@ namespace TechTalk.JiraRestClient /// Returns all watchers for the given issue IEnumerable GetWatchers(IssueRef issue); + List GetProjects() where T : JiraProject; + + List FindUsers(string search) where T : JiraUser; + T FindUser(string search) where T : JiraUser; + + /// Returns all comments for the given issue IEnumerable GetComments(IssueRef issue); /// Adds a comment to the given issue @@ -81,7 +87,13 @@ namespace TechTalk.JiraRestClient void DeleteRemoteLink(IssueRef issue, RemoteLink remoteLink); /// Returns all issue types - IEnumerable GetIssueTypes(); + IEnumerable GetIssueTypes() where T : IssueType; + + /// Returns all issue statuses + IEnumerable GetIssueStatuses() where T : Status; + + /// Returns all issue priorities + IEnumerable GetIssuePriorities() where T : IssuePriority; /// Returns information about the JIRA server ServerInfo GetServerInfo(); diff --git a/TechTalk.JiraRestClient/IssuePriority.cs b/TechTalk.JiraRestClient/IssuePriority.cs new file mode 100644 index 0000000..5c1526e --- /dev/null +++ b/TechTalk.JiraRestClient/IssuePriority.cs @@ -0,0 +1,10 @@ +namespace TechTalk.JiraRestClient +{ + public class IssuePriority + { + public string self { get; set; } + public string iconUrl { get; set; } + public string name { get; set; } + public int id { get; set; } + } +} diff --git a/TechTalk.JiraRestClient/JiraClient.cs b/TechTalk.JiraRestClient/JiraClient.cs index 42fc27e..d99ceb3 100644 --- a/TechTalk.JiraRestClient/JiraClient.cs +++ b/TechTalk.JiraRestClient/JiraClient.cs @@ -277,7 +277,7 @@ public IEnumerable GetTransitions(IssueRef issue) { try { - var path = String.Format("issue/{0}/transitions?expand=transitions.fields", issue.id); + var path = String.Format("issue/{0}/transitions?expand=transitions.fields", issue.JiraIdentifier); var request = CreateRequest(Method.GET, path); var response = ExecuteRequest(request); @@ -340,6 +340,51 @@ public IEnumerable GetWatchers(IssueRef issue) } } + public List GetProjects() where T: JiraProject + { + try + { + var path = "project"; + var request = CreateRequest(Method.GET, path); + + var response = ExecuteRequest(request); + AssertStatus(response, HttpStatusCode.OK); + + return deserializer.Deserialize>(response); + } + catch (Exception ex) + { + Trace.TraceError("GetProjects() error: {0}", ex); + throw new JiraClientException("Could not load projects", ex); + } + + } + + public List FindUsers(string search) where T : JiraUser + { + try + { + var path = String.Format("user/search?username={0}", search); + var request = CreateRequest(Method.GET, path); + var response = ExecuteRequest(request); + AssertStatus(response, HttpStatusCode.OK); + + var result = deserializer.Deserialize>(response); + return result; + } + catch (Exception ex) + { + Trace.TraceError("FindUsers(issue) error: {0}", ex); + throw new JiraClientException(String.Format("Could find user {0}. {1}", search, ex)); + } + } + + public T FindUser(string search) where T : JiraUser + { + return FindUsers(search).FirstOrDefault(); + } + + public IEnumerable GetComments(IssueRef issue) { @@ -616,7 +661,8 @@ public void DeleteRemoteLink(IssueRef issue, RemoteLink remoteLink) } } - public IEnumerable GetIssueTypes() + //public IEnumerable GetIssueTypes() + public IEnumerable GetIssueTypes() where T : IssueType { try { @@ -626,7 +672,7 @@ public IEnumerable GetIssueTypes() var response = ExecuteRequest(request); AssertStatus(response, HttpStatusCode.OK); - var data = deserializer.Deserialize>(response); + var data = deserializer.Deserialize>(response); return data; } @@ -637,6 +683,48 @@ public IEnumerable GetIssueTypes() } } + public IEnumerable GetIssueStatuses() where T:Status + { + try + { + var request = CreateRequest(Method.GET, "status"); + 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("GetIssueStatuses() error: {0}", ex); + throw new JiraClientException("Could not load issue statuses", ex); + } + } + + public IEnumerable GetIssuePriorities() where T : IssuePriority + { + try + { + var request = CreateRequest(Method.GET, "priority"); + 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("GetIssuePriorities() error: {0}", ex); + throw new JiraClientException("Could not load issue priorities", ex); + } + } + public ServerInfo GetServerInfo() { try diff --git a/TechTalk.JiraRestClient/JiraProject.cs b/TechTalk.JiraRestClient/JiraProject.cs new file mode 100644 index 0000000..0488f55 --- /dev/null +++ b/TechTalk.JiraRestClient/JiraProject.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace TechTalk.JiraRestClient +{ + public class JiraProject + { + public string self { get; set; } + public int id { get; set; } + public string key { get; set; } + public string name { get; set; } + public string projectTypeKey { get; set; } + + } +} diff --git a/TechTalk.JiraRestClient/TechTalk.JiraRestClient.csproj b/TechTalk.JiraRestClient/TechTalk.JiraRestClient.csproj index bd93afe..38be586 100644 --- a/TechTalk.JiraRestClient/TechTalk.JiraRestClient.csproj +++ b/TechTalk.JiraRestClient/TechTalk.JiraRestClient.csproj @@ -44,7 +44,9 @@ + +