Project

General

Profile

Rest IssueRelations » History » Revision 9

Revision 8 (Toshi MARUYAMA, 2019-10-18 14:51) → Revision 9/10 (Toshi MARUYAMA, 2019-10-18 16:08)

h1. Issue Relations 

 {{>toc}} 

 h2. /issues/:issue_id/relations.:format 

 h3. GET 

 Returns the relations for the issue of given id (:issue_id). 

 +XML example+: 

 <pre> 
 GET /issues/8470/relations.xml 
 </pre> 

 +Response+: 

 <pre><code class="xml"> 
 <?xml version="1.0" encoding="UTF-8"?> 
 <relations type="array"> 
   <relation> 
     <id>1819</id> 
     <issue_id>8470</issue_id> 
     <issue_to_id>8469</issue_to_id> 
     <relation_type>relates</relation_type> 
     <delay/> 
   </relation> 
   <relation> 
     <id>1820</id> 
     <issue_id>8470</issue_id> 
     <issue_to_id>8467</issue_to_id> 
     <relation_type>relates</relation_type> 
     <delay/> 
   </relation> 
 </relations> 
 </code></pre> 

 +json example+: 

 <pre> 
 GET /issues/8470/relations.json 
 </pre> 

 +Response+: 

 <pre><code class="json"> 
 { 
     "relations": [ 
         { 
             "delay": null, 
             "id": 1819, 
             "issue_id": 8470, 
             "issue_to_id": 8469, 
             "relation_type": "relates" 
         }, 
         { 
             "delay": null, 
             "id": 1820, 
             "issue_id": 8470, 
             "issue_to_id": 8467, 
             "relation_type": "relates" 
         } 
     ] 
 } 
 </code> 
 </pre> 

 Note: when getting an issue, relations can also be retrieved in a single request using @/issues/:id.:format?include=relations@. 

 

 h3. POST 

 Creates a relation for the issue of given id (:issue_id). 

 +Parameters+: 

 * @relation@ (required): a hash of the relation attributes, including: 

   * @issue_to_id@ (required): the id of the related issue 
   * @relation_type@ (required to explicit : default "relates"): the type of relation (in: "relates", "duplicates", "duplicated", "blocks", "blocked", "precedes", "follows", "copied_to", "copied_from") 
   * @delay@ (optional): the delay for a "precedes" or "follows" relation 

 +Response+: 

   * @201 Created@: relation was created 
   * @422 Unprocessable Entity@: relation was not created due to validation failures (response body contains the error messages) 

 +Examples+: 

 <pre> 
 POST /issues/83/relations.xml 
 </pre> 
 <pre><code class="xml"> 
 <?xml version="1.0" encoding="UTF-8"?> 
 <relation> 
   <issue_to_id>82</issue_to_id> 
   <relation_type>relates</relation_type> 
 </relation> 
 </code></pre> 
 <pre> 
 POST /issues/83/relations.json 
 </pre> 
 <pre><code class="json"> 
 { 
   "relation": { 
     "issue_to_id": 82, 
     "relation_type": "relates" 
   } 
 } 
 </code></pre> 

 h2. /relations/:id.:format 

 h3. GET 

 Returns the relation of given id. 

 +XML example+: 

 <pre> 
 GET /relations/1819.xml 
 </pre> 

 +Response+: 

 <pre><code class="xml"> 
 <?xml version="1.0" encoding="UTF-8"?> 
 <relation> 
   <id>1819</id> 
   <issue_id>8470</issue_id> 
   <issue_to_id>8469</issue_to_id> 
   <relation_type>relates</relation_type> 
   <delay/> 
 </relation> 
 </code></pre> 

 +json example+: 

 <pre> 
 GET /relations/1819.json 
 </pre> 

 +Response+: 

 <pre><code class="json"> 
 { 
     "relation": { 
         "delay": null, 
         "id": 1819, 
         "issue_id": 8470, 
         "issue_to_id": 8469, 
         "relation_type": "relates" 
     } 
 } 
 </code></pre> 

 h3. DELETE 

 Deletes the relation of given id. 

 +Response+: 

   * @200 OK@: relation was deleted 
   * @422 Unprocessable Entity@: relation was not deleted (response body contains the error messages)