Skip to content

Commit 90b49b1

Browse files
authored
feat(specs): add global push endpoint (#4855)
1 parent 54e0508 commit 90b49b1

File tree

6 files changed

+174
-28
lines changed

6 files changed

+174
-28
lines changed

specs/ingestion/common/parameters.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,11 @@ orderKeys:
8383
description: Ascending or descending sort order.
8484
default: desc
8585
enum: [asc, desc]
86+
87+
watch:
88+
name: watch
89+
in: query
90+
description: When provided, the push operation will be synchronous and the API will wait for the ingestion to be finished before responding.
91+
required: false
92+
schema:
93+
type: boolean

specs/ingestion/common/schemas/task.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,3 +606,33 @@ Policies:
606606
type: integer
607607
minimum: 1
608608
maximum: 10
609+
610+
PushTaskPayload:
611+
title: pushTaskPayload
612+
type: object
613+
properties:
614+
action:
615+
$ref: '#/action'
616+
records:
617+
type: array
618+
items:
619+
title: pushTaskRecords
620+
type: object
621+
additionalProperties: true
622+
required:
623+
- objectID
624+
properties:
625+
objectID:
626+
$ref: '../../../common/parameters.yml#/objectID'
627+
required:
628+
- action
629+
- records
630+
631+
action:
632+
type: string
633+
enum:
634+
- addObject
635+
- updateObject
636+
- partialUpdateObject
637+
- partialUpdateObjectNoCreate
638+
description: Type of indexing operation.

specs/ingestion/paths/push.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
post:
2+
summary: Pushes records to be transformed through the Pipeline, directly to an index
3+
description: >
4+
Pushes records through the Pipeline, directly to an index. You can make the call synchronous by providing the `watch` parameter,
5+
for asynchronous calls, you can use the observability endpoints and/or debugger dashboard to see the status of your task.
6+
7+
If you want to leverage the [pre-indexing data transformation](https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/how-to/transform-your-data/), this is the recommended way of ingesting your records.
8+
9+
This method is similar to `pushTask`, but requires an `indexName` instead of a `taskID`. If zero or many tasks are found,
10+
an error will be returned.
11+
operationId: push
12+
x-acl:
13+
- addObject
14+
- deleteIndex
15+
- editSettings
16+
x-timeouts:
17+
connect: 180000
18+
read: 180000
19+
write: 180000
20+
parameters:
21+
- $ref: '../../common/parameters.yml#/IndexName'
22+
- $ref: '../common/parameters.yml#/watch'
23+
requestBody:
24+
content:
25+
application/json:
26+
schema:
27+
$ref: '../common/schemas/task.yml#/PushTaskPayload'
28+
required: true
29+
responses:
30+
'200':
31+
description: OK
32+
content:
33+
application/json:
34+
schema:
35+
$ref: '../common/schemas/common.yml#/WatchResponse'
36+
'400':
37+
$ref: '../../common/responses/BadRequest.yml'

specs/ingestion/paths/tasks/v2/pushTask.yml

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
post:
22
tags:
33
- tasks
4-
summary: Push a `batch` request payload through the Pipeline
5-
description: Push a `batch` request payload through the Pipeline. You can check the status of task pushes with the observability endpoints.
4+
summary: Pushes records to be transformed through the Pipeline, directly to an index
5+
description: >
6+
Pushes records through the Pipeline, directly to an index. You can make the call synchronous by providing the `watch` parameter,
7+
for asynchronous calls, you can use the observability endpoints and/or debugger dashboard to see the status of your task.
8+
9+
If you want to leverage the [pre-indexing data transformation](https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/how-to/transform-your-data/), this is the recommended way of ingesting your records.
10+
11+
This method is similar to `push`, but requires a `taskID` instead of a `indexName`, which is useful when many `destinations` target the same `indexName`.
612
operationId: pushTask
713
x-acl:
814
- addObject
@@ -14,36 +20,12 @@ post:
1420
write: 180000
1521
parameters:
1622
- $ref: '../../../common/parameters.yml#/pathTaskID'
17-
- name: watch
18-
in: query
19-
description: When provided, the push operation will be synchronous and the API will wait for the ingestion to be finished before responding.
20-
required: false
21-
schema:
22-
type: boolean
23+
- $ref: '../../../common/parameters.yml#/watch'
2324
requestBody:
24-
description: Request body of a Search API `batch` request that will be pushed in the Connectors pipeline.
2525
content:
2626
application/json:
2727
schema:
28-
title: pushTaskPayload
29-
type: object
30-
properties:
31-
action:
32-
$ref: '../../../../common/schemas/Batch.yml#/action'
33-
records:
34-
type: array
35-
items:
36-
title: pushTaskRecords
37-
type: object
38-
additionalProperties: true
39-
required:
40-
- objectID
41-
properties:
42-
objectID:
43-
$ref: '../../../../common/parameters.yml#/objectID'
44-
required:
45-
- action
46-
- records
28+
$ref: '../../../common/schemas/task.yml#/PushTaskPayload'
4729
required: true
4830
responses:
4931
'200':

specs/ingestion/spec.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ paths:
112112
/{path}:
113113
$ref: '../common/paths/customRequest.yml'
114114

115+
/1/push/{indexName}:
116+
$ref: 'paths/push.yml'
117+
115118
# authentications API.
116119
/1/authentications:
117120
$ref: 'paths/authentications/authentications.yml'
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
[
2+
{
3+
"testName": "global push",
4+
"parameters": {
5+
"indexName": "foo",
6+
"pushTaskPayload": {
7+
"action": "addObject",
8+
"records": [
9+
{
10+
"key": "bar",
11+
"foo": "1",
12+
"objectID": "o"
13+
},
14+
{
15+
"key": "baz",
16+
"foo": "2",
17+
"objectID": "k"
18+
}
19+
]
20+
}
21+
},
22+
"request": {
23+
"path": "/1/push/foo",
24+
"method": "POST",
25+
"body": {
26+
"action": "addObject",
27+
"records": [
28+
{
29+
"key": "bar",
30+
"foo": "1",
31+
"objectID": "o"
32+
},
33+
{
34+
"key": "baz",
35+
"foo": "2",
36+
"objectID": "k"
37+
}
38+
]
39+
}
40+
}
41+
},
42+
{
43+
"testName": "global push with watch mode",
44+
"parameters": {
45+
"indexName": "bar",
46+
"pushTaskPayload": {
47+
"action": "addObject",
48+
"records": [
49+
{
50+
"key": "bar",
51+
"foo": "1",
52+
"objectID": "o"
53+
},
54+
{
55+
"key": "baz",
56+
"foo": "2",
57+
"objectID": "k"
58+
}
59+
]
60+
},
61+
"watch": true
62+
},
63+
"request": {
64+
"path": "/1/push/bar",
65+
"method": "POST",
66+
"queryParameters": {
67+
"watch": "true"
68+
},
69+
"body": {
70+
"action": "addObject",
71+
"records": [
72+
{
73+
"key": "bar",
74+
"foo": "1",
75+
"objectID": "o"
76+
},
77+
{
78+
"key": "baz",
79+
"foo": "2",
80+
"objectID": "k"
81+
}
82+
]
83+
}
84+
}
85+
}
86+
]

0 commit comments

Comments
 (0)