Skip to content

Commit

Permalink
feat(specs): add v2 endpoints for ingestion
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#3416

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Clément Vannicatte <[email protected]>
  • Loading branch information
algolia-bot and shortcuts committed Jul 25, 2024
1 parent 5ed8335 commit 2412801
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/ingestion/model/action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// 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.

/**
* Type of indexing operation.
*/
export type Action =
| 'addObject'
| 'clear'
| 'delete'
| 'deleteObject'
| 'partialUpdateObject'
| 'partialUpdateObjectNoCreate'
| 'updateObject';
12 changes: 12 additions & 0 deletions packages/ingestion/model/batchRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// 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.

import type { Action } from './action';

export type BatchRequest = {
action: Action;

/**
* Operation arguments (varies with specified `action`).
*/
body: Record<string, any>;
};
10 changes: 10 additions & 0 deletions packages/ingestion/model/batchWriteParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// 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.

import type { BatchRequest } from './batchRequest';

/**
* Batch parameters.
*/
export type BatchWriteParams = {
requests: BatchRequest[];
};
15 changes: 15 additions & 0 deletions packages/ingestion/model/clientMethodProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { ActionType } from './actionType';
import type { AuthenticationSortKeys } from './authenticationSortKeys';
import type { AuthenticationType } from './authenticationType';
import type { AuthenticationUpdate } from './authenticationUpdate';
import type { BatchWriteParams } from './batchWriteParams';
import type { DestinationSortKeys } from './destinationSortKeys';
import type { DestinationType } from './destinationType';
import type { DestinationUpdate } from './destinationUpdate';
Expand Down Expand Up @@ -540,6 +541,20 @@ export type ListTransformationsProps = {
order?: OrderKeys;
};

/**
* Properties for the `pushTask` method.
*/
export type PushTaskProps = {
/**
* Unique identifier of a task.
*/
taskID: string;
/**
* Request body of a Search API `batch` request that will be pushed in the Connectors pipeline.
*/
batchWriteParams: BatchWriteParams;
};

/**
* Properties for the `runTask` method.
*/
Expand Down
3 changes: 3 additions & 0 deletions packages/ingestion/model/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// 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.

export * from './action';
export * from './actionType';
export * from './authAPIKey';
export * from './authAPIKeyPartial';
Expand All @@ -23,6 +24,8 @@ export * from './authenticationSortKeys';
export * from './authenticationType';
export * from './authenticationUpdate';
export * from './authenticationUpdateResponse';
export * from './batchRequest';
export * from './batchWriteParams';
export * from './bigCommerceChannel';
export * from './bigCommerceMetafield';
export * from './bigQueryDataType';
Expand Down
54 changes: 54 additions & 0 deletions packages/ingestion/src/ingestionClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import type {
ListTasksProps,
ListTasksV1Props,
ListTransformationsProps,
PushTaskProps,
RunTaskProps,
RunTaskV1Props,
TriggerDockerSourceDiscoverProps,
Expand Down Expand Up @@ -1907,6 +1908,59 @@ export function createIngestionClient({
return transporter.request(request, requestOptions);
},

/**
* Push a `batch` request payload through the Pipeline. You can check the status of task pushes with the observability endpoints.
*
* Required API Key ACLs:
* - addObject
* - deleteIndex
* - editSettings.
*
* @param pushTask - The pushTask object.
* @param pushTask.taskID - Unique identifier of a task.
* @param pushTask.batchWriteParams - Request body of a Search API `batch` request that will be pushed in the Connectors pipeline.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
pushTask(
{ taskID, batchWriteParams }: PushTaskProps,
requestOptions?: RequestOptions
): Promise<RunResponse> {
if (!taskID) {
throw new Error(
'Parameter `taskID` is required when calling `pushTask`.'
);
}

if (!batchWriteParams) {
throw new Error(
'Parameter `batchWriteParams` is required when calling `pushTask`.'
);
}

if (!batchWriteParams.requests) {
throw new Error(
'Parameter `batchWriteParams.requests` is required when calling `pushTask`.'
);
}

const requestPath = '/2/tasks/{taskID}/push'.replace(
'{taskID}',
encodeURIComponent(taskID)
);
const headers: Headers = {};
const queryParameters: QueryParameters = {};

const request: Request = {
method: 'POST',
path: requestPath,
queryParameters,
headers,
data: batchWriteParams,
};

return transporter.request(request, requestOptions);
},

/**
* Runs a task. You can check the status of task runs with the observability endpoints.
*
Expand Down

0 comments on commit 2412801

Please sign in to comment.