Skip to content

Commit e5be827

Browse files
feat(specs): add put task endpoint to ingestion api (generated)
algolia/api-clients-automation#5281 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Clément Vannicatte <vannicattec@gmail.com>
1 parent 15cf7cc commit e5be827

File tree

5 files changed

+105
-2
lines changed

5 files changed

+105
-2
lines changed

packages/ingestion/model/clientMethodProps.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import type { SourceSortKeys } from '../model/sourceSortKeys';
3030
import type { SourceType } from '../model/sourceType';
3131
import type { SourceUpdate } from '../model/sourceUpdate';
3232

33+
import type { TaskReplace } from '../model/taskReplace';
34+
3335
import type { TaskSortKeys } from '../model/taskSortKeys';
3436
import type { TaskUpdate } from '../model/taskUpdate';
3537

@@ -616,6 +618,17 @@ export type PushTaskProps = {
616618
watch?: boolean | undefined;
617619
};
618620

621+
/**
622+
* Properties for the `replaceTask` method.
623+
*/
624+
export type ReplaceTaskProps = {
625+
/**
626+
* Unique identifier of a task.
627+
*/
628+
taskID: string;
629+
taskReplace: TaskReplace;
630+
};
631+
619632
/**
620633
* Properties for the `runSource` method.
621634
*/

packages/ingestion/model/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ export * from './taskCreateResponse';
126126
export * from './taskCreateTrigger';
127127
export * from './taskCreateV1';
128128
export * from './taskInput';
129+
export * from './taskReplace';
129130
export * from './taskSearch';
130131
export * from './taskSortKeys';
131132
export * from './taskUpdate';
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
2+
3+
import type { ActionType } from './actionType';
4+
import type { Notifications } from './notifications';
5+
import type { Policies } from './policies';
6+
import type { TaskInput } from './taskInput';
7+
8+
/**
9+
* API request body for updating a task.
10+
*/
11+
export type TaskReplace = {
12+
/**
13+
* Universally unique identifier (UUID) of a destination resource.
14+
*/
15+
destinationID: string;
16+
17+
action: ActionType;
18+
19+
subscriptionAction?: ActionType | undefined;
20+
21+
/**
22+
* Cron expression for the task\'s schedule.
23+
*/
24+
cron?: string | undefined;
25+
26+
/**
27+
* Whether the task is enabled.
28+
*/
29+
enabled?: boolean | undefined;
30+
31+
/**
32+
* Maximum accepted percentage of failures for a task run to finish successfully.
33+
*/
34+
failureThreshold?: number | undefined;
35+
36+
input?: TaskInput | undefined;
37+
38+
/**
39+
* Date of the last cursor in RFC 3339 format.
40+
*/
41+
cursor?: string | undefined;
42+
43+
notifications?: Notifications | undefined;
44+
45+
policies?: Policies | undefined;
46+
};

packages/ingestion/model/taskUpdate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { Policies } from './policies';
66
import type { TaskInput } from './taskInput';
77

88
/**
9-
* API request body for updating a task.
9+
* API request body for partially updating a task.
1010
*/
1111
export type TaskUpdate = {
1212
/**

packages/ingestion/src/ingestionClient.ts

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import type { Task } from '../model/task';
5151
import type { TaskCreate } from '../model/taskCreate';
5252
import type { TaskCreateResponse } from '../model/taskCreateResponse';
5353
import type { TaskCreateV1 } from '../model/taskCreateV1';
54+
5455
import type { TaskSearch } from '../model/taskSearch';
5556

5657
import type { TaskUpdateResponse } from '../model/taskUpdateResponse';
@@ -101,6 +102,7 @@ import type {
101102
ListTransformationsProps,
102103
PushProps,
103104
PushTaskProps,
105+
ReplaceTaskProps,
104106
RunSourceProps,
105107
RunTaskProps,
106108
RunTaskV1Props,
@@ -1911,6 +1913,47 @@ export function createIngestionClient({
19111913
return transporter.request(request, requestOptions);
19121914
},
19131915

1916+
/**
1917+
* Fully updates a task by its ID, use partialUpdateTask if you only want to update a subset of fields.
1918+
* @param replaceTask - The replaceTask object.
1919+
* @param replaceTask.taskID - Unique identifier of a task.
1920+
* @param replaceTask.taskReplace - The taskReplace object.
1921+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1922+
*/
1923+
replaceTask(
1924+
{ taskID, taskReplace }: ReplaceTaskProps,
1925+
requestOptions?: RequestOptions,
1926+
): Promise<TaskUpdateResponse> {
1927+
if (!taskID) {
1928+
throw new Error('Parameter `taskID` is required when calling `replaceTask`.');
1929+
}
1930+
1931+
if (!taskReplace) {
1932+
throw new Error('Parameter `taskReplace` is required when calling `replaceTask`.');
1933+
}
1934+
1935+
if (!taskReplace.destinationID) {
1936+
throw new Error('Parameter `taskReplace.destinationID` is required when calling `replaceTask`.');
1937+
}
1938+
if (!taskReplace.action) {
1939+
throw new Error('Parameter `taskReplace.action` is required when calling `replaceTask`.');
1940+
}
1941+
1942+
const requestPath = '/2/tasks/{taskID}'.replace('{taskID}', encodeURIComponent(taskID));
1943+
const headers: Headers = {};
1944+
const queryParameters: QueryParameters = {};
1945+
1946+
const request: Request = {
1947+
method: 'PUT',
1948+
path: requestPath,
1949+
queryParameters,
1950+
headers,
1951+
data: taskReplace,
1952+
};
1953+
1954+
return transporter.request(request, requestOptions);
1955+
},
1956+
19141957
/**
19151958
* Runs all tasks linked to a source, only available for Shopify, BigCommerce and commercetools sources. Creates one run per task.
19161959
*
@@ -2482,7 +2525,7 @@ export function createIngestionClient({
24822525
},
24832526

24842527
/**
2485-
* Updates a task by its ID.
2528+
* Partially updates a task by its ID.
24862529
* @param updateTask - The updateTask object.
24872530
* @param updateTask.taskID - Unique identifier of a task.
24882531
* @param updateTask.taskUpdate - The taskUpdate object.

0 commit comments

Comments
 (0)