Skip to content

Commit d4ca2d0

Browse files
feat(API): add pre_translations resource to API (#1224)
Co-authored-by: Sönke Behrendt <soenke.behrendt@gmail.com>
1 parent 22385de commit d4ca2d0

8 files changed

Lines changed: 484 additions & 0 deletions

File tree

doc/compiled.json

Lines changed: 283 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@
147147
{
148148
"name": "Organization Job Templates"
149149
},
150+
{
151+
"name": "Pre Translations"
152+
},
150153
{
151154
"name": "Projects"
152155
},
@@ -2886,6 +2889,53 @@
28862889
"updated_at": "2015-01-28T09:52:53Z"
28872890
}
28882891
},
2892+
"pre_translation": {
2893+
"type": "object",
2894+
"properties": {
2895+
"id": {
2896+
"type": "string",
2897+
"example": "abcd1234cdef1234abcd1234cdef1234"
2898+
},
2899+
"status": {
2900+
"type": "string",
2901+
"enum": [
2902+
"pending",
2903+
"running",
2904+
"success",
2905+
"error"
2906+
],
2907+
"description": "Current execution state of the pre-translation job. Jobs start as `pending` while queued, transition to `running` while executing, and settle to `success` or `error`.\n"
2908+
},
2909+
"translatable_type": {
2910+
"type": "string",
2911+
"enum": [
2912+
"locale",
2913+
"job",
2914+
"translation_key",
2915+
"upload"
2916+
],
2917+
"description": "Resource type that was pre-translated."
2918+
},
2919+
"translatable_id": {
2920+
"type": "string",
2921+
"description": "ID of the targeted resource (locale ID, job ID, key ID, or upload ID).",
2922+
"example": "abcd1234cdef1234abcd1234cdef1234"
2923+
},
2924+
"error": {
2925+
"type": "string",
2926+
"nullable": true,
2927+
"description": "Error message. `null` unless the job's status is `error`."
2928+
},
2929+
"created_at": {
2930+
"type": "string",
2931+
"format": "date-time"
2932+
},
2933+
"updated_at": {
2934+
"type": "string",
2935+
"format": "date-time"
2936+
}
2937+
}
2938+
},
28892939
"translation_version": {
28902940
"type": "object",
28912941
"title": "translation_version",
@@ -16224,6 +16274,239 @@
1622416274
"x-cli-version": "2.5"
1622516275
}
1622616276
},
16277+
"/projects/{project_id}/pre_translations": {
16278+
"get": {
16279+
"summary": "List pre-translation jobs",
16280+
"description": "Returns all pre-translation jobs scoped to a project, ordered by\ncreation date descending.\n",
16281+
"operationId": "pre_translations/list",
16282+
"tags": [
16283+
"Pre Translations"
16284+
],
16285+
"parameters": [
16286+
{
16287+
"$ref": "#/components/parameters/X-PhraseApp-OTP"
16288+
},
16289+
{
16290+
"$ref": "#/components/parameters/If-Modified-Since"
16291+
},
16292+
{
16293+
"$ref": "#/components/parameters/If-None-Match"
16294+
},
16295+
{
16296+
"$ref": "#/components/parameters/project_id"
16297+
},
16298+
{
16299+
"$ref": "#/components/parameters/page"
16300+
},
16301+
{
16302+
"$ref": "#/components/parameters/per_page"
16303+
}
16304+
],
16305+
"responses": {
16306+
"200": {
16307+
"description": "OK",
16308+
"content": {
16309+
"application/json": {
16310+
"schema": {
16311+
"type": "array",
16312+
"items": {
16313+
"$ref": "#/components/schemas/pre_translation"
16314+
}
16315+
}
16316+
}
16317+
},
16318+
"headers": {
16319+
"X-Rate-Limit-Limit": {
16320+
"$ref": "#/components/headers/X-Rate-Limit-Limit"
16321+
},
16322+
"X-Rate-Limit-Remaining": {
16323+
"$ref": "#/components/headers/X-Rate-Limit-Remaining"
16324+
},
16325+
"X-Rate-Limit-Reset": {
16326+
"$ref": "#/components/headers/X-Rate-Limit-Reset"
16327+
},
16328+
"Link": {
16329+
"$ref": "#/components/headers/Link"
16330+
},
16331+
"Pagination": {
16332+
"$ref": "#/components/headers/Pagination"
16333+
}
16334+
}
16335+
},
16336+
"400": {
16337+
"$ref": "#/components/responses/400"
16338+
},
16339+
"401": {
16340+
"$ref": "#/components/responses/401"
16341+
},
16342+
"403": {
16343+
"$ref": "#/components/responses/403",
16344+
"description": "Forbidden. Returned when the access token lacks the `read` scope, when the requesting user is not allowed to list pre-translation jobs in this project, or when the account does not have the `autopilot` plan feature."
16345+
},
16346+
"404": {
16347+
"$ref": "#/components/responses/404"
16348+
},
16349+
"429": {
16350+
"$ref": "#/components/responses/429"
16351+
}
16352+
}
16353+
},
16354+
"post": {
16355+
"summary": "Create a pre-translation job",
16356+
"description": "Triggers a pre-translation job for a resource within a project, addressed\nby `translatable_type` (`locale`, `job`, `translation_key`, or `upload`)\nand `translatable_id` (its ID).\n\nEnqueues machine translation using the project's configured MT engine.\n",
16357+
"operationId": "pre_translation/create",
16358+
"tags": [
16359+
"Pre Translations"
16360+
],
16361+
"parameters": [
16362+
{
16363+
"$ref": "#/components/parameters/X-PhraseApp-OTP"
16364+
},
16365+
{
16366+
"$ref": "#/components/parameters/project_id"
16367+
}
16368+
],
16369+
"requestBody": {
16370+
"required": true,
16371+
"content": {
16372+
"application/json": {
16373+
"schema": {
16374+
"type": "object",
16375+
"title": "pre_translation/create/parameters",
16376+
"properties": {
16377+
"translatable_type": {
16378+
"type": "string",
16379+
"enum": [
16380+
"locale",
16381+
"job",
16382+
"translation_key",
16383+
"upload"
16384+
],
16385+
"description": "Resource type to pre-translate."
16386+
},
16387+
"translatable_id": {
16388+
"type": "string",
16389+
"description": "ID of the targeted resource: locale ID for `locale`, job ID for `job`, key ID for `translation_key`, upload ID for `upload`.\n"
16390+
}
16391+
},
16392+
"example": {
16393+
"translatable_type": "locale",
16394+
"translatable_id": "abcd1234cdef1234abcd1234cdef1234"
16395+
}
16396+
}
16397+
}
16398+
}
16399+
},
16400+
"responses": {
16401+
"202": {
16402+
"description": "Accepted",
16403+
"content": {
16404+
"application/json": {
16405+
"schema": {
16406+
"$ref": "#/components/schemas/pre_translation"
16407+
}
16408+
}
16409+
},
16410+
"headers": {
16411+
"X-Rate-Limit-Limit": {
16412+
"$ref": "#/components/headers/X-Rate-Limit-Limit"
16413+
},
16414+
"X-Rate-Limit-Remaining": {
16415+
"$ref": "#/components/headers/X-Rate-Limit-Remaining"
16416+
},
16417+
"X-Rate-Limit-Reset": {
16418+
"$ref": "#/components/headers/X-Rate-Limit-Reset"
16419+
}
16420+
}
16421+
},
16422+
"400": {
16423+
"$ref": "#/components/responses/400"
16424+
},
16425+
"401": {
16426+
"$ref": "#/components/responses/401"
16427+
},
16428+
"403": {
16429+
"$ref": "#/components/responses/403",
16430+
"description": "Forbidden. Returned when the access token lacks the `write` scope, when the requesting user is not allowed to create pre-translation jobs in this project, when the project is protected, or when the account does not have the `autopilot` plan feature."
16431+
},
16432+
"404": {
16433+
"$ref": "#/components/responses/404"
16434+
},
16435+
"422": {
16436+
"$ref": "#/components/responses/422"
16437+
},
16438+
"429": {
16439+
"$ref": "#/components/responses/429"
16440+
}
16441+
}
16442+
}
16443+
},
16444+
"/projects/{project_id}/pre_translations/{id}": {
16445+
"get": {
16446+
"summary": "Get a single pre-translation job",
16447+
"description": "Returns a single pre-translation job identified by its ID.\n",
16448+
"operationId": "pre_translation/show",
16449+
"tags": [
16450+
"Pre Translations"
16451+
],
16452+
"parameters": [
16453+
{
16454+
"$ref": "#/components/parameters/X-PhraseApp-OTP"
16455+
},
16456+
{
16457+
"$ref": "#/components/parameters/If-Modified-Since"
16458+
},
16459+
{
16460+
"$ref": "#/components/parameters/If-None-Match"
16461+
},
16462+
{
16463+
"$ref": "#/components/parameters/project_id"
16464+
},
16465+
{
16466+
"$ref": "#/components/parameters/id"
16467+
}
16468+
],
16469+
"responses": {
16470+
"200": {
16471+
"description": "OK",
16472+
"content": {
16473+
"application/json": {
16474+
"schema": {
16475+
"$ref": "#/components/schemas/pre_translation"
16476+
}
16477+
}
16478+
},
16479+
"headers": {
16480+
"X-Rate-Limit-Limit": {
16481+
"$ref": "#/components/headers/X-Rate-Limit-Limit"
16482+
},
16483+
"X-Rate-Limit-Remaining": {
16484+
"$ref": "#/components/headers/X-Rate-Limit-Remaining"
16485+
},
16486+
"X-Rate-Limit-Reset": {
16487+
"$ref": "#/components/headers/X-Rate-Limit-Reset"
16488+
}
16489+
}
16490+
},
16491+
"400": {
16492+
"$ref": "#/components/responses/400"
16493+
},
16494+
"401": {
16495+
"$ref": "#/components/responses/401"
16496+
},
16497+
"403": {
16498+
"$ref": "#/components/responses/403",
16499+
"description": "Forbidden. Returned when the access token lacks the `read` scope, when the requesting user is not allowed to read pre-translation jobs in this project, or when the account does not have the `autopilot` plan feature."
16500+
},
16501+
"404": {
16502+
"$ref": "#/components/responses/404"
16503+
},
16504+
"429": {
16505+
"$ref": "#/components/responses/429"
16506+
}
16507+
}
16508+
}
16509+
},
1622716510
"/projects/{project_id}/uploads": {
1622816511
"post": {
1622916512
"summary": "Upload a new file",

main.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ tags:
197197
</div>
198198
- name: Organization Job Template Locales
199199
- name: Organization Job Templates
200+
- name: Pre Translations
200201
- name: Projects
201202
- name: Quality
202203
- name: Releases

paths.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,14 @@
283283
"/projects/{project_id}/webhooks/{id}/test":
284284
post:
285285
"$ref": "./paths/webhooks/test.yaml"
286+
"/projects/{project_id}/pre_translations":
287+
get:
288+
"$ref": "./paths/pre_translations/index.yaml"
289+
post:
290+
"$ref": "./paths/pre_translations/create.yaml"
291+
"/projects/{project_id}/pre_translations/{id}":
292+
get:
293+
"$ref": "./paths/pre_translations/show.yaml"
286294
"/projects/{project_id}/uploads":
287295
post:
288296
"$ref": "./paths/uploads/create.yaml"

paths/pre_translations/create.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
summary: Create a pre-translation job
3+
description: |
4+
Triggers a pre-translation job for a resource within a project, addressed
5+
by `translatable_type` (`locale`, `job`, `translation_key`, or `upload`)
6+
and `translatable_id` (its ID).
7+
8+
Enqueues machine translation using the project's configured MT engine.
9+
operationId: pre_translation/create
10+
tags:
11+
- Pre Translations
12+
parameters:
13+
- "$ref": "../../parameters.yaml#/X-PhraseApp-OTP"
14+
- "$ref": "../../parameters.yaml#/project_id"
15+
requestBody:
16+
required: true
17+
content:
18+
application/json:
19+
schema:
20+
type: object
21+
title: pre_translation/create/parameters
22+
properties:
23+
translatable_type:
24+
type: string
25+
enum:
26+
- locale
27+
- job
28+
- translation_key
29+
- upload
30+
description: Resource type to pre-translate.
31+
translatable_id:
32+
type: string
33+
description: >
34+
ID of the targeted resource: locale ID for `locale`, job ID
35+
for `job`, key ID for `translation_key`, upload ID for
36+
`upload`.
37+
example:
38+
translatable_type: locale
39+
translatable_id: abcd1234cdef1234abcd1234cdef1234
40+
responses:
41+
'202':
42+
description: Accepted
43+
content:
44+
application/json:
45+
schema:
46+
"$ref": "../../schemas/pre_translation.yaml#/pre_translation"
47+
headers:
48+
X-Rate-Limit-Limit:
49+
"$ref": "../../headers.yaml#/X-Rate-Limit-Limit"
50+
X-Rate-Limit-Remaining:
51+
"$ref": "../../headers.yaml#/X-Rate-Limit-Remaining"
52+
X-Rate-Limit-Reset:
53+
"$ref": "../../headers.yaml#/X-Rate-Limit-Reset"
54+
'400':
55+
"$ref": "../../responses.yaml#/400"
56+
'401':
57+
"$ref": "../../responses.yaml#/401"
58+
'403':
59+
"$ref": "../../responses.yaml#/403"
60+
description: Forbidden. Returned when the access token lacks the `write` scope, when the requesting user is not allowed to create pre-translation jobs in this project, when the project is protected, or when the account does not have the `autopilot` plan feature.
61+
'404':
62+
"$ref": "../../responses.yaml#/404"
63+
'422':
64+
"$ref": "../../responses.yaml#/422"
65+
'429':
66+
"$ref": "../../responses.yaml#/429"

0 commit comments

Comments
 (0)