Skip to content

Commit b7ae19f

Browse files
authored
feat(specs): add transformations endpoints to ingestion (#3215)
1 parent 9cbe719 commit b7ae19f

15 files changed

+455
-0
lines changed

specs/ingestion/common/parameters.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ pathTaskID:
3030
schema:
3131
$ref: './schemas/common.yml#/taskID'
3232

33+
pathTransformationID:
34+
name: transformationID
35+
in: path
36+
required: true
37+
description: Unique identifier of a transformation.
38+
schema:
39+
$ref: './schemas/common.yml#/transformationID'
40+
3341
pathRunID:
3442
name: runID
3543
in: path
@@ -75,3 +83,17 @@ orderKeys:
7583
description: Ascending or descending sort order.
7684
default: desc
7785
enum: [asc, desc]
86+
87+
sort:
88+
name: sort
89+
in: query
90+
description: Property by which to sort the list.
91+
required: false
92+
schema:
93+
$ref: '#/sortKeys'
94+
95+
sortKeys:
96+
type: string
97+
description: Property by which to sort the list.
98+
default: desc
99+
enum: [name, type, updatedAt, createdAt]

specs/ingestion/common/schemas/common.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ taskID:
5555
description: Universally unique identifier (UUID) of a task.
5656
example: 6c02aeb1-775e-418e-870b-1faccd4b2c0f
5757

58+
transformationID:
59+
type: string
60+
# format: uuid
61+
description: Universally unique identifier (UUID) of a transformation.
62+
example: 6c02aeb1-775e-418e-870b-1faccd4b2c0f
63+
5864
runID:
5965
type: string
6066
# format: uuid
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
Transformation:
2+
type: object
3+
additionalProperties: false
4+
properties:
5+
transformationID:
6+
$ref: './common.yml#/transformationID'
7+
code:
8+
$ref: '#/Code'
9+
name:
10+
$ref: '#/Name'
11+
description:
12+
$ref: '#/Description'
13+
createdAt:
14+
$ref: './common.yml#/createdAt'
15+
updatedAt:
16+
$ref: './common.yml#/updatedAt'
17+
required:
18+
- transformationID
19+
- code
20+
- name
21+
- description
22+
- createdAt
23+
24+
Code:
25+
type: string
26+
description: The source code of the transformation.
27+
28+
Name:
29+
type: string
30+
description: The uniquely identified name of your transformation.
31+
32+
Description:
33+
type: string
34+
description: A descriptive name for your transformation of what it does.
35+
36+
TransformationCreate:
37+
type: object
38+
additionalProperties: false
39+
description: API request body for creating a transformation.
40+
properties:
41+
code:
42+
$ref: '#/Code'
43+
name:
44+
$ref: '#/Name'
45+
description:
46+
$ref: '#/Description'
47+
required:
48+
- code
49+
- name
50+
- description
51+
52+
TransformationCreateResponse:
53+
type: object
54+
additionalProperties: false
55+
description: API response for creating a transformation.
56+
properties:
57+
transformationID:
58+
$ref: './common.yml#/transformationID'
59+
createdAt:
60+
$ref: './common.yml#/createdAt'
61+
required:
62+
- transformationID
63+
- createdAt
64+
65+
TransformationUpdateResponse:
66+
type: object
67+
description: API response for updating a transformation.
68+
additionalProperties: false
69+
properties:
70+
transformationID:
71+
$ref: './common.yml#/transformationID'
72+
updatedAt:
73+
$ref: './common.yml#/updatedAt'
74+
required:
75+
- transformationID
76+
- updatedAt
77+
78+
TransformationSearch:
79+
type: object
80+
additionalProperties: false
81+
properties:
82+
transformationsIDs:
83+
type: array
84+
items:
85+
$ref: './common.yml#/transformationID'
86+
required:
87+
- transformationsIDs
88+
89+
TransformationTry:
90+
type: object
91+
additionalProperties: false
92+
properties:
93+
code:
94+
$ref: '#/Code'
95+
sampleRecord:
96+
description: The record to apply the given code to.
97+
type: object
98+
required:
99+
- code
100+
- sampleRecord
101+
102+
TransformationTryResponse:
103+
type: object
104+
additionalProperties: false
105+
properties:
106+
payloads:
107+
type: array
108+
description: The array of records returned by the transformation service.
109+
items:
110+
type: object
111+
error:
112+
type: object
113+
description: The error if the transformation failed.
114+
properties:
115+
code:
116+
description: The error status code.
117+
type: integer
118+
message:
119+
description: A descriptive message explaining the failure.
120+
type: string
121+
required:
122+
- payloads
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
get:
2+
tags:
3+
- transformations
4+
summary: Retrieve a transformation
5+
description: Retrieves a transformation by its ID.
6+
operationId: getTransformation
7+
x-acl:
8+
- addObject
9+
- deleteIndex
10+
- editSettings
11+
parameters:
12+
- $ref: '../../common/parameters.yml#/pathTransformationID'
13+
responses:
14+
'200':
15+
description: OK
16+
content:
17+
application/json:
18+
schema:
19+
$ref: '../../common/schemas/transformation.yml#/Transformation'
20+
'400':
21+
$ref: '../../../common/responses/BadRequest.yml'
22+
23+
put:
24+
tags:
25+
- transformations
26+
summary: Update a transformation
27+
description: Updates a transformation by its ID.
28+
operationId: updateTransformation
29+
parameters:
30+
- $ref: '../../common/parameters.yml#/pathTransformationID'
31+
requestBody:
32+
content:
33+
application/json:
34+
schema:
35+
$ref: '../../common/schemas/transformation.yml#/TransformationCreate'
36+
required: true
37+
responses:
38+
'200':
39+
description: OK
40+
content:
41+
application/json:
42+
schema:
43+
$ref: '../../common/schemas/transformation.yml#/TransformationUpdateResponse'
44+
'400':
45+
$ref: '../../../common/responses/BadRequest.yml'
46+
47+
delete:
48+
tags:
49+
- transformations
50+
summary: Delete a transformation
51+
description: Deletes a transformation by its ID.
52+
operationId: deleteTransformation
53+
parameters:
54+
- $ref: '../../common/parameters.yml#/pathTransformationID'
55+
responses:
56+
'200':
57+
description: OK
58+
content:
59+
application/json:
60+
schema:
61+
$ref: '../../common/schemas/common.yml#/DeleteResponse'
62+
'400':
63+
$ref: '../../../common/responses/BadRequest.yml'
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
get:
2+
tags:
3+
- transformations
4+
summary: List transformations
5+
description: Retrieves a list of transformations.
6+
operationId: getTransformations
7+
x-acl:
8+
- addObject
9+
- deleteIndex
10+
- editSettings
11+
parameters:
12+
- $ref: '../../common/parameters.yml#/sort'
13+
- $ref: '../../common/parameters.yml#/order'
14+
responses:
15+
'200':
16+
description: OK
17+
content:
18+
application/json:
19+
schema:
20+
title: listTransformationsResponse
21+
type: object
22+
description: Configured transformations and pagination information.
23+
additionalProperties: false
24+
properties:
25+
transformations:
26+
type: array
27+
items:
28+
$ref: '../../common/schemas/transformation.yml#/Transformation'
29+
pagination:
30+
$ref: '../../common/schemas/pagination.yml#/Pagination'
31+
required:
32+
- transformations
33+
- pagination
34+
'400':
35+
$ref: '../../../common/responses/BadRequest.yml'
36+
37+
post:
38+
tags:
39+
- transformations
40+
summary: Create a transformation
41+
description: Creates a new transformation.
42+
operationId: createTransformation
43+
requestBody:
44+
description: Request body for creating a transformation.
45+
content:
46+
application/json:
47+
schema:
48+
$ref: '../../common/schemas/transformation.yml#/TransformationCreate'
49+
required: true
50+
responses:
51+
'200':
52+
description: OK
53+
content:
54+
application/json:
55+
schema:
56+
$ref: '../../common/schemas/transformation.yml#/TransformationCreateResponse'
57+
'400':
58+
$ref: '../../../common/responses/BadRequest.yml'
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
post:
2+
tags:
3+
- transformations
4+
summary: Search for transformations
5+
description: Searches for transformations.
6+
operationId: searchTransformations
7+
x-acl:
8+
- addObject
9+
- deleteIndex
10+
- editSettings
11+
requestBody:
12+
content:
13+
application/json:
14+
schema:
15+
$ref: '../../common/schemas/transformation.yml#/TransformationSearch'
16+
required: true
17+
responses:
18+
'200':
19+
description: OK
20+
content:
21+
application/json:
22+
schema:
23+
title: searchTransformationsResponse
24+
type: array
25+
items:
26+
$ref: '../../common/schemas/transformation.yml#/Transformation'
27+
'400':
28+
$ref: '../../../common/responses/BadRequest.yml'
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
post:
2+
tags:
3+
- transformations
4+
summary: Search for transformations
5+
description: Searches for transformations.
6+
operationId: tryTransformations
7+
x-acl:
8+
- addObject
9+
- deleteIndex
10+
- editSettings
11+
requestBody:
12+
content:
13+
application/json:
14+
schema:
15+
$ref: '../../common/schemas/transformation.yml#/TransformationTry'
16+
required: true
17+
responses:
18+
'200':
19+
description: OK
20+
content:
21+
application/json:
22+
schema:
23+
$ref: '../../common/schemas/transformation.yml#/TransformationTryResponse'
24+
'400':
25+
$ref: '../../../common/responses/BadRequest.yml'

specs/ingestion/spec.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ tags:
8888
description: |
8989
Tasks contain information how your data should be read from a source and stored in a destination.
9090
Tasks have _triggers_ which determine when the task should run.
91+
- name: transformations
92+
x-displayName: Transformations
93+
description: |
94+
Transformations allows you to transform a record before it gets indexed in Algolia.
9195
x-tagGroups:
9296
- name: Resources
9397
tags:
@@ -147,6 +151,16 @@ paths:
147151
/1/tasks/{taskID}/disable:
148152
$ref: 'paths/tasks/disableTask.yml'
149153

154+
# transformations API.
155+
/1/transformations:
156+
$ref: 'paths/transformations/transformations.yml'
157+
/1/transformations/try:
158+
$ref: 'paths/transformations/transformationsTry.yml'
159+
/1/transformations/search:
160+
$ref: 'paths/transformations/transformationsSearch.yml'
161+
/1/transformations/{transformationID}:
162+
$ref: 'paths/transformations/transformationID.yml'
163+
150164
# observability API.
151165
/1/runs:
152166
$ref: 'paths/runs/runs.yml'
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[
2+
{
3+
"parameters": {
4+
"code": "foo",
5+
"name": "bar",
6+
"description": "baz"
7+
},
8+
"request": {
9+
"path": "/1/transformations",
10+
"method": "POST",
11+
"body": {
12+
"code": "foo",
13+
"name": "bar",
14+
"description": "baz"
15+
}
16+
}
17+
}
18+
]

0 commit comments

Comments
 (0)