Skip to content

Commit 55382de

Browse files
feat(specs): update transformation specs for no-code (generated)
algolia/api-clients-automation#4901 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Mehmet Ali Gok <33124154+mehmetaligok@users.noreply.github.com>
1 parent c43095e commit 55382de

File tree

8 files changed

+171
-4
lines changed

8 files changed

+171
-4
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ object JsonSupport {
5555
new SubscriptionTriggerTypeSerializer() :+
5656
new TaskSortKeysSerializer() :+
5757
new TransformationSortKeysSerializer() :+
58+
new TransformationTypeSerializer() :+
5859
new TriggerTypeSerializer()
5960

6061
private def oneOfsSerializers: Seq[Serializer[?]] = Seq[Serializer[?]]() :+
@@ -65,6 +66,7 @@ object JsonSupport {
6566
SourceUpdateInputSerializer :+
6667
TaskCreateTriggerSerializer :+
6768
TaskInputSerializer :+
69+
TransformationInputSerializer :+
6870
TriggerSerializer
6971

7072
private def classMapSerializers: Seq[Serializer[?]] = Seq[Serializer[?]]() :+

src/main/scala/algoliasearch/ingestion/Transformation.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@
1919
*/
2020
package algoliasearch.ingestion
2121

22+
import algoliasearch.ingestion.TransformationType._
23+
2224
/** Transformation
2325
*
2426
* @param transformationID
2527
* Universally unique identifier (UUID) of a transformation.
2628
* @param authenticationIDs
2729
* The authentications associated with the current transformation.
2830
* @param code
29-
* The source code of the transformation.
31+
* It is deprecated. Use the `input` field with proper `type` instead to specify the transformation code.
3032
* @param name
3133
* The uniquely identified name of your transformation.
3234
* @param description
@@ -42,6 +44,8 @@ case class Transformation(
4244
transformationID: String,
4345
authenticationIDs: Option[Seq[String]] = scala.None,
4446
code: String,
47+
`type`: Option[TransformationType] = scala.None,
48+
input: Option[TransformationInput] = scala.None,
4549
name: String,
4650
description: Option[String] = scala.None,
4751
owner: Option[String] = scala.None,
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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. Successful responses return a `2xx`
11+
* status. Client errors return a `4xx` status. Server errors are indicated by a `5xx` status. Error responses have a
12+
* `message` property with more information. ## Version The current version of the Ingestion API is version 1, as
13+
* indicated by the `/1/` in each endpoint's URL.
14+
*
15+
* The version of the OpenAPI document: 1.0.0
16+
*
17+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
18+
* https://openapi-generator.tech Do not edit the class manually.
19+
*/
20+
package algoliasearch.ingestion
21+
22+
/** Input for a transformation that contains the source code of the transformation.
23+
*
24+
* @param code
25+
* The source code of the transformation.
26+
*/
27+
case class TransformationCode(
28+
code: String
29+
) extends TransformationInputTrait

src/main/scala/algoliasearch/ingestion/TransformationCreate.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919
*/
2020
package algoliasearch.ingestion
2121

22+
import algoliasearch.ingestion.TransformationType._
23+
2224
/** API request body for creating a transformation.
2325
*
2426
* @param code
25-
* The source code of the transformation.
27+
* It is deprecated. Use the `input` field with proper `type` instead to specify the transformation code.
2628
* @param name
2729
* The uniquely identified name of your transformation.
2830
* @param description
@@ -31,8 +33,10 @@ package algoliasearch.ingestion
3133
* The authentications associated with the current transformation.
3234
*/
3335
case class TransformationCreate(
34-
code: String,
36+
code: Option[String] = scala.None,
3537
name: String,
38+
`type`: TransformationType,
39+
input: TransformationInput,
3640
description: Option[String] = scala.None,
3741
authenticationIDs: Option[Seq[String]] = scala.None
3842
)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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. Successful responses return a `2xx`
11+
* status. Client errors return a `4xx` status. Server errors are indicated by a `5xx` status. Error responses have a
12+
* `message` property with more information. ## Version The current version of the Ingestion API is version 1, as
13+
* indicated by the `/1/` in each endpoint's URL.
14+
*
15+
* The version of the OpenAPI document: 1.0.0
16+
*
17+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
18+
* https://openapi-generator.tech Do not edit the class manually.
19+
*/
20+
package algoliasearch.ingestion
21+
22+
import org.json4s._
23+
24+
/** The input for the transformation, which can be either code or a no-code configuration.
25+
*/
26+
sealed trait TransformationInput
27+
28+
trait TransformationInputTrait extends TransformationInput
29+
30+
object TransformationInput {}
31+
32+
object TransformationInputSerializer extends Serializer[TransformationInput] {
33+
override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), TransformationInput] = {
34+
35+
case (TypeInfo(clazz, _), json) if clazz == classOf[TransformationInput] =>
36+
json match {
37+
case value: JObject => Extraction.extract[TransformationCode](value)
38+
case value: JObject => Extraction.extract[TransformationNoCode](value)
39+
case _ => throw new MappingException("Can't convert " + json + " to TransformationInput")
40+
}
41+
}
42+
43+
override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: TransformationInput =>
44+
value match {
45+
case value: TransformationCode => Extraction.decompose(value)(format - this)
46+
case value: TransformationNoCode => Extraction.decompose(value)(format - this)
47+
}
48+
}
49+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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. Successful responses return a `2xx`
11+
* status. Client errors return a `4xx` status. Server errors are indicated by a `5xx` status. Error responses have a
12+
* `message` property with more information. ## Version The current version of the Ingestion API is version 1, as
13+
* indicated by the `/1/` in each endpoint's URL.
14+
*
15+
* The version of the OpenAPI document: 1.0.0
16+
*
17+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
18+
* https://openapi-generator.tech Do not edit the class manually.
19+
*/
20+
package algoliasearch.ingestion
21+
22+
/** Input for a no-code transformation that contains a series of steps.
23+
*/
24+
case class TransformationNoCode(
25+
steps: Seq[Any]
26+
) extends TransformationInputTrait

