PageRenderTime 52ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/Atlassian.Jira/IIssueService.cs

https://bitbucket.org/farmas/atlassian.net-sdk
C# | 342 lines | 57 code | 42 blank | 243 comment | 0 complexity | 5fdf087701a4891d57476588b0154a76 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. using Atlassian.Jira.Linq;
  7. using Newtonsoft.Json.Linq;
  8. namespace Atlassian.Jira
  9. {
  10. /// <summary>
  11. /// Represents the operations on the issues of jira.
  12. /// </summary>
  13. public interface IIssueService
  14. {
  15. /// <summary>
  16. /// Query builder for issues in jira.
  17. /// </summary>
  18. JiraQueryable<Issue> Queryable { get; }
  19. /// <summary>
  20. /// Whether to validate a JQL query
  21. /// </summary>
  22. bool ValidateQuery { get; set; }
  23. /// <summary>
  24. /// Maximum number of issues to retrieve per request.
  25. /// </summary>
  26. int MaxIssuesPerRequest { get; set; }
  27. /// <summary>
  28. /// Retrieves an issue by its key.
  29. /// </summary>
  30. /// <param name="issueKey">The issue key to retrieve</param>
  31. /// <param name="token">Cancellation token for this operation.</param>
  32. Task<Issue> GetIssueAsync(string issueKey, CancellationToken token = default(CancellationToken));
  33. /// <summary>
  34. /// Retrieves a list of issues by their keys.
  35. /// </summary>
  36. /// <param name="issueKeys">List of issue keys to retrieve.</param>
  37. /// <param name="token">Cancellation token for this operation.</param>
  38. Task<IDictionary<string, Issue>> GetIssuesAsync(IEnumerable<string> issueKeys, CancellationToken token = default(CancellationToken));
  39. /// <summary>
  40. /// Retrieves a list of issues by their keys.
  41. /// </summary>
  42. /// <param name="issueKeys">List of issue keys to retrieve.</param>
  43. Task<IDictionary<string, Issue>> GetIssuesAsync(params string[] issueKeys);
  44. /// <summary>
  45. /// Updates all fields of an issue.
  46. /// </summary>
  47. /// <param name="issue">Issue to update.</param>
  48. /// <param name="token">Cancellation token for this operation.</param>
  49. Task UpdateIssueAsync(Issue issue, CancellationToken token = default(CancellationToken));
  50. /// <summary>
  51. /// Updates all fields of an issue.
  52. /// </summary>
  53. /// <param name="issue">Issue to update.</param>
  54. /// <param name="options">Options for the update</param>
  55. /// <param name="token">Cancellation token for this operation.</param>
  56. Task UpdateIssueAsync(Issue issue, IssueUpdateOptions options, CancellationToken token = default(CancellationToken));
  57. /// <summary>
  58. /// Creates an issue and returns a new instance populated from server.
  59. /// </summary>
  60. /// <param name="issue">Issue to create.</param>
  61. /// <param name="token">Cancellation token for this operation.</param>
  62. /// <returns>Promise that contains the new issue key when resolved.</returns>
  63. Task<string> CreateIssueAsync(Issue issue, CancellationToken token = default(CancellationToken));
  64. /// <summary>
  65. /// Deletes the specified issue.
  66. /// </summary>
  67. /// <param name="issueKey">Key of issue to delete.</param>
  68. /// <param name="token">Cancellation token for this operation.</param>
  69. Task DeleteIssueAsync(string issueKey, CancellationToken token = default(CancellationToken));
  70. /// <summary>
  71. /// Execute a specific JQL query and return the resulting issues.
  72. /// </summary>
  73. /// <param name="jql">JQL search query</param>
  74. /// <param name="maxIssues">Maximum number of issues to return (defaults to 20). The maximum allowable value is dictated by the JIRA property 'jira.search.views.default.max'. If you specify a value that is higher than this number, your search results will be truncated.</param>
  75. /// <param name="startAt">Index of the first issue to return (0-based)</param>
  76. /// <param name="token">Cancellation token for this operation.</param>
  77. Task<IPagedQueryResult<Issue>> GetIssuesFromJqlAsync(string jql, int? maxIssues = null, int startAt = 0, CancellationToken token = default(CancellationToken));
  78. /// <summary>
  79. /// Execute a specific JQL query and return the resulting issues.
  80. /// </summary>
  81. /// <param name="options">Options to use when executing the search.</param>
  82. /// <param name="token">Cancellatin token for this operation.</param>
  83. Task<IPagedQueryResult<Issue>> GetIssuesFromJqlAsync(IssueSearchOptions options, CancellationToken token = default(CancellationToken));
  84. /// <summary>
  85. /// Transition an issue through a workflow action.
  86. /// </summary>
  87. /// <param name="issue">Issue to transition.</param>
  88. /// <param name="actionNameOrId">The workflow action name or id to transition to.</param>
  89. /// <param name="updates">Additional updates to perform when transitioning the issue.</param>
  90. /// <param name="token">Cancellation token for this operation.</param>
  91. Task ExecuteWorkflowActionAsync(Issue issue, string actionNameOrId, WorkflowTransitionUpdates updates, CancellationToken token = default(CancellationToken));
  92. /// <summary>
  93. /// Gets time tracking information for an issue.
  94. /// </summary>
  95. /// <param name="issueKey">The issue key.</param>
  96. /// <param name="token">Cancellation token for this operation.</param>
  97. Task<IssueTimeTrackingData> GetTimeTrackingDataAsync(string issueKey, CancellationToken token = default(CancellationToken));
  98. /// <summary>
  99. /// Gets metadata object containing dictionary with issuefields identifiers as keys and their metadata as values
  100. /// </summary>
  101. /// <param name="issueKey">The issue key.</param>
  102. /// <param name="token">Cancellation token for this operation.</param>
  103. Task<IDictionary<String, IssueFieldEditMetadata>> GetFieldsEditMetadataAsync(string issueKey, CancellationToken token = default(CancellationToken));
  104. /// <summary>
  105. /// Adds a comment to an issue.
  106. /// </summary>
  107. /// <param name="issueKey">Issue key to add the comment to.</param>
  108. /// <param name="comment">Comment object to add.</param>
  109. /// <param name="token">Cancellation token for this operation.</param>
  110. Task<Comment> AddCommentAsync(string issueKey, Comment comment, CancellationToken token = default(CancellationToken));
  111. /// <summary>
  112. /// Returns all comments of an issue.
  113. /// </summary>
  114. /// <param name="issueKey">Issue key to retrieve comments from.</param>
  115. /// <param name="token">Cancellation token for this operation.</param>
  116. Task<IEnumerable<Comment>> GetCommentsAsync(string issueKey, CancellationToken token = default(CancellationToken));
  117. /// <summary>
  118. /// Returns all comments of an issue.
  119. /// </summary>
  120. /// <param name="issueKey">Issue key to retrieve comments from.</param>
  121. /// <param name="options">Options to configure the values of the query.</param>
  122. /// <param name="token">Cancellation token for this operation.</param>
  123. Task<IEnumerable<Comment>> GetCommentsAsync(string issueKey, CommentQueryOptions options, CancellationToken token = default(CancellationToken));
  124. /// <summary>
  125. /// Removes a comment from an issue.
  126. /// </summary>
  127. /// <param name="issueKey">Issue key to remove the comment from.</param>
  128. /// <param name="commentId">Identifier of the comment to remove.</param>
  129. /// <param name="token">Cancellation token for this operation.</param>
  130. Task DeleteCommentAsync(string issueKey, string commentId, CancellationToken token = default(CancellationToken));
  131. /// <summary>
  132. /// Updates a comment in an issue.
  133. /// </summary>
  134. /// <param name="issueKey">Issue key to update the comment to.</param>
  135. /// <param name="comment">Comment object to update.</param>
  136. /// <param name="token">Cancellation token for this operation.</param>
  137. Task<Comment> UpdateCommentAsync(string issueKey, Comment comment, CancellationToken token = default(CancellationToken));
  138. /// <summary>
  139. /// Returns the comments of an issue with paging.
  140. /// </summary>
  141. /// <param name="issueKey">Issue key to retrieve comments from.</param>
  142. /// <param name="maxComments">Maximum number of comments to retrieve.</param>
  143. /// <param name="startAt">Index of the first comment to return (0-based).</param>
  144. /// <param name="token">Cancellation token for this operation.</param>
  145. Task<IPagedQueryResult<Comment>> GetPagedCommentsAsync(string issueKey, int? maxComments = null, int startAt = 0, CancellationToken token = default(CancellationToken));
  146. /// <summary>
  147. /// Returns the workflow actions that an issue can be transitioned to.
  148. /// </summary>
  149. /// <param name="issueKey">The issue key</param>
  150. /// <param name="token">Cancellation token for this operation.</param>
  151. Task<IEnumerable<IssueTransition>> GetActionsAsync(string issueKey, CancellationToken token = default(CancellationToken));
  152. /// <summary>
  153. /// Returns the workflow actions that an issue can be transitioned to.
  154. /// </summary>
  155. /// <param name="issueKey">The issue key</param>
  156. /// <param name="expandTransitionFields">Whether to show the transition fields</param>
  157. /// <param name="token">Cancellation token for this operation.</param>
  158. Task<IEnumerable<IssueTransition>> GetActionsAsync(string issueKey, bool expandTransitionFields, CancellationToken token = default(CancellationToken));
  159. /// <summary>
  160. /// Retrieve attachment metadata from server for this issue
  161. /// </summary>
  162. /// <param name="issueKey">The issue key to get attachments from.</param>
  163. /// <param name="token">Cancellation token for this operation.</param>
  164. Task<IEnumerable<Attachment>> GetAttachmentsAsync(string issueKey, CancellationToken token = default(CancellationToken));
  165. /// <summary>
  166. /// Retrieve the labels from server for the issue specified.
  167. /// </summary>
  168. /// <param name="issueKey">The issue key to get labels from.</param>
  169. /// <param name="token">Cancellation token for this operation.</param>
  170. [Obsolete("Use Issue.Labels instead.")]
  171. Task<string[]> GetLabelsAsync(string issueKey, CancellationToken token = default(CancellationToken));
  172. /// <summary>
  173. /// Sets the labels for the issue specified.
  174. /// </summary>
  175. /// <param name="issueKey">The issue key to set the labels.</param>
  176. /// <param name="labels">The list of labels to set on the issue.</param>
  177. /// <param name="token">Cancellation token for this operation.</param>
  178. [Obsolete("Modify the Issue.Labels collection and call Issue.SaveChanges to update the labels field.")]
  179. Task SetLabelsAsync(string issueKey, string[] labels, CancellationToken token = default(CancellationToken));
  180. /// <summary>
  181. /// Retrieve the watchers from server for the issue specified.
  182. /// </summary>
  183. /// <param name="issueKey">The issue key to get watchers from.</param>
  184. /// <param name="token">Cancellation token for this operation.</param>
  185. Task<IEnumerable<JiraUser>> GetWatchersAsync(string issueKey, CancellationToken token = default(CancellationToken));
  186. /// <summary>
  187. /// Removes a user from the watcher list of an issue.
  188. /// </summary>
  189. /// <param name="issueKey">The issue key to remove the watcher from.</param>
  190. /// <param name="usernameOrAccountId">User name or account id of user to remove.</param>
  191. /// <param name="token">Cancellation token for this operation.</param>
  192. Task DeleteWatcherAsync(string issueKey, string usernameOrAccountId, CancellationToken token = default(CancellationToken));
  193. /// <summary>
  194. /// Adds a user to the watcher list of an issue.
  195. /// </summary>
  196. /// <param name="issueKey">The issue key to add the watcher to.</param>
  197. /// <param name="usernameOrAccountId">User name or account id of user to add.</param>
  198. /// <param name="token">Cancellation token for this operation.</param>
  199. Task AddWatcherAsync(string issueKey, string usernameOrAccountId, CancellationToken token = default(CancellationToken));
  200. /// <summary>
  201. /// Retrieve the change logs from server for the issue specified.
  202. /// </summary>
  203. /// <param name="issueKey">The issue key to get watchers from.</param>
  204. /// <param name="token">Cancellation token for this operation.</param>
  205. Task<IEnumerable<IssueChangeLog>> GetChangeLogsAsync(string issueKey, CancellationToken token = default(CancellationToken));
  206. /// <summary>
  207. /// Returns the issues that are marked as sub tasks of this issue.
  208. /// </summary>
  209. /// <param name="issueKey">The issue key to get sub tasks from.</param>
  210. /// <param name="maxIssues">Maximum number of issues to retrieve.</param>
  211. /// <param name="startAt">Index of the first issue to return (0-based).</param>
  212. /// <param name="token">Cancellation token for this operation.</param>
  213. Task<IPagedQueryResult<Issue>> GetSubTasksAsync(string issueKey, int? maxIssues = null, int startAt = 0, CancellationToken token = default(CancellationToken));
  214. /// <summary>
  215. /// Add one or more attachments to an issue.
  216. /// </summary>
  217. /// <param name="issueKey">Issue key to add attachments to.</param>
  218. /// <param name="attachments">Attachments to add.</param>
  219. /// <param name="token">Cancellation token for this operation.</param>
  220. Task AddAttachmentsAsync(string issueKey, UploadAttachmentInfo[] attachments, CancellationToken token = default(CancellationToken));
  221. /// <summary>
  222. /// Removes an attachment from an issue.
  223. /// </summary>
  224. /// <param name="issueKey">Issue key to remove the attachment from.</param>
  225. /// <param name="attachmentId">Identifier of the attachment to remove.</param>
  226. /// <param name="token">Cancellation token for this operation.</param>
  227. Task DeleteAttachmentAsync(string issueKey, string attachmentId, CancellationToken token = default(CancellationToken));
  228. /// <summary>
  229. /// Gets the worklog with the given identifier from an issue.
  230. /// </summary>
  231. /// <param name="issueKey">The issue key to retrieve the worklog from.</param>
  232. /// <param name="worklogId">The worklog identifier.</param>
  233. /// <param name="token">Cancellation token for this operation.</param>
  234. /// <returns></returns>
  235. Task<Worklog> GetWorklogAsync(string issueKey, string worklogId, CancellationToken token = default(CancellationToken));
  236. /// <summary>
  237. /// Gets the worklogs for an issue.
  238. /// </summary>
  239. /// <param name="issueKey">Issue key to retrieve the worklogs from.</param>
  240. /// <param name="token">Cancellation token for this operation.</param>
  241. Task<IEnumerable<Worklog>> GetWorklogsAsync(string issueKey, CancellationToken token = default(CancellationToken));
  242. /// <summary>
  243. /// Adds a work log to an issue.
  244. /// </summary>
  245. /// <param name="issueKey">Issue key to add the worklog to.</param>
  246. /// <param name="worklog">The worklog instance to add.</param>
  247. /// <param name="worklogStrategy">How to handle the remaining estimate, defaults to AutoAdjustRemainingEstimate.</param>
  248. /// <param name="newEstimate">New estimate (only used if worklogStrategy set to NewRemainingEstimate)</param>
  249. /// <param name="token">Cancellation token for this operation.</param>
  250. Task<Worklog> AddWorklogAsync(string issueKey, Worklog worklog, WorklogStrategy worklogStrategy = WorklogStrategy.AutoAdjustRemainingEstimate, string newEstimate = null, CancellationToken token = default(CancellationToken));
  251. /// <summary>
  252. /// Removes a work log from an issue.
  253. /// </summary>
  254. /// <param name="issueKey">Issue key to remove the work log from.</param>
  255. /// <param name="worklogId">The identifier of the work log to remove.</param>
  256. /// <param name="worklogStrategy">How to handle the remaining estimate, defaults to AutoAdjustRemainingEstimate.</param>
  257. /// <param name="newEstimate">New estimate (only used if worklogStrategy set to NewRemainingEstimate)</param>
  258. /// <param name="token">Cancellation token for this operation.</param>
  259. Task DeleteWorklogAsync(string issueKey, string worklogId, WorklogStrategy worklogStrategy = WorklogStrategy.AutoAdjustRemainingEstimate, string newEstimate = null, CancellationToken token = default(CancellationToken));
  260. /// <summary>
  261. /// Assigns an issue to the specified user.
  262. /// </summary>
  263. /// <param name="issueKey">Identifier of the issue to assign.</param>
  264. /// <param name="assignee">The username or account id of the user to assign the issue to.</param>
  265. /// <param name="token">Cancellation token for this operation.</param>
  266. Task AssignIssueAsync(string issueKey, string assignee, CancellationToken token = default(CancellationToken));
  267. /// <summary>
  268. /// Fetch all entity properties attached to the issue.
  269. /// </summary>
  270. /// <param name="issueKey">Identifier of the issue.</param>
  271. /// <param name="token">Cancellation token for this operation.</param>
  272. Task<IEnumerable<string>> GetPropertyKeysAsync(string issueKey, CancellationToken token = default);
  273. /// <summary>
  274. /// Fetch requested entity properties attached to the issue.
  275. /// </summary>
  276. /// <param name="issueKey">Identifier of the issue.</param>
  277. /// <param name="propertyKeys">The property keys to fetch.</param>
  278. /// <param name="token">Cancellation token for this operation.</param>
  279. /// <returns>A mapping between requested property keys and stored values.</returns>
  280. Task<ReadOnlyDictionary<string, JToken>> GetPropertiesAsync(string issueKey, IEnumerable<string> propertyKeys, CancellationToken token = default);
  281. /// <summary>
  282. /// Adds an entity property to the specified issue.
  283. /// </summary>
  284. /// <remarks>
  285. /// This method overwrites any already existing property values with the same key!
  286. /// </remarks>
  287. /// <param name="issueKey">Identifier of the issue.</param>
  288. /// <param name="propertyKey">The property key to identify the value.</param>
  289. /// <param name="obj">The JSON construct to store as property value.</param>
  290. /// <param name="token">Cancellation token for this operation.</param>
  291. Task SetPropertyAsync(string issueKey, string propertyKey, JToken obj, CancellationToken token = default);
  292. /// <summary>
  293. /// Removes the entity property from the specified issue.
  294. /// </summary>
  295. /// <param name="issueKey">Identifier of the issue.</param>
  296. /// <param name="propertyKey">The property key to identify the value.</param>
  297. /// <param name="token">Cancellation token for this operation.</param>
  298. Task DeletePropertyAsync(string issueKey, string propertyKey, CancellationToken token = default);
  299. }
  300. }