aboutsummaryrefslogtreecommitdiff
path: root/docs/api/schemas/v1.2
diff options
context:
space:
mode:
authorMete Polat <metepolat2000@gmail.com>2020-02-27 23:29:32 +0000
committerDaniel Axtens <dja@axtens.net>2020-03-16 11:15:57 +1100
commit83f364aad66c35e31df8d0871ec2b62016eba337 (patch)
tree9a9c650ec0e11f18ca5b25145ec64ae9689ba378 /docs/api/schemas/v1.2
parent27c2acf56cd30e77c932a1dde87b6fc1de8eeb2c (diff)
downloadpatchwork-83f364aad66c35e31df8d0871ec2b62016eba337.tar
patchwork-83f364aad66c35e31df8d0871ec2b62016eba337.tar.gz
REST: Add patch relations
View relations and add/update/delete them as a maintainer. Maintainers can only create relations of patches which are part of a project they maintain. Because this is a writable many-many nested relationship, it behaves a little unusually. In short: - All operations use PATCH to the 'related' field of a patch - To relate a patch to another patch, say 7 to 19, either: PATCH /api/patch/7 related := [19] PATCH /api/patch/19 related := [7] - To delete a patch from a relation, say 1, 21 and 42 are related but we only want it to be 1 and 42: PATCH /api/patch/21 related := [] * You _cannot_ remove a patch from a relation by patching another patch in the relation: I'm trying to avoid read-modify-write loops. * Relations that would be left with just 1 patch are deleted. This is only ensured in the API - the admin interface will let you do this. - Break-before-make: if you have [1, 12, 24] and [7, 15, 42] and you want to end up with [1, 12, 15, 42], you have to remove 15 from the second relation first: PATCH /api/patch/1 related := [15] will fail with 409 Conflict. Instead do: PATCH /api/patch/15 related := [] PATCH /api/patch/1 related := [15] -> 200 OK, [1, 12, 15, 42] and [7, 42] are the resulting relations Signed-off-by: Mete Polat <metepolat2000@gmail.com> Signed-off-by: Stephen Finucane <stephen@that.guru> Signed-off-by: Daniel Axtens <dja@axtens.net>
Diffstat (limited to 'docs/api/schemas/v1.2')
-rw-r--r--docs/api/schemas/v1.2/patchwork.yaml44
1 files changed, 44 insertions, 0 deletions
diff --git a/docs/api/schemas/v1.2/patchwork.yaml b/docs/api/schemas/v1.2/patchwork.yaml
index be79e38..db2ed12 100644
--- a/docs/api/schemas/v1.2/patchwork.yaml
+++ b/docs/api/schemas/v1.2/patchwork.yaml
@@ -352,6 +352,7 @@ paths:
- patch-created
- patch-completed
- patch-state-changed
+ - patch-relation-changed
- patch-delegated
- check-created
- series-created
@@ -390,6 +391,7 @@ paths:
- $ref: '#/components/schemas/EventPatchCreated'
- $ref: '#/components/schemas/EventPatchCompleted'
- $ref: '#/components/schemas/EventPatchStateChanged'
+ - $ref: '#/components/schemas/EventPatchRelationChanged'
- $ref: '#/components/schemas/EventPatchDelegated'
- $ref: '#/components/schemas/EventCheckCreated'
- $ref: '#/components/schemas/EventSeriesCreated'
@@ -403,6 +405,8 @@ paths:
'#/components/schemas/EventPatchCompleted'
patch-state-changed: >
'#/components/schemas/EventPatchStateChanged'
+ patch-relation-changed: >
+ '#/components/schemas/EventPatchRelationChanged'
patch-delegated: >
'#/components/schemas/EventPatchDelegated'
check-created: '#/components/schemas/EventCheckCreated'
@@ -552,6 +556,12 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
+ '409':
+ description: Conflict
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Error'
tags:
- patches
put:
@@ -595,6 +605,12 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
+ '409':
+ description: Conflict
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Error'
tags:
- patches
/api/1.2/patches/{id}/comments/:
@@ -1721,6 +1737,24 @@ components:
current_state:
title: Current state
type: string
+ EventPatchRelationChanged:
+ allOf:
+ - $ref: '#/components/schemas/EventBase'
+ - type: object
+ properties:
+ category:
+ enum:
+ - patch-relation-changed
+ payload:
+ properties:
+ patch:
+ $ref: '#/components/schemas/PatchEmbedded'
+ previous_relation:
+ title: Previous relation
+ type: string
+ current_relation:
+ title: Current relation
+ type: string
EventPatchDelegated:
allOf:
- $ref: '#/components/schemas/EventBase'
@@ -1893,6 +1927,11 @@ components:
items:
type: string
readOnly: true
+ related:
+ title: Relations
+ type: array
+ items:
+ type: string
PatchDetail:
allOf:
- $ref: '#/components/schemas/PatchList'
@@ -1943,6 +1982,11 @@ components:
title: Delegate
type: integer
nullable: true
+ related:
+ title: Relations
+ type: array
+ items:
+ type: string
Person:
type: object
properties: