Skip to content

Commit 42905a0

Browse files
feat(specs): add global push endpoint (generated)
algolia/api-clients-automation#4855 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent c95bf1b commit 42905a0

File tree

3 files changed

+76
-13
lines changed

3 files changed

+76
-13
lines changed

packages/ingestion/model/action.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,4 @@
33
/**
44
* Type of indexing operation.
55
*/
6-
export type Action =
7-
| 'addObject'
8-
| 'updateObject'
9-
| 'partialUpdateObject'
10-
| 'partialUpdateObjectNoCreate'
11-
| 'deleteObject'
12-
| 'delete'
13-
| 'clear';
6+
export type Action = 'addObject' | 'updateObject' | 'partialUpdateObject' | 'partialUpdateObjectNoCreate';

packages/ingestion/model/clientMethodProps.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,21 @@ export type ListTransformationsProps = {
580580
order?: OrderKeys;
581581
};
582582

583+
/**
584+
* Properties for the `push` method.
585+
*/
586+
export type PushProps = {
587+
/**
588+
* Name of the index on which to perform the operation.
589+
*/
590+
indexName: string;
591+
pushTaskPayload: PushTaskPayload;
592+
/**
593+
* When provided, the push operation will be synchronous and the API will wait for the ingestion to be finished before responding.
594+
*/
595+
watch?: boolean;
596+
};
597+
583598
/**
584599
* Properties for the `pushTask` method.
585600
*/
@@ -588,9 +603,6 @@ export type PushTaskProps = {
588603
* Unique identifier of a task.
589604
*/
590605
taskID: string;
591-
/**
592-
* Request body of a Search API `batch` request that will be pushed in the Connectors pipeline.
593-
*/
594606
pushTaskPayload: PushTaskPayload;
595607
/**
596608
* When provided, the push operation will be synchronous and the API will wait for the ingestion to be finished before responding.

packages/ingestion/src/ingestionClient.ts

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ import type {
9797
ListTasksProps,
9898
ListTasksV1Props,
9999
ListTransformationsProps,
100+
PushProps,
100101
PushTaskProps,
101102
RunSourceProps,
102103
RunTaskProps,
@@ -1706,15 +1707,72 @@ export function createIngestionClient({
17061707
},
17071708

17081709
/**
1709-
* Push a `batch` request payload through the Pipeline. You can check the status of task pushes with the observability endpoints.
1710+
* Pushes records through the Pipeline, directly to an index. You can make the call synchronous by providing the `watch` parameter, for asynchronous calls, you can use the observability endpoints and/or debugger dashboard to see the status of your task. 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. This method is similar to `pushTask`, but requires an `indexName` instead of a `taskID`. If zero or many tasks are found, an error will be returned.
1711+
*
1712+
* Required API Key ACLs:
1713+
* - addObject
1714+
* - deleteIndex
1715+
* - editSettings
1716+
* @param push - The push object.
1717+
* @param push.indexName - Name of the index on which to perform the operation.
1718+
* @param push.pushTaskPayload - The pushTaskPayload object.
1719+
* @param push.watch - When provided, the push operation will be synchronous and the API will wait for the ingestion to be finished before responding.
1720+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1721+
*/
1722+
push({ indexName, pushTaskPayload, watch }: PushProps, requestOptions?: RequestOptions): Promise<WatchResponse> {
1723+
if (!indexName) {
1724+
throw new Error('Parameter `indexName` is required when calling `push`.');
1725+
}
1726+
1727+
if (!pushTaskPayload) {
1728+
throw new Error('Parameter `pushTaskPayload` is required when calling `push`.');
1729+
}
1730+
1731+
if (!pushTaskPayload.action) {
1732+
throw new Error('Parameter `pushTaskPayload.action` is required when calling `push`.');
1733+
}
1734+
if (!pushTaskPayload.records) {
1735+
throw new Error('Parameter `pushTaskPayload.records` is required when calling `push`.');
1736+
}
1737+
1738+
const requestPath = '/1/push/{indexName}'.replace('{indexName}', encodeURIComponent(indexName));
1739+
const headers: Headers = {};
1740+
const queryParameters: QueryParameters = {};
1741+
1742+
if (watch !== undefined) {
1743+
queryParameters['watch'] = watch.toString();
1744+
}
1745+
1746+
const request: Request = {
1747+
method: 'POST',
1748+
path: requestPath,
1749+
queryParameters,
1750+
headers,
1751+
data: pushTaskPayload,
1752+
};
1753+
1754+
requestOptions = {
1755+
timeouts: {
1756+
connect: 180000,
1757+
read: 180000,
1758+
write: 180000,
1759+
...requestOptions?.timeouts,
1760+
},
1761+
};
1762+
1763+
return transporter.request(request, requestOptions);
1764+
},
1765+
1766+
/**
1767+
* Pushes records through the Pipeline, directly to an index. You can make the call synchronous by providing the `watch` parameter, for asynchronous calls, you can use the observability endpoints and/or debugger dashboard to see the status of your task. 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. This method is similar to `push`, but requires a `taskID` instead of a `indexName`, which is useful when many `destinations` target the same `indexName`.
17101768
*
17111769
* Required API Key ACLs:
17121770
* - addObject
17131771
* - deleteIndex
17141772
* - editSettings
17151773
* @param pushTask - The pushTask object.
17161774
* @param pushTask.taskID - Unique identifier of a task.
1717-
* @param pushTask.pushTaskPayload - Request body of a Search API `batch` request that will be pushed in the Connectors pipeline.
1775+
* @param pushTask.pushTaskPayload - The pushTaskPayload object.
17181776
* @param pushTask.watch - When provided, the push operation will be synchronous and the API will wait for the ingestion to be finished before responding.
17191777
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
17201778
*/

0 commit comments

Comments
 (0)