Skip to content

Commit a8339af

Browse files
feat(specs): add v2 endpoints for ingestion
algolia/api-clients-automation#3416 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 7c79439 commit a8339af

File tree

4 files changed

+267
-0
lines changed

4 files changed

+267
-0
lines changed

algoliasearch/src/main/java/com/algolia/api/IngestionClient.java

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2931,6 +2931,77 @@ public CompletableFuture<ListTransformationsResponse> listTransformationsAsync()
29312931
return this.listTransformationsAsync(null, null, null);
29322932
}
29332933

2934+
/**
2935+
* Push a `batch` request payload through the Pipeline. You can check the status of task pushes
2936+
* with the observability endpoints.
2937+
*
2938+
* @param taskID Unique identifier of a task. (required)
2939+
* @param batchWriteParams Request body of a Search API `batch` request that will be pushed in the
2940+
* Connectors pipeline. (required)
2941+
* @param requestOptions The requestOptions to send along with the query, they will be merged with
2942+
* the transporter requestOptions.
2943+
* @throws AlgoliaRuntimeException If it fails to process the API call
2944+
*/
2945+
public RunResponse pushTask(@Nonnull String taskID, @Nonnull BatchWriteParams batchWriteParams, RequestOptions requestOptions)
2946+
throws AlgoliaRuntimeException {
2947+
return LaunderThrowable.await(pushTaskAsync(taskID, batchWriteParams, requestOptions));
2948+
}
2949+
2950+
/**
2951+
* Push a `batch` request payload through the Pipeline. You can check the status of task pushes
2952+
* with the observability endpoints.
2953+
*
2954+
* @param taskID Unique identifier of a task. (required)
2955+
* @param batchWriteParams Request body of a Search API `batch` request that will be pushed in the
2956+
* Connectors pipeline. (required)
2957+
* @throws AlgoliaRuntimeException If it fails to process the API call
2958+
*/
2959+
public RunResponse pushTask(@Nonnull String taskID, @Nonnull BatchWriteParams batchWriteParams) throws AlgoliaRuntimeException {
2960+
return this.pushTask(taskID, batchWriteParams, null);
2961+
}
2962+
2963+
/**
2964+
* (asynchronously) Push a `batch` request payload through the Pipeline. You can check the status
2965+
* of task pushes with the observability endpoints.
2966+
*
2967+
* @param taskID Unique identifier of a task. (required)
2968+
* @param batchWriteParams Request body of a Search API `batch` request that will be pushed in the
2969+
* Connectors pipeline. (required)
2970+
* @param requestOptions The requestOptions to send along with the query, they will be merged with
2971+
* the transporter requestOptions.
2972+
* @throws AlgoliaRuntimeException If it fails to process the API call
2973+
*/
2974+
public CompletableFuture<RunResponse> pushTaskAsync(
2975+
@Nonnull String taskID,
2976+
@Nonnull BatchWriteParams batchWriteParams,
2977+
RequestOptions requestOptions
2978+
) throws AlgoliaRuntimeException {
2979+
Parameters.requireNonNull(taskID, "Parameter `taskID` is required when calling `pushTask`.");
2980+
2981+
Parameters.requireNonNull(batchWriteParams, "Parameter `batchWriteParams` is required when calling `pushTask`.");
2982+
2983+
HttpRequest request = HttpRequest.builder()
2984+
.setPath("/2/tasks/{taskID}/push", taskID)
2985+
.setMethod("POST")
2986+
.setBody(batchWriteParams)
2987+
.build();
2988+
return executeAsync(request, requestOptions, new TypeReference<RunResponse>() {});
2989+
}
2990+
2991+
/**
2992+
* (asynchronously) Push a `batch` request payload through the Pipeline. You can check the status
2993+
* of task pushes with the observability endpoints.
2994+
*
2995+
* @param taskID Unique identifier of a task. (required)
2996+
* @param batchWriteParams Request body of a Search API `batch` request that will be pushed in the
2997+
* Connectors pipeline. (required)
2998+
* @throws AlgoliaRuntimeException If it fails to process the API call
2999+
*/
3000+
public CompletableFuture<RunResponse> pushTaskAsync(@Nonnull String taskID, @Nonnull BatchWriteParams batchWriteParams)
3001+
throws AlgoliaRuntimeException {
3002+
return this.pushTaskAsync(taskID, batchWriteParams, null);
3003+
}
3004+
29343005
/**
29353006
* Runs a task. You can check the status of task runs with the observability endpoints.
29363007
*
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost
2+
// - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
3+
4+
package com.algolia.model.ingestion;
5+
6+
import com.fasterxml.jackson.annotation.*;
7+
import com.fasterxml.jackson.databind.annotation.*;
8+
9+
/** Type of indexing operation. */
10+
public enum Action {
11+
ADD_OBJECT("addObject"),
12+
13+
UPDATE_OBJECT("updateObject"),
14+
15+
PARTIAL_UPDATE_OBJECT("partialUpdateObject"),
16+
17+
PARTIAL_UPDATE_OBJECT_NO_CREATE("partialUpdateObjectNoCreate"),
18+
19+
DELETE_OBJECT("deleteObject"),
20+
21+
DELETE("delete"),
22+
23+
CLEAR("clear");
24+
25+
private final String value;
26+
27+
Action(String value) {
28+
this.value = value;
29+
}
30+
31+
@JsonValue
32+
public String getValue() {
33+
return value;
34+
}
35+
36+
@Override
37+
public String toString() {
38+
return String.valueOf(value);
39+
}
40+
41+
@JsonCreator
42+
public static Action fromValue(String value) {
43+
for (Action b : Action.values()) {
44+
if (b.value.equals(value)) {
45+
return b;
46+
}
47+
}
48+
throw new IllegalArgumentException("Unexpected value '" + value + "'");
49+
}
50+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost
2+
// - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
3+
4+
package com.algolia.model.ingestion;
5+
6+
import com.fasterxml.jackson.annotation.*;
7+
import com.fasterxml.jackson.databind.annotation.*;
8+
import java.util.Objects;
9+
10+
/** BatchRequest */
11+
public class BatchRequest {
12+
13+
@JsonProperty("action")
14+
private Action action;
15+
16+
@JsonProperty("body")
17+
private Object body;
18+
19+
public BatchRequest setAction(Action action) {
20+
this.action = action;
21+
return this;
22+
}
23+
24+
/** Get action */
25+
@javax.annotation.Nonnull
26+
public Action getAction() {
27+
return action;
28+
}
29+
30+
public BatchRequest setBody(Object body) {
31+
this.body = body;
32+
return this;
33+
}
34+
35+
/** Operation arguments (varies with specified `action`). */
36+
@javax.annotation.Nonnull
37+
public Object getBody() {
38+
return body;
39+
}
40+
41+
@Override
42+
public boolean equals(Object o) {
43+
if (this == o) {
44+
return true;
45+
}
46+
if (o == null || getClass() != o.getClass()) {
47+
return false;
48+
}
49+
BatchRequest batchRequest = (BatchRequest) o;
50+
return Objects.equals(this.action, batchRequest.action) && Objects.equals(this.body, batchRequest.body);
51+
}
52+
53+
@Override
54+
public int hashCode() {
55+
return Objects.hash(action, body);
56+
}
57+
58+
@Override
59+
public String toString() {
60+
StringBuilder sb = new StringBuilder();
61+
sb.append("class BatchRequest {\n");
62+
sb.append(" action: ").append(toIndentedString(action)).append("\n");
63+
sb.append(" body: ").append(toIndentedString(body)).append("\n");
64+
sb.append("}");
65+
return sb.toString();
66+
}
67+
68+
/**
69+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
70+
*/
71+
private String toIndentedString(Object o) {
72+
if (o == null) {
73+
return "null";
74+
}
75+
return o.toString().replace("\n", "\n ");
76+
}
77+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost
2+
// - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
3+
4+
package com.algolia.model.ingestion;
5+
6+
import com.fasterxml.jackson.annotation.*;
7+
import com.fasterxml.jackson.databind.annotation.*;
8+
import java.util.ArrayList;
9+
import java.util.List;
10+
import java.util.Objects;
11+
12+
/** Batch parameters. */
13+
public class BatchWriteParams {
14+
15+
@JsonProperty("requests")
16+
private List<BatchRequest> requests = new ArrayList<>();
17+
18+
public BatchWriteParams setRequests(List<BatchRequest> requests) {
19+
this.requests = requests;
20+
return this;
21+
}
22+
23+
public BatchWriteParams addRequests(BatchRequest requestsItem) {
24+
this.requests.add(requestsItem);
25+
return this;
26+
}
27+
28+
/** Get requests */
29+
@javax.annotation.Nonnull
30+
public List<BatchRequest> getRequests() {
31+
return requests;
32+
}
33+
34+
@Override
35+
public boolean equals(Object o) {
36+
if (this == o) {
37+
return true;
38+
}
39+
if (o == null || getClass() != o.getClass()) {
40+
return false;
41+
}
42+
BatchWriteParams batchWriteParams = (BatchWriteParams) o;
43+
return Objects.equals(this.requests, batchWriteParams.requests);
44+
}
45+
46+
@Override
47+
public int hashCode() {
48+
return Objects.hash(requests);
49+
}
50+
51+
@Override
52+
public String toString() {
53+
StringBuilder sb = new StringBuilder();
54+
sb.append("class BatchWriteParams {\n");
55+
sb.append(" requests: ").append(toIndentedString(requests)).append("\n");
56+
sb.append("}");
57+
return sb.toString();
58+
}
59+
60+
/**
61+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
62+
*/
63+
private String toIndentedString(Object o) {
64+
if (o == null) {
65+
return "null";
66+
}
67+
return o.toString().replace("\n", "\n ");
68+
}
69+
}

0 commit comments

Comments
 (0)