Skip to content

Commit fc20ec3

Browse files
committed
feat(ingestion): add put task endpoint
1 parent 1ae0f1d commit fc20ec3

File tree

4 files changed

+157
-11
lines changed

4 files changed

+157
-11
lines changed

specs/ingestion/common/schemas/task.yml

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,41 @@ TaskCreateResponse:
179179
- taskID
180180
- createdAt
181181

182-
TaskUpdate:
182+
TaskFullUpdate:
183183
type: object
184184
additionalProperties: false
185185
description: API request body for updating a task.
186+
properties:
187+
destinationID:
188+
$ref: './common.yml#/destinationID'
189+
action:
190+
$ref: '#/ActionType'
191+
subscriptionAction:
192+
$ref: '#/ActionType'
193+
cron:
194+
$ref: '#/Cron'
195+
enabled:
196+
type: boolean
197+
description: Whether the task is enabled.
198+
failureThreshold:
199+
$ref: '#/failureThreshold'
200+
input:
201+
$ref: '#/TaskInput'
202+
cursor:
203+
$ref: './common.yml#/cursor'
204+
notifications:
205+
$ref: '#/Notifications'
206+
policies:
207+
$ref: '#/Policies'
208+
required:
209+
- destinationID
210+
- action
211+
212+
# TODO: rename TaskUpdate to TaskPartialUpdate next major
213+
TaskUpdate:
214+
type: object
215+
additionalProperties: false
216+
description: API request body for partially updating a task.
186217
properties:
187218
destinationID:
188219
$ref: './common.yml#/destinationID'
@@ -215,8 +246,7 @@ TaskUpdateV1:
215246
input:
216247
$ref: '#/TaskInput'
217248
enabled:
218-
type: boolean
219-
description: Whether the task is enabled.
249+
$ref: '#/Enabled'
220250
failureThreshold:
221251
$ref: '#/failureThreshold'
222252

@@ -309,6 +339,10 @@ Cron:
309339
description: Cron expression for the task's schedule.
310340
example: '* * 1 * *'
311341

342+
Enabled:
343+
type: boolean
344+
description: Whether the task is enabled.
345+
312346
ScheduleTriggerType:
313347
type: string
314348
description: Task runs on a schedule.

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

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,36 @@ get:
2020
'400':
2121
$ref: '../../../../common/responses/BadRequest.yml'
2222

23+
put:
24+
tags:
25+
- tasks
26+
summary: Fully updates a task
27+
description: Fully updates a task by its ID, use partialUpdateTask if you only want to update a subset of fields.
28+
operationId: fullUpdateTask
29+
parameters:
30+
- $ref: '../../../common/parameters.yml#/pathTaskID'
31+
requestBody:
32+
content:
33+
application/json:
34+
schema:
35+
$ref: '../../../common/schemas/task.yml#/TaskFullUpdate'
36+
required: true
37+
responses:
38+
'200':
39+
description: OK
40+
content:
41+
application/json:
42+
schema:
43+
$ref: '../../../common/schemas/task.yml#/TaskUpdateResponse'
44+
'400':
45+
$ref: '../../../../common/responses/BadRequest.yml'
46+
47+
# TODO: rename taskUpdate to taskPartialUpdate next major
2348
patch:
2449
tags:
2550
- tasks
26-
summary: Update a task
27-
description: Updates a task by its ID.
51+
summary: Partially updates a task
52+
description: Partially updates a task by its ID.
2853
operationId: updateTask
2954
parameters:
3055
- $ref: '../../../common/parameters.yml#/pathTaskID'

