Rest IssueRelations » History » Version 9

Toshi MARUYAMA, 2019-10-18 16:08
add POST example

1 1 Jean-Philippe Lang
h1. Issue Relations
2 1 Jean-Philippe Lang
3 1 Jean-Philippe Lang
{{>toc}}
4 1 Jean-Philippe Lang
5 2 Jean-Philippe Lang
h2. /issues/:issue_id/relations.:format
6 1 Jean-Philippe Lang
7 2 Jean-Philippe Lang
h3. GET
8 2 Jean-Philippe Lang
9 2 Jean-Philippe Lang
Returns the relations for the issue of given id (:issue_id).
10 2 Jean-Philippe Lang
11 7 Toshi MARUYAMA
+XML example+:
12 2 Jean-Philippe Lang
13 2 Jean-Philippe Lang
<pre>
14 2 Jean-Philippe Lang
GET /issues/8470/relations.xml
15 2 Jean-Philippe Lang
</pre>
16 2 Jean-Philippe Lang
17 2 Jean-Philippe Lang
+Response+:
18 2 Jean-Philippe Lang
19 6 Go MAEDA
<pre><code class="xml">
20 2 Jean-Philippe Lang
<?xml version="1.0" encoding="UTF-8"?>
21 2 Jean-Philippe Lang
<relations type="array">
22 2 Jean-Philippe Lang
  <relation>
23 2 Jean-Philippe Lang
    <id>1819</id>
24 2 Jean-Philippe Lang
    <issue_id>8470</issue_id>
25 2 Jean-Philippe Lang
    <issue_to_id>8469</issue_to_id>
26 2 Jean-Philippe Lang
    <relation_type>relates</relation_type>
27 2 Jean-Philippe Lang
    <delay/>
28 2 Jean-Philippe Lang
  </relation>
29 2 Jean-Philippe Lang
  <relation>
30 2 Jean-Philippe Lang
    <id>1820</id>
31 2 Jean-Philippe Lang
    <issue_id>8470</issue_id>
32 2 Jean-Philippe Lang
    <issue_to_id>8467</issue_to_id>
33 2 Jean-Philippe Lang
    <relation_type>relates</relation_type>
34 2 Jean-Philippe Lang
    <delay/>
35 2 Jean-Philippe Lang
  </relation>
36 2 Jean-Philippe Lang
</relations>
37 1 Jean-Philippe Lang
</code></pre>
38 7 Toshi MARUYAMA
39 7 Toshi MARUYAMA
+json example+:
40 7 Toshi MARUYAMA
41 7 Toshi MARUYAMA
<pre>
42 7 Toshi MARUYAMA
GET /issues/8470/relations.json
43 7 Toshi MARUYAMA
</pre>
44 7 Toshi MARUYAMA
45 7 Toshi MARUYAMA
+Response+:
46 7 Toshi MARUYAMA
47 7 Toshi MARUYAMA
<pre><code class="json">
48 7 Toshi MARUYAMA
{
49 7 Toshi MARUYAMA
    "relations": [
50 7 Toshi MARUYAMA
        {
51 7 Toshi MARUYAMA
            "delay": null,
52 7 Toshi MARUYAMA
            "id": 1819,
53 7 Toshi MARUYAMA
            "issue_id": 8470,
54 7 Toshi MARUYAMA
            "issue_to_id": 8469,
55 7 Toshi MARUYAMA
            "relation_type": "relates"
56 7 Toshi MARUYAMA
        },
57 7 Toshi MARUYAMA
        {
58 7 Toshi MARUYAMA
            "delay": null,
59 7 Toshi MARUYAMA
            "id": 1820,
60 7 Toshi MARUYAMA
            "issue_id": 8470,
61 7 Toshi MARUYAMA
            "issue_to_id": 8467,
62 7 Toshi MARUYAMA
            "relation_type": "relates"
63 7 Toshi MARUYAMA
        }
64 7 Toshi MARUYAMA
    ]
65 7 Toshi MARUYAMA
}
66 7 Toshi MARUYAMA
</code>
67 7 Toshi MARUYAMA
</pre>
68 2 Jean-Philippe Lang
69 2 Jean-Philippe Lang
Note: when getting an issue, relations can also be retrieved in a single request using @/issues/:id.:format?include=relations@.
70 2 Jean-Philippe Lang
71 1 Jean-Philippe Lang
h3. POST
72 1 Jean-Philippe Lang
73 1 Jean-Philippe Lang
Creates a relation for the issue of given id (:issue_id).
74 1 Jean-Philippe Lang
75 1 Jean-Philippe Lang
+Parameters+:
76 1 Jean-Philippe Lang
77 1 Jean-Philippe Lang
* @relation@ (required): a hash of the relation attributes, including:
78 1 Jean-Philippe Lang
79 1 Jean-Philippe Lang
  * @issue_to_id@ (required): the id of the related issue
80 5 Sahya Norn
  * @relation_type@ (required to explicit : default "relates"): the type of relation (in: "relates", "duplicates", "duplicated", "blocks", "blocked", "precedes", "follows", "copied_to", "copied_from")
