Skip to content

Commit 0bd1756

Browse files
authored
feat(API): Add Repo Sync [TSI-1923] (#569)
1 parent 721a126 commit 0bd1756

15 files changed

Lines changed: 1048 additions & 1 deletion

doc/compiled.json

Lines changed: 600 additions & 0 deletions
Large diffs are not rendered by default.

lint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
output=$(npx openapi-generator-cli validate -i tmp/compiled.yaml | grep -v "inheritance without use of 'discriminator.propertyName'" | grep -v "No validation issues detected.")
3+
output=$(npx openapi-generator-cli validate -i tmp/compiled.yaml | grep -v "No validation issues detected.")
44
if echo "$output" | grep -q -E "WARN|ERROR"; then
55
echo "$output"
66
echo "Validation errors"

main.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ tags:
195195
- name: Projects
196196
- name: Quality
197197
- name: Releases
198+
- name: Repo Syncs
199+
description: |
200+
The Repo Syncs API allows you to synchronize your Phrase projects with your code repositories.
201+
You can import translations from your repository to Phrase and export translations from Phrase to your repository.
198202
- name: Reports
199203
- name: Search
200204
- name: Screenshot Markers

parameters.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ query_account_id:
4646
required: false
4747
schema:
4848
type: string
49+
repo_sync_id:
50+
in: path
51+
name: repo_sync_id
52+
description: Repo Sync ID
53+
required: true
54+
schema:
55+
type: string
4956
space_id:
5057
in: path
5158
name: space_id

paths.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,27 @@
510510
"/projects/{project_id}/quality_performance_score":
511511
post:
512512
"$ref": "./paths/quality_performance_score/index.yaml"
513+
"/accounts/{account_id}/repo_syncs":
514+
get:
515+
"$ref": "./paths/repo_syncs/index.yaml"
516+
"/accounts/{account_id}/repo_syncs/{repo_sync_id}":
517+
get:
518+
"$ref": "./paths/repo_syncs/show.yaml"
519+
"/accounts/{account_id}/repo_syncs/{repo_sync_id}/export":
520+
post:
521+
"$ref": "./paths/repo_syncs/export.yaml"
522+
"/accounts/{account_id}/repo_syncs/{repo_sync_id}/import":
523+
post:
524+
"$ref": "./paths/repo_syncs/import.yaml"
525+
"/accounts/{account_id}/repo_syncs/{repo_sync_id}/events":
526+
get:
527+
"$ref": "./paths/repo_syncs/events.yaml"
528+
"/accounts/{account_id}/repo_syncs/{repo_sync_id}/deactivate":
529+
post:
530+
"$ref": "./paths/repo_syncs/deactivate.yaml"
531+
"/accounts/{account_id}/repo_syncs/{repo_sync_id}/activate":
532+
post:
533+
"$ref": "./paths/repo_syncs/activate.yaml"
513534
"/accounts/{account_id}/spaces":
514535
get:
515536
"$ref": "./paths/spaces/index.yaml"

paths/repo_syncs/activate.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
summary: Activate a Repo Sync
3+
description: |-
4+
Activate a deactivated Repo Sync. Active syncs can be used to import and export translations,
5+
and imports to Phrase are automatically triggered by pushes to the repository, if configured.
6+
operationId: repo_sync/activate
7+
tags:
8+
- Repo Syncs
9+
parameters:
10+
- "$ref": "../../parameters.yaml#/X-PhraseApp-OTP"
11+
- "$ref": "../../parameters.yaml#/account_id"
12+
- "$ref": "../../parameters.yaml#/repo_sync_id"
13+
responses:
14+
'200':
15+
description: OK
16+
content:
17+
application/json:
18+
schema:
19+
$ref: "../../schemas/repo_sync.yaml#/repo_sync"
20+
headers:
21+
X-Rate-Limit-Limit:
22+
"$ref": "../../headers.yaml#/X-Rate-Limit-Limit"
23+
X-Rate-Limit-Remaining:
24+
"$ref": "../../headers.yaml#/X-Rate-Limit-Remaining"
25+
X-Rate-Limit-Reset:
26+
"$ref": "../../headers.yaml#/X-Rate-Limit-Reset"
27+
'400':
28+
"$ref": "../../responses.yaml#/400"
29+
'404':
30+
"$ref": "../../responses.yaml#/404"
31+
'429':
32+
"$ref": "../../responses.yaml#/429"
33+
x-code-samples:
34+
- lang: Curl
35+
source: |-
36+
curl "https://api.phrase.com/v2/accounts/ab12cd34/repo_syncs/45ef6789/activate"\
37+
-u USERNAME_OR_ACCESS_TOKEN \
38+
-X POST \
39+
-H 'Content-Type: application/json'
40+
- lang: CLI v2
41+
source: |-
42+
phrase repo_sync activate \
43+
--repo_sync_id <repo_sync_id> \
44+
--access_token <token>
45+
x-cli-version: '2.24'

paths/repo_syncs/deactivate.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
summary: Deactivate a Repo Sync
3+
description: |-
4+
Deactivate an active Repo Sync. Import and export can't be performed on deactivated syncs
5+
and the pushes to the repository won't trigger the import to Phrase.
6+
operationId: repo_sync/deactivate
7+
tags:
8+
- Repo Syncs
9+
parameters:
10+
- "$ref": "../../parameters.yaml#/X-PhraseApp-OTP"
11+
- "$ref": "../../parameters.yaml#/account_id"
12+
- "$ref": "../../parameters.yaml#/repo_sync_id"
13+
responses:
14+
'200':
15+
description: OK
16+
content:
17+
application/json:
18+
schema:
19+
$ref: "../../schemas/repo_sync.yaml#/repo_sync"
20+
headers:
21+
X-Rate-Limit-Limit:
22+
"$ref": "../../headers.yaml#/X-Rate-Limit-Limit"
23+
X-Rate-Limit-Remaining:
24+
"$ref": "../../headers.yaml#/X-Rate-Limit-Remaining"
25+
X-Rate-Limit-Reset:
26+
"$ref": "../../headers.yaml#/X-Rate-Limit-Reset"
27+
'400':
28+
"$ref": "../../responses.yaml#/400"
29+
'404':
30+
"$ref": "../../responses.yaml#/404"
31+
'429':
32+
"$ref": "../../responses.yaml#/429"
33+
x-code-samples:
34+
- lang: Curl
35+
source: |-
36+
curl "https://api.phrase.com/v2/accounts/ab12cd34/repo_syncs/45ef6789/deactivate"\
37+
-u USERNAME_OR_ACCESS_TOKEN \
38+
-X POST \
39+
-H 'Content-Type: application/json'
40+
- lang: CLI v2
41+
source: |-
42+
phrase repo_sync deactivate \
43+
--repo_sync_id <repo_sync_id> \
44+
--access_token <token>
45+
x-cli-version: '2.24'

paths/repo_syncs/events.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
summary: "Repository Syncs History"
2+
description: |-
3+
Get the history of a single Repo Sync. The history includes all imports and exports
4+
performed by the Repo Sync.
5+
operationId: repo_sync/events
6+
tags:
7+
- Repo Syncs
8+
parameters:
9+
- "$ref": "../../parameters.yaml#/X-PhraseApp-OTP"
10+
- "$ref": "../../parameters.yaml#/account_id"
11+
- "$ref": "../../parameters.yaml#/repo_sync_id"
12+
responses:
13+
'200':
14+
description: Successful response
15+
content:
16+
application/json:
17+
schema:
18+
type: array
19+
items:
20+
"$ref": "../../schemas/repo_sync_event.yaml#/repo_sync_event"
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"
28+
Link:
29+
"$ref": "../../headers.yaml#/Link"
30+
Pagination:
31+
"$ref": "../../headers.yaml#/Pagination"
32+
'400':
33+
"$ref": "../../responses.yaml#/400"
34+
'404':
35+
"$ref": "../../responses.yaml#/404"
36+
'429':
37+
"$ref": "../../responses.yaml#/429"
38+
x-code-samples:
39+
- lang: Curl
40+
source: |-
41+
curl "https://api.phrase.com/v2/accounts/ab12cd34/repo_syncs/56ef78/events"\
42+
-u USERNAME_OR_ACCESS_TOKEN
43+
- lang: CLI v2
44+
source: |-
45+
phrase repo_sync events \
46+
--id <id> \
47+
--account_id abcd1234 \
48+
--access_token <token>
49+
x-cli-version: '2.24'

paths/repo_syncs/export.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
summary: Export to code repository
3+
description: |-
4+
> Beta: this feature will change in the future.
5+
6+
Export translations from Phrase Strings to repository provider according to the
7+
.phrase.yml file within the code repository.
8+
9+
*Export is done asynchronously and may take several seconds depending on the project size.*
10+
operationId: repo_sync/export
11+
tags:
12+
- Repo Syncs
13+
parameters:
14+
- "$ref": "../../parameters.yaml#/X-PhraseApp-OTP"
15+
- "$ref": "../../parameters.yaml#/account_id"
16+
- "$ref": "../../parameters.yaml#/repo_sync_id"
17+
responses:
18+
'200':
19+
description: OK
20+
content:
21+
application/json:
22+
schema:
23+
type: object
24+
title: repo_sync/export
25+
properties:
26+
message:
27+
type: string
28+
example: Export started
29+
headers:
30+
X-Rate-Limit-Limit:
31+
"$ref": "../../headers.yaml#/X-Rate-Limit-Limit"
32+
X-Rate-Limit-Remaining:
33+
"$ref": "../../headers.yaml#/X-Rate-Limit-Remaining"
34+
X-Rate-Limit-Reset:
35+
"$ref": "../../headers.yaml#/X-Rate-Limit-Reset"
36+
'400':
37+
"$ref": "../../responses.yaml#/400"
38+
'404':
39+
"$ref": "../../responses.yaml#/404"
40+
'429':
41+
"$ref": "../../responses.yaml#/429"
42+
x-code-samples:
43+
- lang: Curl
44+
source: |-
45+
curl "https://api.phrase.com/v2/accounts/ab12cd34/repo_syncs/45ef6789/export"\
46+
-u USERNAME_OR_ACCESS_TOKEN \
47+
-X POST \
48+
-H 'Content-Type: application/json'
49+
- lang: CLI v2
50+
source: |-
51+
phrase repo_sync export \
52+
--repo_sync_id <repo_sync_id> \
53+
--access_token <token>
54+
x-cli-version: '2.24'

paths/repo_syncs/import.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
summary: Import from code repository
3+
description: |-
4+
> Beta: this feature will change in the future.
5+
6+
Import translations from repository provider to Phrase Strings according to the .phrase.yml file
7+
within the code repository.
8+
9+
_Import is done asynchronously and may take several seconds depending on the project size._
10+
operationId: repo_sync/import
11+
tags:
12+
- Repo Syncs
13+
parameters:
14+
- "$ref": "../../parameters.yaml#/X-PhraseApp-OTP"
15+
- "$ref": "../../parameters.yaml#/account_id"
16+
- "$ref": "../../parameters.yaml#/repo_sync_id"
17+
responses:
18+
'200':
19+
description: OK
20+
content:
21+
application/json:
22+
schema:
23+
type: object
24+
title: repo_sync/import
25+
properties:
26+
message:
27+
type: string
28+
example: Import started
29+
headers:
30+
X-Rate-Limit-Limit:
31+
"$ref": "../../headers.yaml#/X-Rate-Limit-Limit"
32+
X-Rate-Limit-Remaining:
33+
"$ref": "../../headers.yaml#/X-Rate-Limit-Remaining"
34+
X-Rate-Limit-Reset:
35+
"$ref": "../../headers.yaml#/X-Rate-Limit-Reset"
36+
'400':
37+
"$ref": "../../responses.yaml#/400"
38+
'404':
39+
"$ref": "../../responses.yaml#/404"
40+
'429':
41+
"$ref": "../../responses.yaml#/429"
42+
x-code-samples:
43+
- lang: Curl
44+
source: |-
45+
curl "https://api.phrase.com/v2/accounts/ab12cd34/repo_syncs/45ef6789/import"\
46+
-u USERNAME_OR_ACCESS_TOKEN \
47+
-X POST \
48+
-H 'Content-Type: application/json'
49+
- lang: CLI v2
50+
source: |-
51+
phrase repo_sync import \
52+
--repo_sync_id <repo_sync_id> \
53+
--access_token <token>
54+
x-cli-version: '2.24'

0 commit comments

Comments
 (0)