tests/CTS/requests/ingestion/createTask.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
"testName": "task without cron",
44
"parameters": {
55
"sourceID": "search",
6-
"destinationID": "destinationName",
6+
"destinationID": "destinationID",
77
"action": "replace"
88
},
99
"request": {
1010
"path": "/2/tasks",
1111
"method": "POST",
1212
"body": {
1313
"sourceID": "search",
14-
"destinationID": "destinationName",
14+
"destinationID": "destinationID",
1515
"action": "replace"
1616
}
1717
}
@@ -20,7 +20,7 @@
2020
"testName": "task with cron",
2121
"parameters": {
2222
"sourceID": "search",
23-
"destinationID": "destinationName",
23+
"destinationID": "destinationID",
2424
"cron": "* * * * *",
2525
"action": "replace",
2626
"notifications": {
@@ -37,7 +37,7 @@
3737
"method": "POST",
3838
"body": {
3939
"sourceID": "search",
40-
"destinationID": "destinationName",
40+
"destinationID": "destinationID",
4141
"cron": "* * * * *",
4242
"action": "replace",
4343
"notifications": {
@@ -55,7 +55,7 @@
5555
"testName": "task shopify",
5656
"parameters": {
5757
"sourceID": "search",
58-
"destinationID": "destinationName",
58+
"destinationID": "destinationID",
5959
"cron": "* * * * *",
6060
"action": "replace",
6161
"input": {
@@ -72,7 +72,7 @@
7272
"method": "POST",
7373
"body": {
7474
"sourceID": "search",
75-
"destinationID": "destinationName",
75+
"destinationID": "destinationID",
7676
"cron": "* * * * *",
7777
"action": "replace",
7878
"input": {
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
[
2+
{
3+
"testName": "task without cron",
4+
"parameters": {
5+
"taskID": "6c02aeb1-775e-418e-870b-1faccd4b2c0f",
6+
"destinationID": "destinationID",
7+
"action": "replace"
8+
},
9+
"request": {
10+
"path": "/2/tasks/6c02aeb1-775e-418e-870b-1faccd4b2c0f",
11+
"method": "POST",
12+
"body": {
13+
"destinationID": "destinationID",
14+
"action": "replace"
15+
}
16+
}
17+
},
18+
{
19+
"testName": "task with cron",
20+
"parameters": {
21+
"taskID": "6c02aeb1-775e-418e-870b-1faccd4b2c0f",
22+
"destinationID": "destinationID",
23+
"cron": "* * * * *",
24+
"action": "replace",
25+
"notifications": {
26+
"email": {
27+
"enabled": true
28+
}
29+
},
30+
"policies": {
31+
"criticalThreshold": 8
32+
}
33+
},
34+
"request": {
35+
"path": "/2/tasks/6c02aeb1-775e-418e-870b-1faccd4b2c0f",
36+
"method": "POST",
37+
"body": {
38+
"destinationID": "destinationID",
39+
"cron": "* * * * *",
40+
"action": "replace",
41+
"notifications": {
42+
"email": {
43+
"enabled": true
44+
}
45+
},
46+
"policies": {
47+
"criticalThreshold": 8
48+
}
49+
}
50+
}
51+
},
52+
{
53+
"testName": "task shopify",
54+
"parameters": {
55+
"taskID": "6c02aeb1-775e-418e-870b-1faccd4b2c0f",
56+
"destinationID": "destinationID",
57+
"cron": "* * * * *",
58+
"action": "replace",
59+
"input": {
60+
"streams": [
61+
{
62+
"name": "foo",
63+
"syncMode": "incremental"
64+
}
65+
]
66+
}
67+
},
68+
"request": {
69+
"path": "/2/tasks/6c02aeb1-775e-418e-870b-1faccd4b2c0f",
70+
"method": "POST",
71+
"body": {
72+
"sourceID": "search",
73+
"destinationID": "destinationID",
74+
"cron": "* * * * *",
75+
"action": "replace",
76+
"input": {
77+
"streams": [
78+
{
79+
"name": "foo",
80+
"syncMode": "incremental"
81+
}
82+
]
83+
}
84+
}
85+
}
86+
}
87+
]

0 commit comments

Comments
 (0)