src/main/scala/algoliasearch/ingestion/TransformationTry.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ package algoliasearch.ingestion
2222
/** TransformationTry
2323
*
2424
* @param code
25-
* The source code of the transformation.
25+
* It is deprecated. Use the `input` field with proper `type` instead to specify the transformation code.
2626
* @param sampleRecord
2727
* The record to apply the given code to.
2828
*/
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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. Successful responses return a `2xx`
11+
* status. Client errors return a `4xx` status. Server errors are indicated by a `5xx` status. Error responses have a
12+
* `message` property with more information. ## Version The current version of the Ingestion API is version 1, as
13+
* indicated by the `/1/` in each endpoint's URL.
14+
*
15+
* The version of the OpenAPI document: 1.0.0
16+
*
17+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
18+
* https://openapi-generator.tech Do not edit the class manually.
19+
*/
20+
package algoliasearch.ingestion
21+
22+
import org.json4s._
23+
24+
sealed trait TransformationType
25+
26+
/** The type of transformation, which can be either 'code' or 'noCode'.
27+
*/
28+
object TransformationType {
29+
case object Code extends TransformationType {
30+
override def toString = "code"
31+
}
32+
case object NoCode extends TransformationType {
33+
override def toString = "noCode"
34+
}
35+
val values: Seq[TransformationType] = Seq(Code, NoCode)
36+
37+
def withName(name: String): TransformationType = TransformationType.values
38+
.find(_.toString == name)
39+
.getOrElse(throw new MappingException(s"Unknown TransformationType value: $name"))
40+
}
41+
42+
class TransformationTypeSerializer
43+
extends CustomSerializer[TransformationType](_ =>
44+
(
45+
{
46+
case JString(value) => TransformationType.withName(value)
47+
case JNull => null
48+
},
49+
{ case value: TransformationType =>
50+
JString(value.toString)
51+
}
52+
)
53+
)

0 commit comments

Comments
 (0)