Skip to content

Commit

Permalink
feat(API): Add Repo Sync [TSI-1923] (#569)
Browse files Browse the repository at this point in the history
  • Loading branch information
jablan authored Apr 17, 2024
1 parent 721a126 commit 0bd1756
Show file tree
Hide file tree
Showing 15 changed files with 1,048 additions and 1 deletion.
600 changes: 600 additions & 0 deletions doc/compiled.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

output=$(npx openapi-generator-cli validate -i tmp/compiled.yaml | grep -v "inheritance without use of 'discriminator.propertyName'" | grep -v "No validation issues detected.")
output=$(npx openapi-generator-cli validate -i tmp/compiled.yaml | grep -v "No validation issues detected.")
if echo "$output" | grep -q -E "WARN|ERROR"; then
echo "$output"
echo "Validation errors"
Expand Down
4 changes: 4 additions & 0 deletions main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ tags:
- name: Projects
- name: Quality
- name: Releases
- name: Repo Syncs
description: |
The Repo Syncs API allows you to synchronize your Phrase projects with your code repositories.
You can import translations from your repository to Phrase and export translations from Phrase to your repository.
- name: Reports
- name: Search
- name: Screenshot Markers
Expand Down
7 changes: 7 additions & 0 deletions parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ query_account_id:
required: false
schema:
type: string
repo_sync_id:
in: path
name: repo_sync_id
description: Repo Sync ID
required: true
schema:
type: string
space_id:
in: path
name: space_id
Expand Down
21 changes: 21 additions & 0 deletions paths.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,27 @@
"/projects/{project_id}/quality_performance_score":
post:
"$ref": "./paths/quality_performance_score/index.yaml"
"/accounts/{account_id}/repo_syncs":
get:
"$ref": "./paths/repo_syncs/index.yaml"
"/accounts/{account_id}/repo_syncs/{repo_sync_id}":
get:
"$ref": "./paths/repo_syncs/show.yaml"
"/accounts/{account_id}/repo_syncs/{repo_sync_id}/export":
post:
"$ref": "./paths/repo_syncs/export.yaml"
"/accounts/{account_id}/repo_syncs/{repo_sync_id}/import":
post:
"$ref": "./paths/repo_syncs/import.yaml"
"/accounts/{account_id}/repo_syncs/{repo_sync_id}/events":
get:
"$ref": "./paths/repo_syncs/events.yaml"
"/accounts/{account_id}/repo_syncs/{repo_sync_id}/deactivate":
post:
"$ref": "./paths/repo_syncs/deactivate.yaml"
"/accounts/{account_id}/repo_syncs/{repo_sync_id}/activate":
post:
"$ref": "./paths/repo_syncs/activate.yaml"
"/accounts/{account_id}/spaces":
get:
"$ref": "./paths/spaces/index.yaml"
Expand Down
45 changes: 45 additions & 0 deletions paths/repo_syncs/activate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
summary: Activate a Repo Sync
description: |-
Activate a deactivated Repo Sync. Active syncs can be used to import and export translations,
and imports to Phrase are automatically triggered by pushes to the repository, if configured.
operationId: repo_sync/activate
tags:
- Repo Syncs
parameters:
- "$ref": "../../parameters.yaml#/X-PhraseApp-OTP"
- "$ref": "../../parameters.yaml#/account_id"
- "$ref": "../../parameters.yaml#/repo_sync_id"
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: "../../schemas/repo_sync.yaml#/repo_sync"
headers:
X-Rate-Limit-Limit:
"$ref": "../../headers.yaml#/X-Rate-Limit-Limit"
X-Rate-Limit-Remaining:
"$ref": "../../headers.yaml#/X-Rate-Limit-Remaining"
X-Rate-Limit-Reset:
"$ref": "../../headers.yaml#/X-Rate-Limit-Reset"
'400':
"$ref": "../../responses.yaml#/400"
'404':
"$ref": "../../responses.yaml#/404"
'429':
"$ref": "../../responses.yaml#/429"
x-code-samples:
- lang: Curl
source: |-
curl "https://api.phrase.com/v2/accounts/ab12cd34/repo_syncs/45ef6789/activate"\
-u USERNAME_OR_ACCESS_TOKEN \
-X POST \
-H 'Content-Type: application/json'
- lang: CLI v2
source: |-
phrase repo_sync activate \
--repo_sync_id <repo_sync_id> \
--access_token <token>
x-cli-version: '2.24'
45 changes: 45 additions & 0 deletions paths/repo_syncs/deactivate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
summary: Deactivate a Repo Sync
description: |-
Deactivate an active Repo Sync. Import and export can't be performed on deactivated syncs
and the pushes to the repository won't trigger the import to Phrase.
operationId: repo_sync/deactivate
tags:
- Repo Syncs
parameters:
- "$ref": "../../parameters.yaml#/X-PhraseApp-OTP"
- "$ref": "../../parameters.yaml#/account_id"
- "$ref": "../../parameters.yaml#/repo_sync_id"
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: "../../schemas/repo_sync.yaml#/repo_sync"
headers:
X-Rate-Limit-Limit:
"$ref": "../../headers.yaml#/X-Rate-Limit-Limit"
X-Rate-Limit-Remaining:
"$ref": "../../headers.yaml#/X-Rate-Limit-Remaining"
X-Rate-Limit-Reset:
"$ref": "../../headers.yaml#/X-Rate-Limit-Reset"
'400':
"$ref": "../../responses.yaml#/400"
'404':
"$ref": "../../responses.yaml#/404"
'429':
"$ref": "../../responses.yaml#/429"
x-code-samples:
- lang: Curl
source: |-
curl "https://api.phrase.com/v2/accounts/ab12cd34/repo_syncs/45ef6789/deactivate"\
-u USERNAME_OR_ACCESS_TOKEN \
-X POST \
-H 'Content-Type: application/json'
- lang: CLI v2
source: |-
phrase repo_sync deactivate \
--repo_sync_id <repo_sync_id> \
--access_token <token>
x-cli-version: '2.24'
49 changes: 49 additions & 0 deletions paths/repo_syncs/events.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
summary: "Repository Syncs History"
description: |-
Get the history of a single Repo Sync. The history includes all imports and exports
performed by the Repo Sync.
operationId: repo_sync/events
tags:
- Repo Syncs
parameters:
- "$ref": "../../parameters.yaml#/X-PhraseApp-OTP"
- "$ref": "../../parameters.yaml#/account_id"
- "$ref": "../../parameters.yaml#/repo_sync_id"
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: array
items:
"$ref": "../../schemas/repo_sync_event.yaml#/repo_sync_event"
headers:
X-Rate-Limit-Limit:
"$ref": "../../headers.yaml#/X-Rate-Limit-Limit"
X-Rate-Limit-Remaining:
"$ref": "../../headers.yaml#/X-Rate-Limit-Remaining"
X-Rate-Limit-Reset:
"$ref": "../../headers.yaml#/X-Rate-Limit-Reset"
Link:
"$ref": "../../headers.yaml#/Link"
Pagination:
"$ref": "../../headers.yaml#/Pagination"
'400':
"$ref": "../../responses.yaml#/400"
'404':
"$ref": "../../responses.yaml#/404"
'429':
"$ref": "../../responses.yaml#/429"
x-code-samples:
- lang: Curl
source: |-
curl "https://api.phrase.com/v2/accounts/ab12cd34/repo_syncs/56ef78/events"\
-u USERNAME_OR_ACCESS_TOKEN
- lang: CLI v2
source: |-
phrase repo_sync events \
--id <id> \
--account_id abcd1234 \
--access_token <token>
x-cli-version: '2.24'
54 changes: 54 additions & 0 deletions paths/repo_syncs/export.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
summary: Export to code repository
description: |-
> Beta: this feature will change in the future.
Export translations from Phrase Strings to repository provider according to the
.phrase.yml file within the code repository.
*Export is done asynchronously and may take several seconds depending on the project size.*
operationId: repo_sync/export
tags:
- Repo Syncs
parameters:
- "$ref": "../../parameters.yaml#/X-PhraseApp-OTP"
- "$ref": "../../parameters.yaml#/account_id"
- "$ref": "../../parameters.yaml#/repo_sync_id"
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
title: repo_sync/export
properties:
message:
type: string
example: Export started
headers:
X-Rate-Limit-Limit:
"$ref": "../../headers.yaml#/X-Rate-Limit-Limit"
X-Rate-Limit-Remaining:
"$ref": "../../headers.yaml#/X-Rate-Limit-Remaining"
X-Rate-Limit-Reset:
"$ref": "../../headers.yaml#/X-Rate-Limit-Reset"
'400':
"$ref": "../../responses.yaml#/400"
'404':
"$ref": "../../responses.yaml#/404"
'429':
"$ref": "../../responses.yaml#/429"
x-code-samples:
- lang: Curl
source: |-
curl "https://api.phrase.com/v2/accounts/ab12cd34/repo_syncs/45ef6789/export"\
-u USERNAME_OR_ACCESS_TOKEN \
-X POST \
-H 'Content-Type: application/json'
- lang: CLI v2
source: |-
phrase repo_sync export \
--repo_sync_id <repo_sync_id> \
--access_token <token>
x-cli-version: '2.24'
54 changes: 54 additions & 0 deletions paths/repo_syncs/import.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
summary: Import from code repository
description: |-
> Beta: this feature will change in the future.
Import translations from repository provider to Phrase Strings according to the .phrase.yml file
within the code repository.
_Import is done asynchronously and may take several seconds depending on the project size._
operationId: repo_sync/import
tags:
- Repo Syncs
parameters:
- "$ref": "../../parameters.yaml#/X-PhraseApp-OTP"
- "$ref": "../../parameters.yaml#/account_id"
- "$ref": "../../parameters.yaml#/repo_sync_id"
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
title: repo_sync/import
properties:
message:
type: string
example: Import started
headers:
X-Rate-Limit-Limit:
"$ref": "../../headers.yaml#/X-Rate-Limit-Limit"
X-Rate-Limit-Remaining:
"$ref": "../../headers.yaml#/X-Rate-Limit-Remaining"
X-Rate-Limit-Reset:
"$ref": "../../headers.yaml#/X-Rate-Limit-Reset"
'400':
"$ref": "../../responses.yaml#/400"
'404':
"$ref": "../../responses.yaml#/404"
'429':
"$ref": "../../responses.yaml#/429"
x-code-samples:
- lang: Curl
source: |-
curl "https://api.phrase.com/v2/accounts/ab12cd34/repo_syncs/45ef6789/import"\
-u USERNAME_OR_ACCESS_TOKEN \
-X POST \
-H 'Content-Type: application/json'
- lang: CLI v2
source: |-
phrase repo_sync import \
--repo_sync_id <repo_sync_id> \
--access_token <token>
x-cli-version: '2.24'
46 changes: 46 additions & 0 deletions paths/repo_syncs/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
summary: Get Repo Syncs
description: Lists all Repo Syncs from an account
operationId: repo_sync/list
tags:
- Repo Syncs
parameters:
- "$ref": "../../parameters.yaml#/X-PhraseApp-OTP"
- "$ref": "../../parameters.yaml#/account_id"
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
"$ref": "../../schemas/repo_sync.yaml#/repo_sync"
headers:
X-Rate-Limit-Limit:
"$ref": "../../headers.yaml#/X-Rate-Limit-Limit"
X-Rate-Limit-Remaining:
"$ref": "../../headers.yaml#/X-Rate-Limit-Remaining"
X-Rate-Limit-Reset:
"$ref": "../../headers.yaml#/X-Rate-Limit-Reset"
Link:
"$ref": "../../headers.yaml#/Link"
Pagination:
"$ref": "../../headers.yaml#/Pagination"
'400':
"$ref": "../../responses.yaml#/400"
'404':
"$ref": "../../responses.yaml#/404"
'429':
"$ref": "../../responses.yaml#/429"
x-code-samples:
- lang: Curl
source: |-
curl "https://api.phrase.com/v2/accounts/ab12cd34/repo_syncs"\
-u USERNAME_OR_ACCESS_TOKEN
- lang: CLI v2
source: |-
phrase repo_sync list \
--account_id abcd1234 \
--access_token <token>
x-cli-version: '2.24'
Loading

0 comments on commit 0bd1756

Please sign in to comment.