1919
2020package co .elastic .clients .elasticsearch .ingest ;
2121
22+ import co .elastic .clients .json .JsonEnum ;
2223import co .elastic .clients .json .JsonpDeserializable ;
2324import co .elastic .clients .json .JsonpDeserializer ;
2425import co .elastic .clients .json .JsonpMapper ;
2829import co .elastic .clients .json .ObjectDeserializer ;
2930import co .elastic .clients .util .ApiTypeHelper ;
3031import co .elastic .clients .util .ObjectBuilder ;
32+ import co .elastic .clients .util .TaggedUnion ;
33+ import co .elastic .clients .util .TaggedUnionUtils ;
3134import co .elastic .clients .util .WithJsonObjectBuilderBase ;
3235import jakarta .json .stream .JsonGenerator ;
36+ import java .lang .Object ;
3337import java .lang .String ;
3438import java .util .Objects ;
3539import java .util .function .Function ;
5357// typedef: ingest._types.DatabaseConfiguration
5458
5559/**
56- *
60+ * The configuration necessary to identify which IP geolocation provider to use
61+ * to download a database, as well as any provider-specific configuration
62+ * necessary for such downloading. At present, the only supported providers are
63+ * maxmind and ipinfo, and the maxmind provider requires that an account_id
64+ * (string) is configured. A provider (either maxmind or ipinfo) must be
65+ * specified. The web and local providers can be returned as read only
66+ * configurations.
67+ *
5768 * @see <a href=
5869 * "../doc-files/api-spec.html#ingest._types.DatabaseConfiguration">API
5970 * specification</a>
6071 */
6172@ JsonpDeserializable
62- public class DatabaseConfiguration implements JsonpSerializable {
63- private final String name ;
73+ public class DatabaseConfiguration implements TaggedUnion <DatabaseConfiguration .Kind , Object >, JsonpSerializable {
74+
75+ /**
76+ * {@link DatabaseConfiguration} variant kinds.
77+ *
78+ * @see <a href=
79+ * "../doc-files/api-spec.html#ingest._types.DatabaseConfiguration">API
80+ * specification</a>
81+ */
6482
65- private final Maxmind maxmind ;
83+ public enum Kind implements JsonEnum {
84+ Maxmind ("maxmind" ),
6685
67- // ---------------------------------------------------------------------------------------------
86+ Ipinfo ("ipinfo" ),
87+
88+ ;
89+
90+ private final String jsonValue ;
91+
92+ Kind (String jsonValue ) {
93+ this .jsonValue = jsonValue ;
94+ }
95+
96+ public String jsonValue () {
97+ return this .jsonValue ;
98+ }
99+
100+ }
101+
102+ private final Kind _kind ;
103+ private final Object _value ;
104+
105+ @ Override
106+ public final Kind _kind () {
107+ return _kind ;
108+ }
109+
110+ @ Override
111+ public final Object _get () {
112+ return _value ;
113+ }
114+
115+ private final String name ;
68116
69117 private DatabaseConfiguration (Builder builder ) {
70118
119+ this ._kind = ApiTypeHelper .requireNonNull (builder ._kind , builder , "<variant kind>" );
120+ this ._value = ApiTypeHelper .requireNonNull (builder ._value , builder , "<variant value>" );
121+
71122 this .name = ApiTypeHelper .requireNonNull (builder .name , this , "name" );
72- this .maxmind = ApiTypeHelper .requireNonNull (builder .maxmind , this , "maxmind" );
73123
74124 }
75125
@@ -88,34 +138,54 @@ public final String name() {
88138 }
89139
90140 /**
91- * Required - The configuration necessary to identify which IP geolocation
92- * provider to use to download the database, as well as any provider-specific
93- * configuration necessary for such downloading. At present, the only supported
94- * provider is maxmind, and the maxmind provider requires that an account_id
95- * (string) is configured.
96- * <p>
97- * API name: {@code maxmind}
141+ * Is this variant instance of kind {@code maxmind}?
98142 */
99- public final Maxmind maxmind () {
100- return this . maxmind ;
143+ public boolean isMaxmind () {
144+ return _kind == Kind . Maxmind ;
101145 }
102146
103147 /**
104- * Serialize this object to JSON.
148+ * Get the {@code maxmind} variant value.
149+ *
150+ * @throws IllegalStateException
151+ * if the current variant is not of the {@code maxmind} kind.
105152 */
106- public void serialize (JsonGenerator generator , JsonpMapper mapper ) {
107- generator .writeStartObject ();
108- serializeInternal (generator , mapper );
109- generator .writeEnd ();
153+ public Maxmind maxmind () {
154+ return TaggedUnionUtils .get (this , Kind .Maxmind );
155+ }
156+
157+ /**
158+ * Is this variant instance of kind {@code ipinfo}?
159+ */
160+ public boolean isIpinfo () {
161+ return _kind == Kind .Ipinfo ;
110162 }
111163
112- protected void serializeInternal (JsonGenerator generator , JsonpMapper mapper ) {
164+ /**
165+ * Get the {@code ipinfo} variant value.
166+ *
167+ * @throws IllegalStateException
168+ * if the current variant is not of the {@code ipinfo} kind.
169+ */
170+ public Ipinfo ipinfo () {
171+ return TaggedUnionUtils .get (this , Kind .Ipinfo );
172+ }
173+
174+ @ Override
175+ @ SuppressWarnings ("unchecked" )
176+ public void serialize (JsonGenerator generator , JsonpMapper mapper ) {
177+
178+ generator .writeStartObject ();
113179
114180 generator .writeKey ("name" );
115181 generator .write (this .name );
116182
117- generator .writeKey ("maxmind" );
118- this .maxmind .serialize (generator , mapper );
183+ generator .writeKey (_kind .jsonValue ());
184+ if (_value instanceof JsonpSerializable ) {
185+ ((JsonpSerializable ) _value ).serialize (generator , mapper );
186+ }
187+
188+ generator .writeEnd ();
119189
120190 }
121191
@@ -124,18 +194,13 @@ public String toString() {
124194 return JsonpUtils .toString (this );
125195 }
126196
127- // ---------------------------------------------------------------------------------------------
128-
129- /**
130- * Builder for {@link DatabaseConfiguration}.
131- */
132-
133197 public static class Builder extends WithJsonObjectBuilderBase <Builder >
134198 implements
135199 ObjectBuilder <DatabaseConfiguration > {
136- private String name ;
200+ private Kind _kind ;
201+ private Object _value ;
137202
138- private Maxmind maxmind ;
203+ private String name ;
139204
140205 /**
141206 * Required - The provider-assigned name of the IP geolocation database to
@@ -148,64 +213,62 @@ public final Builder name(String value) {
148213 return this ;
149214 }
150215
151- /**
152- * Required - The configuration necessary to identify which IP geolocation
153- * provider to use to download the database, as well as any provider-specific
154- * configuration necessary for such downloading. At present, the only supported
155- * provider is maxmind, and the maxmind provider requires that an account_id
156- * (string) is configured.
157- * <p>
158- * API name: {@code maxmind}
159- */
160- public final Builder maxmind (Maxmind value ) {
161- this .maxmind = value ;
216+ @ Override
217+ protected Builder self () {
162218 return this ;
163219 }
220+ public ContainerBuilder maxmind (Maxmind v ) {
221+ this ._kind = Kind .Maxmind ;
222+ this ._value = v ;
223+ return new ContainerBuilder ();
224+ }
164225
165- /**
166- * Required - The configuration necessary to identify which IP geolocation
167- * provider to use to download the database, as well as any provider-specific
168- * configuration necessary for such downloading. At present, the only supported
169- * provider is maxmind, and the maxmind provider requires that an account_id
170- * (string) is configured.
171- * <p>
172- * API name: {@code maxmind}
173- */
174- public final Builder maxmind (Function <Maxmind .Builder , ObjectBuilder <Maxmind >> fn ) {
226+ public ContainerBuilder maxmind (Function <Maxmind .Builder , ObjectBuilder <Maxmind >> fn ) {
175227 return this .maxmind (fn .apply (new Maxmind .Builder ()).build ());
176228 }
177229
178- @ Override
179- protected Builder self () {
180- return this ;
230+ public ContainerBuilder ipinfo (Ipinfo v ) {
231+ this ._kind = Kind .Ipinfo ;
232+ this ._value = v ;
233+ return new ContainerBuilder ();
234+ }
235+
236+ public ContainerBuilder ipinfo (Function <Ipinfo .Builder , ObjectBuilder <Ipinfo >> fn ) {
237+ return this .ipinfo (fn .apply (new Ipinfo .Builder ()).build ());
181238 }
182239
183- /**
184- * Builds a {@link DatabaseConfiguration}.
185- *
186- * @throws NullPointerException
187- * if some of the required fields are null.
188- */
189240 public DatabaseConfiguration build () {
190241 _checkSingleUse ();
191-
192242 return new DatabaseConfiguration (this );
193243 }
194- }
195-
196- // ---------------------------------------------------------------------------------------------
197244
198- /**
199- * Json deserializer for {@link DatabaseConfiguration}
200- */
201- public static final JsonpDeserializer <DatabaseConfiguration > _DESERIALIZER = ObjectBuilderDeserializer
202- .lazy (Builder ::new , DatabaseConfiguration ::setupDatabaseConfigurationDeserializer );
245+ public class ContainerBuilder implements ObjectBuilder <DatabaseConfiguration > {
246+
247+ /**
248+ * Required - The provider-assigned name of the IP geolocation database to
249+ * download.
250+ * <p>
251+ * API name: {@code name}
252+ */
253+ public final ContainerBuilder name (String value ) {
254+ Builder .this .name = value ;
255+ return this ;
256+ }
257+
258+ public DatabaseConfiguration build () {
259+ return Builder .this .build ();
260+ }
261+ }
262+ }
203263
204- protected static void setupDatabaseConfigurationDeserializer (ObjectDeserializer <DatabaseConfiguration . Builder > op ) {
264+ protected static void setupDatabaseConfigurationDeserializer (ObjectDeserializer <Builder > op ) {
205265
206266 op .add (Builder ::name , JsonpDeserializer .stringDeserializer (), "name" );
207267 op .add (Builder ::maxmind , Maxmind ._DESERIALIZER , "maxmind" );
268+ op .add (Builder ::ipinfo , Ipinfo ._DESERIALIZER , "ipinfo" );
208269
209270 }
210271
272+ public static final JsonpDeserializer <DatabaseConfiguration > _DESERIALIZER = ObjectBuilderDeserializer
273+ .lazy (Builder ::new , DatabaseConfiguration ::setupDatabaseConfigurationDeserializer , Builder ::build );
211274}
0 commit comments