81 1 Jean-Philippe Lang
  * @delay@ (optional): the delay for a "precedes" or "follows" relation
82 1 Jean-Philippe Lang
83 1 Jean-Philippe Lang
+Response+:
84 1 Jean-Philippe Lang
85 1 Jean-Philippe Lang
  * @201 Created@: relation was created
86 1 Jean-Philippe Lang
  * @422 Unprocessable Entity@: relation was not created due to validation failures (response body contains the error messages)
87 1 Jean-Philippe Lang
88 9 Toshi MARUYAMA
+Examples+:
89 9 Toshi MARUYAMA
90 9 Toshi MARUYAMA
<pre>
91 9 Toshi MARUYAMA
POST /issues/83/relations.xml
92 9 Toshi MARUYAMA
</pre>
93 9 Toshi MARUYAMA
<pre><code class="xml">
94 9 Toshi MARUYAMA
<?xml version="1.0" encoding="UTF-8"?>
95 9 Toshi MARUYAMA
<relation>
96 9 Toshi MARUYAMA
  <issue_to_id>82</issue_to_id>
97 9 Toshi MARUYAMA
  <relation_type>relates</relation_type>
98 9 Toshi MARUYAMA
</relation>
99 9 Toshi MARUYAMA
</code></pre>
100 9 Toshi MARUYAMA
<pre>
101 9 Toshi MARUYAMA
POST /issues/83/relations.json
102 9 Toshi MARUYAMA
</pre>
103 9 Toshi MARUYAMA
<pre><code class="json">
104 9 Toshi MARUYAMA
{
105 9 Toshi MARUYAMA
  "relation": {
106 9 Toshi MARUYAMA
    "issue_to_id": 82,
107 9 Toshi MARUYAMA
    "relation_type": "relates"
108 9 Toshi MARUYAMA
  }
109 9 Toshi MARUYAMA
}
110 9 Toshi MARUYAMA
</code></pre>
111 9 Toshi MARUYAMA
112 3 Jean-Philippe Lang
h2. /relations/:id.:format
113 1 Jean-Philippe Lang
114 1 Jean-Philippe Lang
h3. GET
115 1 Jean-Philippe Lang
116 1 Jean-Philippe Lang
Returns the relation of given id.
117 2 Jean-Philippe Lang
118 8 Toshi MARUYAMA
+XML example+:
119 2 Jean-Philippe Lang
120 2 Jean-Philippe Lang
<pre>
121 3 Jean-Philippe Lang
GET /relations/1819.xml
122 2 Jean-Philippe Lang
</pre>
123 1 Jean-Philippe Lang
124 1 Jean-Philippe Lang
+Response+:
125 1 Jean-Philippe Lang
126 6 Go MAEDA
<pre><code class="xml">
127 1 Jean-Philippe Lang
<?xml version="1.0" encoding="UTF-8"?>
128 1 Jean-Philippe Lang
<relation>
129 1 Jean-Philippe Lang
  <id>1819</id>
130 1 Jean-Philippe Lang
  <issue_id>8470</issue_id>
131 1 Jean-Philippe Lang
  <issue_to_id>8469</issue_to_id>
132 1 Jean-Philippe Lang
  <relation_type>relates</relation_type>
133 1 Jean-Philippe Lang
  <delay/>
134 1 Jean-Philippe Lang
</relation>
135 8 Toshi MARUYAMA
</code></pre>
136 8 Toshi MARUYAMA
137 8 Toshi MARUYAMA
+json example+:
138 8 Toshi MARUYAMA
139 8 Toshi MARUYAMA
<pre>
140 8 Toshi MARUYAMA
GET /relations/1819.json
141 8 Toshi MARUYAMA
</pre>
142 8 Toshi MARUYAMA
143 8 Toshi MARUYAMA
+Response+:
144 8 Toshi MARUYAMA
145 8 Toshi MARUYAMA
<pre><code class="json">
146 8 Toshi MARUYAMA
{
147 8 Toshi MARUYAMA
    "relation": {
148 8 Toshi MARUYAMA
        "delay": null,
149 8 Toshi MARUYAMA
        "id": 1819,
150 8 Toshi MARUYAMA
        "issue_id": 8470,
151 8 Toshi MARUYAMA
        "issue_to_id": 8469,
152 8 Toshi MARUYAMA
        "relation_type": "relates"
153 8 Toshi MARUYAMA
    }
154 8 Toshi MARUYAMA
}
155 6 Go MAEDA
</code></pre>
156 1 Jean-Philippe Lang
157 1 Jean-Philippe Lang
h3. DELETE
158 1 Jean-Philippe Lang
159 1 Jean-Philippe Lang
Deletes the relation of given id.
160 1 Jean-Philippe Lang
161 1 Jean-Philippe Lang
+Response+:
162 1 Jean-Philippe Lang
163 1 Jean-Philippe Lang
  * @200 OK@: relation was deleted
164 1 Jean-Philippe Lang
  * @422 Unprocessable Entity@: relation was not deleted (response body contains the error messages)