diff --git a/src/main/scala/algoliasearch/api/IngestionClient.scala b/src/main/scala/algoliasearch/api/IngestionClient.scala index 1d41706d..3497528e 100644 --- a/src/main/scala/algoliasearch/api/IngestionClient.scala +++ b/src/main/scala/algoliasearch/api/IngestionClient.scala @@ -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 @@ -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: diff --git a/src/main/scala/algoliasearch/ingestion/Action.scala b/src/main/scala/algoliasearch/ingestion/Action.scala new file mode 100644 index 00000000..962072e3 --- /dev/null +++ b/src/main/scala/algoliasearch/ingestion/Action.scala @@ -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) + } + ) + ) diff --git a/src/main/scala/algoliasearch/ingestion/BatchRequest.scala b/src/main/scala/algoliasearch/ingestion/BatchRequest.scala new file mode 100644 index 00000000..004810b3 --- /dev/null +++ b/src/main/scala/algoliasearch/ingestion/BatchRequest.scala @@ -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 +) diff --git a/src/main/scala/algoliasearch/ingestion/BatchWriteParams.scala b/src/main/scala/algoliasearch/ingestion/BatchWriteParams.scala new file mode 100644 index 00000000..a9203766 --- /dev/null +++ b/src/main/scala/algoliasearch/ingestion/BatchWriteParams.scala @@ -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] +) diff --git a/src/main/scala/algoliasearch/ingestion/JsonSupport.scala b/src/main/scala/algoliasearch/ingestion/JsonSupport.scala index 3227a50f..f2b3c2d2 100644 --- a/src/main/scala/algoliasearch/ingestion/JsonSupport.scala +++ b/src/main/scala/algoliasearch/ingestion/JsonSupport.scala @@ -27,6 +27,7 @@ import org.json4s._ object JsonSupport { private def enumSerializers: Seq[Serializer[_]] = Seq[Serializer[_]]() :+ + new ActionSerializer() :+ new ActionTypeSerializer() :+ new AuthenticationSortKeysSerializer() :+ new AuthenticationTypeSerializer() :+