示例#1
0
        public RemoteLink UpdateRemoteLink(IssueRef issue, RemoteLink remoteLink)
        {
            try
            {
                var path    = string.Format("issue/{0}/remotelink/{1}", issue.id, remoteLink.id);
                var request = CreateRequest(Method.PUT, path);
                request.AddHeader("ContentType", "application/json");

                var updateData = new Dictionary <string, object>();
                if (remoteLink.url != null)
                {
                    updateData.Add("url", remoteLink.url);
                }
                if (remoteLink.title != null)
                {
                    updateData.Add("title", remoteLink.title);
                }
                if (remoteLink.summary != null)
                {
                    updateData.Add("summary", remoteLink.summary);
                }
                request.AddBody(new { @object = updateData });

                var response = ExecuteRequest(request);
                AssertStatus(response, HttpStatusCode.NoContent);

                return(GetRemoteLinks(issue).Single(rl => rl.id == remoteLink.id));
            }
            catch (Exception ex)
            {
                Trace.TraceError("UpdateRemoteLink(issue, remoteLink) error: {0}", ex);
                throw new JiraClientException("Could not update external link for issue", ex);
            }
        }
示例#2
0
        public RemoteLink CreateRemoteLink(IssueRef issue, RemoteLink remoteLink)
        {
            try
            {
                var path    = string.Format("issue/{0}/remotelink", issue.id);
                var request = CreateRequest(Method.POST, path);
                request.AddHeader("ContentType", "application/json");
                request.AddBody(new
                {
                    application = new
                    {
                        type = "TechTalk.JiraRestClient",
                        name = "JIRA REST client"
                    },
                    @object = new
                    {
                        remoteLink.url, remoteLink.title, remoteLink.summary
                    }
                });

                var response = ExecuteRequest(request);
                AssertStatus(response, HttpStatusCode.Created);

                //returns: { "id": <id>, "self": <url> }
                var linkId = this.deserializer.Deserialize <RemoteLink>(response).id;
                return(GetRemoteLinks(issue).Single(rl => rl.id == linkId));
            }
            catch (Exception ex)
            {
                Trace.TraceError("CreateRemoteLink(issue, remoteLink) error: {0}", ex);
                throw new JiraClientException("Could not create external link for issue", ex);
            }
        }
示例#3
0
        public void DeleteRemoteLink(IssueRef issue, RemoteLink remoteLink)
        {
            try
            {
                var path    = string.Format("issue/{0}/remotelink/{1}", issue.id, remoteLink.id);
                var request = CreateRequest(Method.DELETE, path);
                request.AddHeader("ContentType", "application/json");

                var response = ExecuteRequest(request);
                AssertStatus(response, HttpStatusCode.NoContent);
            }
            catch (Exception ex)
            {
                Trace.TraceError("DeleteRemoteLink(issue, remoteLink) error: {0}", ex);
                throw new JiraClientException("Could not delete external link for issue", ex);
            }
        }
示例#4
0
 public void DeleteRemoteLink(IssueRef issue, RemoteLink remoteLink)
 {
     this.client.DeleteRemoteLink(issue, remoteLink);
 }
示例#5
0
 public RemoteLink UpdateRemoteLink(IssueRef issue, RemoteLink remoteLink)
 {
     return(this.client.UpdateRemoteLink(issue, remoteLink));
 }
示例#6
0
 public RemoteLink CreateRemoteLink(IssueRef issue, RemoteLink remoteLink)
 {
     return(client.CreateRemoteLink(issue, remoteLink));
 }