Skip to content

Commit c1920c2

Browse files
feat(specs): update transformation specs for no-code (generated)
algolia/api-clients-automation#4901 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Mehmet Ali Gok <[email protected]>
1 parent c611fca commit c1920c2

File tree

7 files changed

+312
-6
lines changed

7 files changed

+312
-6
lines changed

algoliasearch/src/main/java/com/algolia/model/ingestion/Transformation.java

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ public class Transformation {
2121
@JsonProperty("code")
2222
private String code;
2323

24+
@JsonProperty("type")
25+
private TransformationType type;
26+
27+
@JsonProperty("input")
28+
private TransformationInput input;
29+
2430
@JsonProperty("name")
2531
private String name;
2632

@@ -71,12 +77,40 @@ public Transformation setCode(String code) {
7177
return this;
7278
}
7379

74-
/** The source code of the transformation. */
80+
/**
81+
* It is deprecated. Use the `input` field with proper `type` instead to specify the
82+
* transformation code.
83+
*
84+
* @deprecated
85+
*/
86+
@Deprecated
7587
@javax.annotation.Nonnull
7688
public String getCode() {
7789
return code;
7890
}
7991

92+
public Transformation setType(TransformationType type) {
93+
this.type = type;
94+
return this;
95+
}
96+
97+
/** Get type */
98+
@javax.annotation.Nullable
99+
public TransformationType getType() {
100+
return type;
101+
}
102+
103+
public Transformation setInput(TransformationInput input) {
104+
this.input = input;
105+
return this;
106+
}
107+
108+
/** Get input */
109+
@javax.annotation.Nullable
110+
public TransformationInput getInput() {
111+
return input;
112+
}
113+
80114
public Transformation setName(String name) {
81115
this.name = name;
82116
return this;
@@ -145,6 +179,8 @@ public boolean equals(Object o) {
145179
Objects.equals(this.transformationID, transformation.transformationID) &&
146180
Objects.equals(this.authenticationIDs, transformation.authenticationIDs) &&
147181
Objects.equals(this.code, transformation.code) &&
182+
Objects.equals(this.type, transformation.type) &&
183+
Objects.equals(this.input, transformation.input) &&
148184
Objects.equals(this.name, transformation.name) &&
149185
Objects.equals(this.description, transformation.description) &&
150186
Objects.equals(this.owner, transformation.owner) &&
@@ -155,7 +191,7 @@ public boolean equals(Object o) {
155191

156192
@Override
157193
public int hashCode() {
158-
return Objects.hash(transformationID, authenticationIDs, code, name, description, owner, createdAt, updatedAt);
194+
return Objects.hash(transformationID, authenticationIDs, code, type, input, name, description, owner, createdAt, updatedAt);
159195
}
160196

161197
@Override
@@ -165,6 +201,8 @@ public String toString() {
165201
sb.append(" transformationID: ").append(toIndentedString(transformationID)).append("\n");
166202
sb.append(" authenticationIDs: ").append(toIndentedString(authenticationIDs)).append("\n");
167203
sb.append(" code: ").append(toIndentedString(code)).append("\n");
204+
sb.append(" type: ").append(toIndentedString(type)).append("\n");
205+
sb.append(" input: ").append(toIndentedString(input)).append("\n");
168206
sb.append(" name: ").append(toIndentedString(name)).append("\n");
169207
sb.append(" description: ").append(toIndentedString(description)).append("\n");
170208
sb.append(" owner: ").append(toIndentedString(owner)).append("\n");
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
/** Input for a transformation that contains the source code of the transformation. */
11+
@JsonDeserialize(as = TransformationCode.class)
12+
public class TransformationCode implements TransformationInput {
13+
14+
@JsonProperty("code")
15+
private String code;
16+
17+
public TransformationCode setCode(String code) {
18+
this.code = code;
19+
return this;
20+
}
21+
22+
/** The source code of the transformation. */
23+
@javax.annotation.Nonnull
24+
public String getCode() {
25+
return code;
26+
}
27+
28+
@Override
29+
public boolean equals(Object o) {
30+
if (this == o) {
31+
return true;
32+
}
33+
if (o == null || getClass() != o.getClass()) {
34+
return false;
35+
}
36+
TransformationCode transformationCode = (TransformationCode) o;
37+
return Objects.equals(this.code, transformationCode.code);
38+
}
39+
40+
@Override
41+
public int hashCode() {
42+
return Objects.hash(code);
43+
}
44+
45+
@Override
46+
public String toString() {
47+
StringBuilder sb = new StringBuilder();
48+
sb.append("class TransformationCode {\n");
49+
sb.append(" code: ").append(toIndentedString(code)).append("\n");
50+
sb.append("}");
51+
return sb.toString();
52+
}
53+
54+
/**
55+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
56+
*/
57+
private String toIndentedString(Object o) {
58+
if (o == null) {
59+
return "null";
60+
}
61+
return o.toString().replace("\n", "\n ");
62+
}
63+
}

algoliasearch/src/main/java/com/algolia/model/ingestion/TransformationCreate.java

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ public class TransformationCreate {
1818
@JsonProperty("name")
1919
private String name;
2020

21+
@JsonProperty("type")
22+
private TransformationType type;
23+
24+
@JsonProperty("input")
25+
private TransformationInput input;
26+
2127
@JsonProperty("description")
2228
private String description;
2329

@@ -29,8 +35,14 @@ public TransformationCreate setCode(String code) {
2935
return this;
3036
}
3137

32-
/** The source code of the transformation. */
33-
@javax.annotation.Nonnull
38+
/**
39+
* It is deprecated. Use the `input` field with proper `type` instead to specify the
40+
* transformation code.
41+
*
42+
* @deprecated
43+
*/
44+
@Deprecated
45+
@javax.annotation.Nullable
3446
public String getCode() {
3547
return code;
3648
}
@@ -46,6 +58,28 @@ public String getName() {
4658
return name;
4759
}
4860

61+
public TransformationCreate setType(TransformationType type) {
62+
this.type = type;
63+
return this;
64+
}
65+
66+
/** Get type */
67+
@javax.annotation.Nonnull
68+
public TransformationType getType() {
69+
return type;
70+
}
71+
72+
public TransformationCreate setInput(TransformationInput input) {
73+
this.input = input;
74+
return this;
75+
}
76+
77+
/** Get input */
78+
@javax.annotation.Nonnull
79+
public TransformationInput getInput() {
80+
return input;
81+
}
82+
4983
public TransformationCreate setDescription(String description) {
5084
this.description = description;
5185
return this;
@@ -88,14 +122,16 @@ public boolean equals(Object o) {
88122
return (
89123
Objects.equals(this.code, transformationCreate.code) &&
90124
Objects.equals(this.name, transformationCreate.name) &&
125+
Objects.equals(this.type, transformationCreate.type) &&
126+
Objects.equals(this.input, transformationCreate.input) &&
91127
Objects.equals(this.description, transformationCreate.description) &&
92128
Objects.equals(this.authenticationIDs, transformationCreate.authenticationIDs)
93129
);
94130
}
95131

96132
@Override
97133
public int hashCode() {
98-
return Objects.hash(code, name, description, authenticationIDs);
134+
return Objects.hash(code, name, type, input, description, authenticationIDs);
99135
}
100136

101137
@Override
@@ -104,6 +140,8 @@ public String toString() {
104140
sb.append("class TransformationCreate {\n");
105141
sb.append(" code: ").append(toIndentedString(code)).append("\n");
106142
sb.append(" name: ").append(toIndentedString(name)).append("\n");
143+
sb.append(" type: ").append(toIndentedString(type)).append("\n");
144+
sb.append(" input: ").append(toIndentedString(input)).append("\n");
107145
sb.append(" description: ").append(toIndentedString(description)).append("\n");
108146
sb.append(" authenticationIDs: ").append(toIndentedString(authenticationIDs)).append("\n");
109147
sb.append("}");
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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.algolia.exceptions.AlgoliaRuntimeException;
7+
import com.fasterxml.jackson.annotation.*;
8+
import com.fasterxml.jackson.core.*;
9+
import com.fasterxml.jackson.databind.*;
10+
import com.fasterxml.jackson.databind.annotation.*;
11+
import java.io.IOException;
12+
import java.util.logging.Logger;
13+
14+
/** The input for the transformation, which can be either code or a no-code configuration. */
15+
@JsonDeserialize(using = TransformationInput.Deserializer.class)
16+
public interface TransformationInput {
17+
class Deserializer extends JsonDeserializer<TransformationInput> {
18+
19+
private static final Logger LOGGER = Logger.getLogger(Deserializer.class.getName());
20+
21+
@Override
22+
public TransformationInput deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
23+
JsonNode tree = jp.readValueAsTree();
24+
// deserialize TransformationCode
25+
if (tree.isObject()) {
26+
try (JsonParser parser = tree.traverse(jp.getCodec())) {
27+
return parser.readValueAs(TransformationCode.class);
28+
} catch (Exception e) {
29+
// deserialization failed, continue
30+
LOGGER.finest("Failed to deserialize oneOf TransformationCode (error: " + e.getMessage() + ") (type: TransformationCode)");
31+
}
32+
}
33+
// deserialize TransformationNoCode
34+
if (tree.isObject()) {
35+
try (JsonParser parser = tree.traverse(jp.getCodec())) {
36+
return parser.readValueAs(TransformationNoCode.class);
37+
} catch (Exception e) {
38+
// deserialization failed, continue
39+
LOGGER.finest("Failed to deserialize oneOf TransformationNoCode (error: " + e.getMessage() + ") (type: TransformationNoCode)");
40+
}
41+
}
42+
throw new AlgoliaRuntimeException(String.format("Failed to deserialize json element: %s", tree));
43+
}
44+
45+
/** Handle deserialization of the 'null' value. */
46+
@Override
47+
public TransformationInput getNullValue(DeserializationContext ctxt) throws JsonMappingException {
48+
throw new JsonMappingException(ctxt.getParser(), "TransformationInput cannot be null");
49+
}
50+
}
51+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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+
/** Input for a no-code transformation that contains a series of steps. */
13+
@JsonDeserialize(as = TransformationNoCode.class)
14+
public class TransformationNoCode implements TransformationInput {
15+
16+
@JsonProperty("steps")
17+
private List<Object> steps = new ArrayList<>();
18+
19+
public TransformationNoCode setSteps(List<Object> steps) {
20+
this.steps = steps;
21+
return this;
22+
}
23+
24+
public TransformationNoCode addSteps(Object stepsItem) {
25+
this.steps.add(stepsItem);
26+
return this;
27+
}
28+
29+
/** Get steps */
30+
@javax.annotation.Nonnull
31+
public List<Object> getSteps() {
32+
return steps;
33+
}
34+
35+
@Override
36+
public boolean equals(Object o) {
37+
if (this == o) {
38+
return true;
39+
}
40+
if (o == null || getClass() != o.getClass()) {
41+
return false;
42+
}
43+
TransformationNoCode transformationNoCode = (TransformationNoCode) o;
44+
return Objects.equals(this.steps, transformationNoCode.steps);
45+
}
46+
47+
@Override
48+
public int hashCode() {
49+
return Objects.hash(steps);
50+
}
51+
52+
@Override
53+
public String toString() {
54+
StringBuilder sb = new StringBuilder();
55+
sb.append("class TransformationNoCode {\n");
56+
sb.append(" steps: ").append(toIndentedString(steps)).append("\n");
57+
sb.append("}");
58+
return sb.toString();
59+
}
60+
61+
/**
62+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
63+
*/
64+
private String toIndentedString(Object o) {
65+
if (o == null) {
66+
return "null";
67+
}
68+
return o.toString().replace("\n", "\n ");
69+
}
70+
}

algoliasearch/src/main/java/com/algolia/model/ingestion/TransformationTry.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ public TransformationTry setCode(String code) {
2626
return this;
2727
}
2828

29-
/** The source code of the transformation. */
29+
/**
30+
* It is deprecated. Use the `input` field with proper `type` instead to specify the
31+
* transformation code.
32+
*
33+
* @deprecated
34+
*/
35+
@Deprecated
3036
@javax.annotation.Nonnull
3137
public String getCode() {
3238
return code;

0 commit comments

Comments
 (0)