Skip to content

Commit 93ec4fc

Browse files
committed
feat(API): Add create comparison endpoint for branches [SCD-549]
1 parent 0312fe3 commit 93ec4fc

File tree

5 files changed

+191
-4
lines changed

5 files changed

+191
-4
lines changed

doc/compiled.json

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5021,6 +5021,20 @@
50215021
}
50225022
}
50235023
},
5024+
"202": {
5025+
"description": "Accepted",
5026+
"headers": {
5027+
"X-Rate-Limit-Limit": {
5028+
"$ref": "#/components/headers/X-Rate-Limit-Limit"
5029+
},
5030+
"X-Rate-Limit-Remaining": {
5031+
"$ref": "#/components/headers/X-Rate-Limit-Remaining"
5032+
},
5033+
"X-Rate-Limit-Reset": {
5034+
"$ref": "#/components/headers/X-Rate-Limit-Reset"
5035+
}
5036+
}
5037+
},
50245038
"204": {
50255039
"description": "The resource was deleted successfully.",
50265040
"headers": {
@@ -5080,6 +5094,20 @@
50805094
}
50815095
}
50825096
},
5097+
"409": {
5098+
"description": "Conflict",
5099+
"headers": {
5100+
"X-Rate-Limit-Limit": {
5101+
"$ref": "#/components/headers/X-Rate-Limit-Limit"
5102+
},
5103+
"X-Rate-Limit-Remaining": {
5104+
"$ref": "#/components/headers/X-Rate-Limit-Remaining"
5105+
},
5106+
"X-Rate-Limit-Reset": {
5107+
"$ref": "#/components/headers/X-Rate-Limit-Reset"
5108+
}
5109+
}
5110+
},
50835111
"422": {
50845112
"description": "Unprocessable entity",
50855113
"content": {
@@ -18508,7 +18536,7 @@
1850818536
"/projects/{project_id}/branches/{name}/compare": {
1850918537
"get": {
1851018538
"summary": "Compare branches",
18511-
"description": "Compare branch with main branch. \n\n*Note: Comparing a branch may take several minutes depending on the project size.*\n",
18539+
"description": "Compare branch with main branch.\n\n*Note: Comparing a branch may take several minutes depending on the project size. Consider using the `POST /compare` endpoint for creating comparison asynchronously.*\n",
1851218540
"operationId": "branch/compare",
1851318541
"tags": [
1851418542
"Branches"
@@ -18554,6 +18582,10 @@
1855418582
"404": {
1855518583
"$ref": "#/components/responses/404"
1855618584
},
18585+
"409": {
18586+
"$ref": "#/components/responses/409",
18587+
"description": "A comparison is already in progress for this branch."
18588+
},
1855718589
"429": {
1855818590
"$ref": "#/components/responses/429"
1855918591
}
@@ -18569,6 +18601,81 @@
1856918601
}
1857018602
],
1857118603
"x-cli-version": "2.5"
18604+
},
18605+
"post": {
18606+
"summary": "Create comparison (async.)",
18607+
"description": "Create a branch comparison asynchronously.\n",
18608+
"operationId": "branch/create_comparison",
18609+
"tags": [
18610+
"Branches"
18611+
],
18612+
"parameters": [
18613+
{
18614+
"$ref": "#/components/parameters/X-PhraseApp-OTP"
18615+
},
18616+
{
18617+
"$ref": "#/components/parameters/project_id"
18618+
},
18619+
{
18620+
"$ref": "#/components/parameters/name"
18621+
}
18622+
],
18623+
"responses": {
18624+
"200": {
18625+
"$ref": "#/components/responses/200"
18626+
},
18627+
"202": {
18628+
"$ref": "#/components/responses/202"
18629+
},
18630+
"400": {
18631+
"$ref": "#/components/responses/400"
18632+
},
18633+
"404": {
18634+
"$ref": "#/components/responses/404"
18635+
},
18636+
"409": {
18637+
"$ref": "#/components/responses/409",
18638+
"description": "An asynchronous comparison is already in progress for this branch."
18639+
},
18640+
"429": {
18641+
"$ref": "#/components/responses/429"
18642+
}
18643+
},
18644+
"x-code-samples": [
18645+
{
18646+
"lang": "Curl",
18647+
"source": "curl \"https://api.phrase.com/v2/projects/:project_id/branches/:name/compare\" \\\n -u USERNAME_OR_ACCESS_TOKEN \\\n -X POST \\\n -d '{\"direction\":\"merge\"}' \\\n -H 'Content-Type: application/json'"
18648+
},
18649+
{
18650+
"lang": "CLI v2",
18651+
"source": "phrase branches create_comparison \\\n--project_id <project_id> \\\n--name <name> \\\n--access_token <token>"
18652+
}
18653+
],
18654+
"requestBody": {
18655+
"required": true,
18656+
"content": {
18657+
"application/json": {
18658+
"schema": {
18659+
"type": "object",
18660+
"title": "branch/create_comparison/parameters",
18661+
"properties": {
18662+
"direction": {
18663+
"description": "direction of comparison, possible values are sync or merge (only for v2 branches, currently in private beta )",
18664+
"type": "string",
18665+
"example": "merge",
18666+
"default": "merge"
18667+
},
18668+
"async": {
18669+
"description": "whether to perform the comparison asynchronously",
18670+
"type": "boolean",
18671+
"example": true,
18672+
"default": true
18673+
}
18674+
}
18675+
}
18676+
}
18677+
}
18678+
}
1857218679
}
1857318680
},
1857418681
"/accounts": {

paths.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,8 @@
399399
"/projects/{project_id}/branches/{name}/compare":
400400
get:
401401
"$ref": "./paths/branches/compare.yaml"
402+
post:
403+
"$ref": "./paths/branches/create_comparison.yaml"
402404
"/accounts":
403405
get:
404406
"$ref": "./paths/accounts/index.yaml"

paths/branches/compare.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
summary: Compare branches
33
description: |
4-
Compare branch with main branch.
5-
6-
*Note: Comparing a branch may take several minutes depending on the project size.*
4+
Compare branch with main branch.
5+
6+
*Note: Comparing a branch may take several minutes depending on the project size. Consider using the `POST /compare` endpoint for creating comparison asynchronously.*
77
operationId: branch/compare
88
tags:
99
- Branches
@@ -31,6 +31,9 @@ responses:
3131
"$ref": "../../responses.yaml#/400"
3232
'404':
3333
"$ref": "../../responses.yaml#/404"
34+
'409':
35+
"$ref": "../../responses.yaml#/409"
36+
description: A comparison is already in progress for this branch.
3437
'429':
3538
"$ref": "../../responses.yaml#/429"
3639
x-code-samples:
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
summary: Create comparison (async.)
3+
description: |
4+
Create a branch comparison asynchronously.
5+
operationId: branch/create_comparison
6+
tags:
7+
- Branches
8+
parameters:
9+
- "$ref": "../../parameters.yaml#/X-PhraseApp-OTP"
10+
- "$ref": "../../parameters.yaml#/project_id"
11+
- "$ref": "../../parameters.yaml#/name"
12+
responses:
13+
'200':
14+
"$ref": "../../responses.yaml#/200"
15+
'202':
16+
"$ref": "../../responses.yaml#/202"
17+
'400':
18+
"$ref": "../../responses.yaml#/400"
19+
'404':
20+
"$ref": "../../responses.yaml#/404"
21+
'409':
22+
"$ref": "../../responses.yaml#/409"
23+
description: An asynchronous comparison is already in progress for this branch.
24+
'429':
25+
"$ref": "../../responses.yaml#/429"
26+
x-code-samples:
27+
- lang: Curl
28+
source: |-
29+
curl "https://api.phrase.com/v2/projects/:project_id/branches/:name/compare" \
30+
-u USERNAME_OR_ACCESS_TOKEN \
31+
-X POST \
32+
-d '{"direction":"merge"}' \
33+
-H 'Content-Type: application/json'
34+
- lang: CLI v2
35+
source: |-
36+
phrase branches create_comparison \
37+
--project_id <project_id> \
38+
--name <name> \
39+
--access_token <token>
40+
requestBody:
41+
required: true
42+
content:
43+
application/json:
44+
schema:
45+
type: object
46+
title: branch/create_comparison/parameters
47+
properties:
48+
direction:
49+
description: direction of comparison, possible values are sync or merge (only for v2 branches, currently in private beta )
50+
type: string
51+
example: merge
52+
default: merge
53+
async:
54+
description: whether to perform the comparison asynchronously
55+
type: boolean
56+
example: true
57+
default: true

responses.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616
$ref: "./headers.yaml#/X-Rate-Limit-Remaining"
1717
X-Rate-Limit-Reset:
1818
$ref: "./headers.yaml#/X-Rate-Limit-Reset"
19+
202:
20+
description: Accepted
21+
headers:
22+
X-Rate-Limit-Limit:
23+
$ref: "./headers.yaml#/X-Rate-Limit-Limit"
24+
X-Rate-Limit-Remaining:
25+
$ref: "./headers.yaml#/X-Rate-Limit-Remaining"
26+
X-Rate-Limit-Reset:
27+
$ref: "./headers.yaml#/X-Rate-Limit-Reset"
1928
204:
2029
description: The resource was deleted successfully.
2130
headers:
@@ -54,6 +63,15 @@
5463
$ref: "./headers.yaml#/X-Rate-Limit-Remaining"
5564
X-Rate-Limit-Reset:
5665
$ref: "./headers.yaml#/X-Rate-Limit-Reset"
66+
409:
67+
description: Conflict
68+
headers:
69+
X-Rate-Limit-Limit:
70+
$ref: "./headers.yaml#/X-Rate-Limit-Limit"
71+
X-Rate-Limit-Remaining:
72+
$ref: "./headers.yaml#/X-Rate-Limit-Remaining"
73+
X-Rate-Limit-Reset:
74+
$ref: "./headers.yaml#/X-Rate-Limit-Reset"
5775
422:
5876
description: Unprocessable entity
5977
content:

0 commit comments

Comments
 (0)