Skip to content

Commit 788e4c2

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 af396b2 commit 788e4c2

File tree

5 files changed

+169
-0
lines changed

5 files changed

+169
-0
lines changed

src/main/scala/algoliasearch/api/IngestionClient.scala

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import algoliasearch.ingestion.AuthenticationSortKeys._
1212
import algoliasearch.ingestion.AuthenticationType._
1313
import algoliasearch.ingestion.AuthenticationUpdate
1414
import algoliasearch.ingestion.AuthenticationUpdateResponse
15+
import algoliasearch.ingestion.BatchWriteParams
1516
import algoliasearch.ingestion.DeleteResponse
1617
import algoliasearch.ingestion.Destination
1718
import algoliasearch.ingestion.DestinationCreate
@@ -1144,6 +1145,34 @@ class IngestionClient(
11441145
execute[ListTransformationsResponse](request, requestOptions)
11451146
}
11461147

1148+
/** Push a `batch` request payload through the Pipeline. You can check the status of task pushes with the
1149+
* observability endpoints.
1150+
*
1151+
* Required API Key ACLs:
1152+
* - addObject
1153+
* - deleteIndex
1154+
* - editSettings
1155+
*
1156+
* @param taskID
1157+
* Unique identifier of a task.
1158+
* @param batchWriteParams
1159+
* Request body of a Search API `batch` request that will be pushed in the Connectors pipeline.
1160+
*/
1161+
def pushTask(taskID: String, batchWriteParams: BatchWriteParams, requestOptions: Option[RequestOptions] = None)(
1162+
implicit ec: ExecutionContext
1163+
): Future[RunResponse] = Future {
1164+
requireNotNull(taskID, "Parameter `taskID` is required when calling `pushTask`.")
1165+
requireNotNull(batchWriteParams, "Parameter `batchWriteParams` is required when calling `pushTask`.")
1166+
1167+
val request = HttpRequest
1168+
.builder()
1169+
.withMethod("POST")
1170+
.withPath(s"/2/tasks/${escape(taskID)}/push")
1171+
.withBody(batchWriteParams)
1172+
.build()
1173+
execute[RunResponse](request, requestOptions)
1174+
}
1175+
11471176
/** Runs a task. You can check the status of task runs with the observability endpoints.
11481177
*
11491178
* Required API Key ACLs:
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/** Ingestion API The Ingestion API lets you connect third-party services and platforms with Algolia and schedule tasks
2+
* to ingest your data. The Ingestion API powers the no-code [data
3+
* connectors](https://dashboard.algolia.com/connectors). ## Base URLs The base URLs for requests to the Ingestion API
4+
* are: - `https://data.us.algolia.com` - `https://data.eu.algolia.com` Use the URL that matches your [analytics
5+
* region](https://dashboard.algolia.com/account/infrastructure/analytics). **All requests must use HTTPS.** ##
6+
* Authentication To authenticate your API requests, add these headers: - `x-algolia-application-id`. Your Algolia
7+
* application ID. - `x-algolia-api-key`. An API key with the necessary permissions to make the request. The required
8+
* access control list (ACL) to make a request is listed in each endpoint's reference. You can find your application ID
9+
* and API key in the [Algolia dashboard](https://dashboard.algolia.com/account). ## Request format Request bodies must
10+
* be JSON objects. ## Response status and errors Response bodies are JSON objects. Deleting a user token returns an
11+
* empty response body with rate-limiting information as headers. Successful responses return a `2xx` status. Client
12+
* errors return a `4xx` status. Server errors are indicated by a `5xx` status. Error responses have a `message`
13+
* property with more information. The Insights API doesn't validate if the event parameters such as `indexName`,
14+
* `objectIDs`, or `userToken`, correspond to anything in the Search API. It justs checks if they're formatted
15+
* correctly. Check the [Events](https://dashboard.algolia.com/events/health) health section, whether your events can
16+
* be used for Algolia features such as Analytics, or Dynamic Re-Ranking. ## Version The current version of the
17+
* Insights API is version 1, as indicated by the `/1/` in each endpoint's URL.
18+
*
19+
* The version of the OpenAPI document: 1.0.0
20+
*
21+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
22+
* https://openapi-generator.tech Do not edit the class manually.
23+
*/
24+
package algoliasearch.ingestion
25+
26+
import org.json4s._
27+
28+
sealed trait Action
29+
30+
/** Type of indexing operation.
31+
*/
32+
object Action {
33+
case object AddObject extends Action {
34+
override def toString = "addObject"
35+
}
36+
case object UpdateObject extends Action {
37+
override def toString = "updateObject"
38+
}
39+
case object PartialUpdateObject extends Action {
40+
override def toString = "partialUpdateObject"
41+
}
42+
case object PartialUpdateObjectNoCreate extends Action {
43+
override def toString = "partialUpdateObjectNoCreate"
44+
}
45+
case object DeleteObject extends Action {
46+
override def toString = "deleteObject"
47+
}
48+
case object Delete extends Action {
49+
override def toString = "delete"
50+
}
51+
case object Clear extends Action {
52+
override def toString = "clear"
53+
}
54+
val values: Seq[Action] =
55+
Seq(AddObject, UpdateObject, PartialUpdateObject, PartialUpdateObjectNoCreate, DeleteObject, Delete, Clear)
56+
57+
def withName(name: String): Action = Action.values
58+
.find(_.toString == name)
59+
.getOrElse(throw new MappingException(s"Unknown Action value: $name"))
60+
}
61+
62+
class ActionSerializer
63+
extends CustomSerializer[Action](_ =>
64+
(
65+
{
66+
case JString(value) => Action.withName(value)
67+
case JNull => null
68+
},
69+
{ case value: Action =>
70+
JString(value.toString)
71+
}
72+
)
73+
)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/** Ingestion API The Ingestion API lets you connect third-party services and platforms with Algolia and schedule tasks
2+
* to ingest your data. The Ingestion API powers the no-code [data
3+
* connectors](https://dashboard.algolia.com/connectors). ## Base URLs The base URLs for requests to the Ingestion API
4+
* are: - `https://data.us.algolia.com` - `https://data.eu.algolia.com` Use the URL that matches your [analytics
5+
* region](https://dashboard.algolia.com/account/infrastructure/analytics). **All requests must use HTTPS.** ##
6+
* Authentication To authenticate your API requests, add these headers: - `x-algolia-application-id`. Your Algolia
7+
* application ID. - `x-algolia-api-key`. An API key with the necessary permissions to make the request. The required
8+
* access control list (ACL) to make a request is listed in each endpoint's reference. You can find your application ID
9+
* and API key in the [Algolia dashboard](https://dashboard.algolia.com/account). ## Request format Request bodies must
10+
* be JSON objects. ## Response status and errors Response bodies are JSON objects. Deleting a user token returns an
11+
* empty response body with rate-limiting information as headers. Successful responses return a `2xx` status. Client
12+
* errors return a `4xx` status. Server errors are indicated by a `5xx` status. Error responses have a `message`
13+
* property with more information. The Insights API doesn't validate if the event parameters such as `indexName`,
14+
* `objectIDs`, or `userToken`, correspond to anything in the Search API. It justs checks if they're formatted
15+
* correctly. Check the [Events](https://dashboard.algolia.com/events/health) health section, whether your events can
16+
* be used for Algolia features such as Analytics, or Dynamic Re-Ranking. ## Version The current version of the
17+
* Insights API is version 1, as indicated by the `/1/` in each endpoint's URL.
18+
*
19+
* The version of the OpenAPI document: 1.0.0
20+
*
21+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
22+
* https://openapi-generator.tech Do not edit the class manually.
23+
*/
24+
package algoliasearch.ingestion
25+
26+
import algoliasearch.ingestion.Action._
27+
28+
/** BatchRequest
29+
*
30+
* @param body
31+
* Operation arguments (varies with specified `action`).
32+
*/
33+
case class BatchRequest(
34+
action: Action,
35+
body: Any
36+
)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/** Ingestion API The Ingestion API lets you connect third-party services and platforms with Algolia and schedule tasks
2+
* to ingest your data. The Ingestion API powers the no-code [data
3+
* connectors](https://dashboard.algolia.com/connectors). ## Base URLs The base URLs for requests to the Ingestion API
4+
* are: - `https://data.us.algolia.com` - `https://data.eu.algolia.com` Use the URL that matches your [analytics
5+
* region](https://dashboard.algolia.com/account/infrastructure/analytics). **All requests must use HTTPS.** ##
6+
* Authentication To authenticate your API requests, add these headers: - `x-algolia-application-id`. Your Algolia
7+
* application ID. - `x-algolia-api-key`. An API key with the necessary permissions to make the request. The required
8+
* access control list (ACL) to make a request is listed in each endpoint's reference. You can find your application ID
9+
* and API key in the [Algolia dashboard](https://dashboard.algolia.com/account). ## Request format Request bodies must
10+
* be JSON objects. ## Response status and errors Response bodies are JSON objects. Deleting a user token returns an
11+
* empty response body with rate-limiting information as headers. Successful responses return a `2xx` status. Client
12+
* errors return a `4xx` status. Server errors are indicated by a `5xx` status. Error responses have a `message`
13+
* property with more information. The Insights API doesn't validate if the event parameters such as `indexName`,
14+
* `objectIDs`, or `userToken`, correspond to anything in the Search API. It justs checks if they're formatted
15+
* correctly. Check the [Events](https://dashboard.algolia.com/events/health) health section, whether your events can
16+
* be used for Algolia features such as Analytics, or Dynamic Re-Ranking. ## Version The current version of the
17+
* Insights API is version 1, as indicated by the `/1/` in each endpoint's URL.
18+
*
19+
* The version of the OpenAPI document: 1.0.0
20+
*
21+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
22+
* https://openapi-generator.tech Do not edit the class manually.
23+
*/
24+
package algoliasearch.ingestion
25+
26+
/** Batch parameters.
27+
*/
28+
case class BatchWriteParams(
29+
requests: Seq[BatchRequest]
30+
)

src/main/scala/algoliasearch/ingestion/JsonSupport.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import org.json4s._
2727

2828
object JsonSupport {
2929
private def enumSerializers: Seq[Serializer[_]] = Seq[Serializer[_]]() :+
30+
new ActionSerializer() :+
3031
new ActionTypeSerializer() :+
3132
new AuthenticationSortKeysSerializer() :+
3233
new AuthenticationTypeSerializer() :+

0 commit comments

Comments
 (0)