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 <accounts+algolia-api-client-bot@algolia.com>
Co-authored-by: Clément Vannicatte <vannicattec@gmail.com>
  • Loading branch information
algolia-bot and shortcuts committed Jul 25, 2024
1 parent af396b2 commit 788e4c2
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/main/scala/algoliasearch/api/IngestionClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import algoliasearch.ingestion.AuthenticationSortKeys._
import algoliasearch.ingestion.AuthenticationType._
import algoliasearch.ingestion.AuthenticationUpdate
import algoliasearch.ingestion.AuthenticationUpdateResponse
import algoliasearch.ingestion.BatchWriteParams
import algoliasearch.ingestion.DeleteResponse
import algoliasearch.ingestion.Destination
import algoliasearch.ingestion.DestinationCreate
Expand Down Expand Up @@ -1144,6 +1145,34 @@ class IngestionClient(
execute[ListTransformationsResponse](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 taskID
* Unique identifier of a task.
* @param batchWriteParams
* Request body of a Search API `batch` request that will be pushed in the Connectors pipeline.
*/
def pushTask(taskID: String, batchWriteParams: BatchWriteParams, requestOptions: Option[RequestOptions] = None)(
implicit ec: ExecutionContext
): Future[RunResponse] = Future {
requireNotNull(taskID, "Parameter `taskID` is required when calling `pushTask`.")
requireNotNull(batchWriteParams, "Parameter `batchWriteParams` is required when calling `pushTask`.")

val request = HttpRequest
.builder()
.withMethod("POST")
.withPath(s"/2/tasks/${escape(taskID)}/push")
.withBody(batchWriteParams)
.build()
execute[RunResponse](request, requestOptions)
}

/** Runs a task. You can check the status of task runs with the observability endpoints.
*
* Required API Key ACLs:
Expand Down
73 changes: 73 additions & 0 deletions src/main/scala/algoliasearch/ingestion/Action.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/** Ingestion API The Ingestion API lets you connect third-party services and platforms with Algolia and schedule tasks
* to ingest your data. The Ingestion API powers the no-code [data
* connectors](https://dashboard.algolia.com/connectors). ## Base URLs The base URLs for requests to the Ingestion API
* are: - `https://data.us.algolia.com` - `https://data.eu.algolia.com` Use the URL that matches your [analytics
* region](https://dashboard.algolia.com/account/infrastructure/analytics). **All requests must use HTTPS.** ##
* Authentication To authenticate your API requests, add these headers: - `x-algolia-application-id`. Your Algolia
* application ID. - `x-algolia-api-key`. An API key with the necessary permissions to make the request. The required
* access control list (ACL) to make a request is listed in each endpoint's reference. You can find your application ID
* and API key in the [Algolia dashboard](https://dashboard.algolia.com/account). ## Request format Request bodies must
* be JSON objects. ## Response status and errors Response bodies are JSON objects. Deleting a user token returns an
* empty response body with rate-limiting information as headers. Successful responses return a `2xx` status. Client
* errors return a `4xx` status. Server errors are indicated by a `5xx` status. Error responses have a `message`
* property with more information. The Insights API doesn't validate if the event parameters such as `indexName`,
* `objectIDs`, or `userToken`, correspond to anything in the Search API. It justs checks if they're formatted
* correctly. Check the [Events](https://dashboard.algolia.com/events/health) health section, whether your events can
* be used for Algolia features such as Analytics, or Dynamic Re-Ranking. ## Version The current version of the
* Insights API is version 1, as indicated by the `/1/` in each endpoint's URL.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech Do not edit the class manually.
*/
package algoliasearch.ingestion

import org.json4s._

sealed trait Action

/** Type of indexing operation.
*/
object Action {
case object AddObject extends Action {
override def toString = "addObject"
}
case object UpdateObject extends Action {
override def toString = "updateObject"
}
case object PartialUpdateObject extends Action {
override def toString = "partialUpdateObject"
}
case object PartialUpdateObjectNoCreate extends Action {
override def toString = "partialUpdateObjectNoCreate"
}
case object DeleteObject extends Action {
override def toString = "deleteObject"
}
case object Delete extends Action {
override def toString = "delete"
}
case object Clear extends Action {
override def toString = "clear"
}
val values: Seq[Action] =
Seq(AddObject, UpdateObject, PartialUpdateObject, PartialUpdateObjectNoCreate, DeleteObject, Delete, Clear)

def withName(name: String): Action = Action.values
.find(_.toString == name)
.getOrElse(throw new MappingException(s"Unknown Action value: $name"))
}

class ActionSerializer
extends CustomSerializer[Action](_ =>
(
{
case JString(value) => Action.withName(value)
case JNull => null
},
{ case value: Action =>
JString(value.toString)
}
)
)
36 changes: 36 additions & 0 deletions src/main/scala/algoliasearch/ingestion/BatchRequest.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/** Ingestion API The Ingestion API lets you connect third-party services and platforms with Algolia and schedule tasks
* to ingest your data. The Ingestion API powers the no-code [data
* connectors](https://dashboard.algolia.com/connectors). ## Base URLs The base URLs for requests to the Ingestion API
* are: - `https://data.us.algolia.com` - `https://data.eu.algolia.com` Use the URL that matches your [analytics
* region](https://dashboard.algolia.com/account/infrastructure/analytics). **All requests must use HTTPS.** ##
* Authentication To authenticate your API requests, add these headers: - `x-algolia-application-id`. Your Algolia
* application ID. - `x-algolia-api-key`. An API key with the necessary permissions to make the request. The required
* access control list (ACL) to make a request is listed in each endpoint's reference. You can find your application ID
* and API key in the [Algolia dashboard](https://dashboard.algolia.com/account). ## Request format Request bodies must
* be JSON objects. ## Response status and errors Response bodies are JSON objects. Deleting a user token returns an
* empty response body with rate-limiting information as headers. Successful responses return a `2xx` status. Client
* errors return a `4xx` status. Server errors are indicated by a `5xx` status. Error responses have a `message`
* property with more information. The Insights API doesn't validate if the event parameters such as `indexName`,
* `objectIDs`, or `userToken`, correspond to anything in the Search API. It justs checks if they're formatted
* correctly. Check the [Events](https://dashboard.algolia.com/events/health) health section, whether your events can
* be used for Algolia features such as Analytics, or Dynamic Re-Ranking. ## Version The current version of the
* Insights API is version 1, as indicated by the `/1/` in each endpoint's URL.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech Do not edit the class manually.
*/
package algoliasearch.ingestion

import algoliasearch.ingestion.Action._

/** BatchRequest
*
* @param body
* Operation arguments (varies with specified `action`).
*/
case class BatchRequest(
action: Action,
body: Any
)
30 changes: 30 additions & 0 deletions src/main/scala/algoliasearch/ingestion/BatchWriteParams.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/** Ingestion API The Ingestion API lets you connect third-party services and platforms with Algolia and schedule tasks
* to ingest your data. The Ingestion API powers the no-code [data
* connectors](https://dashboard.algolia.com/connectors). ## Base URLs The base URLs for requests to the Ingestion API
* are: - `https://data.us.algolia.com` - `https://data.eu.algolia.com` Use the URL that matches your [analytics
* region](https://dashboard.algolia.com/account/infrastructure/analytics). **All requests must use HTTPS.** ##
* Authentication To authenticate your API requests, add these headers: - `x-algolia-application-id`. Your Algolia
* application ID. - `x-algolia-api-key`. An API key with the necessary permissions to make the request. The required
* access control list (ACL) to make a request is listed in each endpoint's reference. You can find your application ID
* and API key in the [Algolia dashboard](https://dashboard.algolia.com/account). ## Request format Request bodies must
* be JSON objects. ## Response status and errors Response bodies are JSON objects. Deleting a user token returns an
* empty response body with rate-limiting information as headers. Successful responses return a `2xx` status. Client
* errors return a `4xx` status. Server errors are indicated by a `5xx` status. Error responses have a `message`
* property with more information. The Insights API doesn't validate if the event parameters such as `indexName`,
* `objectIDs`, or `userToken`, correspond to anything in the Search API. It justs checks if they're formatted
* correctly. Check the [Events](https://dashboard.algolia.com/events/health) health section, whether your events can
* be used for Algolia features such as Analytics, or Dynamic Re-Ranking. ## Version The current version of the
* Insights API is version 1, as indicated by the `/1/` in each endpoint's URL.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech Do not edit the class manually.
*/
package algoliasearch.ingestion

/** Batch parameters.
*/
case class BatchWriteParams(
requests: Seq[BatchRequest]
)
1 change: 1 addition & 0 deletions src/main/scala/algoliasearch/ingestion/JsonSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import org.json4s._

object JsonSupport {
private def enumSerializers: Seq[Serializer[_]] = Seq[Serializer[_]]() :+
new ActionSerializer() :+
new ActionTypeSerializer() :+
new AuthenticationSortKeysSerializer() :+
new AuthenticationTypeSerializer() :+
Expand Down

0 comments on commit 788e4c2

Please sign in to comment.