Skip to content

Commit

Permalink
feat(api): Add QPS endpoint and documentation (#521)
Browse files Browse the repository at this point in the history
  • Loading branch information
Varpuspaavi authored Jan 17, 2024
1 parent 162325b commit d22c558
Show file tree
Hide file tree
Showing 5 changed files with 302 additions and 0 deletions.
178 changes: 178 additions & 0 deletions doc/compiled.json
Original file line number Diff line number Diff line change
Expand Up @@ -4652,6 +4652,9 @@
},
"503": {
"description": "Server error"
},
"504": {
"description": "Gateway timeout"
}
}
},
Expand Down Expand Up @@ -21334,6 +21337,181 @@
"x-cli-version": "2.5"
}
},
"/projects/{id}/quality_performance_score": {
"post": {
"summary": "Get project's translations' quality performance scores",
"description": "Get project's translations' quality performance scores",
"operationId": "projects/quality_performance_score",
"tags": [
"Quality performance score"
],
"parameters": [
{
"$ref": "#/components/parameters/X-PhraseApp-OTP"
},
{
"$ref": "#/components/parameters/id"
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"anyOf": [
{
"type": "object",
"title": "error",
"description": "Error field for when the request completely fails",
"properties": {
"error": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"code": {
"type": "string"
}
}
}
}
},
{
"type": "object",
"properties": {
"data": {
"type": "object",
"properties": {
"translations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"engine": {
"type": "string",
"description": "Engine used for the translation scoring"
},
"score": {
"type": "number",
"description": "Quality score for the translation"
},
"id": {
"type": "string",
"description": "One of the translation ids passed in arguments"
}
}
}
}
}
},
"errors": {
"type": "array",
"description": "Array of errors for any failing translation ids",
"items": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"code": {
"type": "string"
},
"id": {
"type": "string",
"description": "One of the translation ids passed in arguments"
}
}
}
}
}
}
],
"example": {
"data": {
"translations": [
{
"engine": "qe_v4",
"score": 0.78,
"id": "translation_id_1"
},
{
"engine": "qe_v4",
"score": 0.95,
"id": "translation_id_2"
}
]
},
"errors": []
}
}
}
},
"headers": {
"X-Rate-Limit-Limit": {
"$ref": "#/components/headers/X-Rate-Limit-Limit"
},
"X-Rate-Limit-Remaining": {
"$ref": "#/components/headers/X-Rate-Limit-Remaining"
},
"X-Rate-Limit-Reset": {
"$ref": "#/components/headers/X-Rate-Limit-Reset"
}
}
},
"400": {
"$ref": "#/components/responses/400"
},
"401": {
"$ref": "#/components/responses/401"
},
"404": {
"$ref": "#/components/responses/404"
},
"422": {
"$ref": "#/components/responses/422"
},
"429": {
"$ref": "#/components/responses/429"
},
"504": {
"$ref": "#/components/responses/504"
}
},
"x-code-samples": [
{
"lang": "Curl",
"source": "curl \"https://api.phrase.com/v2/projects/:id/quality_performance_score\" \\\n -X POST \\\n -u USERNAME_OR_ACCESS_TOKEN \\\n -d '{\"translation_ids\":[\"translation_id_1\", \"translation_id_2\"]}' \\\n -H 'Content-Type: application/json'"
},
{
"lang": "CLI v2",
"source": "phrase projects quality_performance_score \\\n--id <id> \\\n--data '{\"translation_ids\":[\"translation_id_1\", \"translation_id_2\"]}' \\\n--access_token <token>"
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"translation_ids": {
"description": "Translation ids you want to get the quality performance score for",
"type": "array",
"items": {
"type": "string",
"example": "translation_id_1"
}
}
}
}
}
}
},
"x-cli-version": "2.20"
}
},
"/accounts/{account_id}/spaces": {
"get": {
"summary": "List Spaces",
Expand Down
3 changes: 3 additions & 0 deletions paths.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,9 @@
"/projects/{project_id}/orders/{id}/confirm":
patch:
"$ref": "./paths/orders/confirm.yaml"
"/projects/{id}/quality_performance_score":
post:
"$ref": "./paths/quality_performance_score/index.yaml"
"/accounts/{account_id}/spaces":
get:
"$ref": "./paths/spaces/index.yaml"
Expand Down
63 changes: 63 additions & 0 deletions paths/quality_performance_score/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
summary: Get project's translations' quality performance scores
description: Get project's translations' quality performance scores
operationId: projects/quality_performance_score
tags:
- Quality performance score
parameters:
- "$ref": "../../parameters.yaml#/X-PhraseApp-OTP"
- "$ref": "../../parameters.yaml#/id"
responses:
'200':
description: OK
content:
application/json:
schema:
"$ref": "../../schemas/quality_performance_score.yaml#/quality_performance_score"
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"
'401':
"$ref": "../../responses.yaml#/401"
'404':
"$ref": "../../responses.yaml#/404"
'422':
"$ref": "../../responses.yaml#/422"
'429':
"$ref": "../../responses.yaml#/429"
'504':
"$ref": "../../responses.yaml#/504"
x-code-samples:
- lang: Curl
source: |-
curl "https://api.phrase.com/v2/projects/:id/quality_performance_score" \
-X POST \
-u USERNAME_OR_ACCESS_TOKEN \
-d '{"translation_ids":["translation_id_1", "translation_id_2"]}' \
-H 'Content-Type: application/json'
- lang: CLI v2
source: |-
phrase projects quality_performance_score \
--id <id> \
--data '{"translation_ids":["translation_id_1", "translation_id_2"]}' \
--access_token <token>
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
translation_ids:
description: Translation ids you want to get the quality performance score for
type: array
items:
type: string
example: translation_id_1
x-cli-version: '2.20'
2 changes: 2 additions & 0 deletions responses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,5 @@
$ref: "./headers.yaml#/X-Rate-Limit-Reset"
503:
description: Server error
504:
description: Gateway timeout
56 changes: 56 additions & 0 deletions schemas/quality_performance_score.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
quality_performance_score:
anyOf:
- type: object
title: error
description: Error field for when the request completely fails
properties:
error:
type: object
properties:
message:
type: string
code:
type: string
- type: object
properties:
data:
type: object
properties:
translations:
type: array
items:
type: object
properties:
engine:
type: string
description: Engine used for the translation scoring
score:
type: number
description: Quality score for the translation
id:
type: string
description: One of the translation ids passed in arguments
errors:
type: array
description: Array of errors for any failing translation ids
items:
type: object
properties:
message:
type: string
code:
type: string
id:
type: string
description: One of the translation ids passed in arguments
example:
data:
translations:
- engine: "qe_v4"
score: 0.78
id: "translation_id_1"
- engine: "qe_v4"
score: 0.95
id: "translation_id_2"
errors: []

0 comments on commit d22c558

Please sign in to comment.