Skip to content

Commit

Permalink
[codegen] update to latest spec
Browse files Browse the repository at this point in the history
  • Loading branch information
l-trotta committed Feb 5, 2025
1 parent a3ee856 commit f46b8b0
Show file tree
Hide file tree
Showing 7 changed files with 984 additions and 164 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@
'ilm.stop.Response': 'ilm/stop/StopIlmResponse.ts#L22-L24',
'indices._types.Alias': 'indices/_types/Alias.ts#L23-L53',
'indices._types.AliasDefinition': 'indices/_types/AliasDefinition.ts#L22-L54',
'indices._types.CacheQueries': 'indices/_types/IndexSettings.ts#L413-L415',
'indices._types.CacheQueries': 'indices/_types/IndexSettings.ts#L414-L416',
'indices._types.DataStream': 'indices/_types/DataStream.ts#L45-L127',
'indices._types.DataStreamIndex': 'indices/_types/DataStream.ts#L136-L157',
'indices._types.DataStreamLifecycle': 'indices/_types/DataStreamLifecycle.ts#L25-L31',
Expand All @@ -1429,7 +1429,7 @@
'indices._types.DownsamplingRound': 'indices/_types/DownsamplingRound.ts#L23-L32',
'indices._types.FailureStore': 'indices/_types/DataStream.ts#L39-L43',
'indices._types.FielddataFrequencyFilter': 'indices/_types/FielddataFrequencyFilter.ts#L22-L26',
'indices._types.IndexCheckOnStartup': 'indices/_types/IndexSettings.ts#L262-L269',
'indices._types.IndexCheckOnStartup': 'indices/_types/IndexSettings.ts#L263-L270',
'indices._types.IndexRouting': 'indices/_types/IndexRouting.ts#L22-L25',
'indices._types.IndexRoutingAllocation': 'indices/_types/IndexRouting.ts#L27-L32',
'indices._types.IndexRoutingAllocationDisk': 'indices/_types/IndexRouting.ts#L62-L64',
Expand All @@ -1439,64 +1439,64 @@
'indices._types.IndexRoutingRebalance': 'indices/_types/IndexRouting.ts#L34-L36',
'indices._types.IndexRoutingRebalanceOptions': 'indices/_types/IndexRouting.ts#L45-L50',
'indices._types.IndexSegmentSort': 'indices/_types/IndexSegmentSort.ts#L22-L27',
'indices._types.IndexSettingBlocks': 'indices/_types/IndexSettings.ts#L254-L260',
'indices._types.IndexSettingBlocks': 'indices/_types/IndexSettings.ts#L255-L261',
'indices._types.IndexSettings': 'indices/_types/IndexSettings.ts#L69-L169',
'indices._types.IndexSettingsAnalysis': 'indices/_types/IndexSettings.ts#L325-L331',
'indices._types.IndexSettingsLifecycle': 'indices/_types/IndexSettings.ts#L276-L315',
'indices._types.IndexSettingsLifecycleStep': 'indices/_types/IndexSettings.ts#L317-L323',
'indices._types.IndexSettingsTimeSeries': 'indices/_types/IndexSettings.ts#L333-L336',
'indices._types.IndexSettingsAnalysis': 'indices/_types/IndexSettings.ts#L326-L332',
'indices._types.IndexSettingsLifecycle': 'indices/_types/IndexSettings.ts#L277-L316',
'indices._types.IndexSettingsLifecycleStep': 'indices/_types/IndexSettings.ts#L318-L324',
'indices._types.IndexSettingsTimeSeries': 'indices/_types/IndexSettings.ts#L334-L337',
'indices._types.IndexState': 'indices/_types/IndexState.ts#L27-L40',
'indices._types.IndexTemplate': 'indices/_types/IndexTemplate.ts#L28-L81',
'indices._types.IndexTemplateDataStreamConfiguration': 'indices/_types/IndexTemplate.ts#L83-L94',
'indices._types.IndexTemplateSummary': 'indices/_types/IndexTemplate.ts#L96-L118',
'indices._types.IndexVersioning': 'indices/_types/IndexSettings.ts#L271-L274',
'indices._types.IndexingPressure': 'indices/_types/IndexSettings.ts#L567-L569',
'indices._types.IndexingPressureMemory': 'indices/_types/IndexSettings.ts#L571-L578',
'indices._types.IndexingSlowlogSettings': 'indices/_types/IndexSettings.ts#L580-L585',
'indices._types.IndexingSlowlogTresholds': 'indices/_types/IndexSettings.ts#L587-L594',
'indices._types.IndexVersioning': 'indices/_types/IndexSettings.ts#L272-L275',
'indices._types.IndexingPressure': 'indices/_types/IndexSettings.ts#L568-L570',
'indices._types.IndexingPressureMemory': 'indices/_types/IndexSettings.ts#L572-L579',
'indices._types.IndexingSlowlogSettings': 'indices/_types/IndexSettings.ts#L581-L586',
'indices._types.IndexingSlowlogTresholds': 'indices/_types/IndexSettings.ts#L588-L595',
'indices._types.ManagedBy': 'indices/_types/DataStream.ts#L32-L37',
'indices._types.MappingLimitSettings': 'indices/_types/IndexSettings.ts#L417-L431',
'indices._types.MappingLimitSettingsDepth': 'indices/_types/IndexSettings.ts#L452-L459',
'indices._types.MappingLimitSettingsDimensionFields': 'indices/_types/IndexSettings.ts#L489-L495',
'indices._types.MappingLimitSettingsFieldNameLength': 'indices/_types/IndexSettings.ts#L480-L487',
'indices._types.MappingLimitSettingsNestedFields': 'indices/_types/IndexSettings.ts#L461-L469',
'indices._types.MappingLimitSettingsNestedObjects': 'indices/_types/IndexSettings.ts#L471-L478',
'indices._types.MappingLimitSettingsSourceFields': 'indices/_types/IndexSettings.ts#L497-L499',
'indices._types.MappingLimitSettingsTotalFields': 'indices/_types/IndexSettings.ts#L433-L450',
'indices._types.Merge': 'indices/_types/IndexSettings.ts#L338-L340',
'indices._types.MergeScheduler': 'indices/_types/IndexSettings.ts#L342-L345',
'indices._types.MappingLimitSettings': 'indices/_types/IndexSettings.ts#L418-L432',
'indices._types.MappingLimitSettingsDepth': 'indices/_types/IndexSettings.ts#L453-L460',
'indices._types.MappingLimitSettingsDimensionFields': 'indices/_types/IndexSettings.ts#L490-L496',
'indices._types.MappingLimitSettingsFieldNameLength': 'indices/_types/IndexSettings.ts#L481-L488',
'indices._types.MappingLimitSettingsNestedFields': 'indices/_types/IndexSettings.ts#L462-L470',
'indices._types.MappingLimitSettingsNestedObjects': 'indices/_types/IndexSettings.ts#L472-L479',
'indices._types.MappingLimitSettingsSourceFields': 'indices/_types/IndexSettings.ts#L498-L500',
'indices._types.MappingLimitSettingsTotalFields': 'indices/_types/IndexSettings.ts#L434-L451',
'indices._types.Merge': 'indices/_types/IndexSettings.ts#L339-L341',
'indices._types.MergeScheduler': 'indices/_types/IndexSettings.ts#L343-L346',
'indices._types.NumericFielddata': 'indices/_types/NumericFielddata.ts#L22-L24',
'indices._types.NumericFielddataFormat': 'indices/_types/NumericFielddataFormat.ts#L20-L23',
'indices._types.Queries': 'indices/_types/IndexSettings.ts#L409-L411',
'indices._types.Queries': 'indices/_types/IndexSettings.ts#L410-L412',
'indices._types.RetentionLease': 'indices/_types/IndexSettings.ts#L65-L67',
'indices._types.SearchIdle': 'indices/_types/IndexSettings.ts#L245-L248',
'indices._types.SearchIdle': 'indices/_types/IndexSettings.ts#L246-L249',
'indices._types.SegmentSortMissing': 'indices/_types/IndexSegmentSort.ts#L43-L46',
'indices._types.SegmentSortMode': 'indices/_types/IndexSegmentSort.ts#L36-L41',
'indices._types.SegmentSortOrder': 'indices/_types/IndexSegmentSort.ts#L29-L34',
'indices._types.SettingsAnalyze': 'indices/_types/IndexSettings.ts#L235-L238',
'indices._types.SettingsHighlight': 'indices/_types/IndexSettings.ts#L230-L233',
'indices._types.SettingsQueryString': 'indices/_types/IndexSettings.ts#L250-L252',
'indices._types.SettingsSearch': 'indices/_types/IndexSettings.ts#L240-L243',
'indices._types.SettingsSimilarity': 'indices/_types/IndexSettings.ts#L171-L182',
'indices._types.SettingsSimilarityBm25': 'indices/_types/IndexSettings.ts#L188-L193',
'indices._types.SettingsSimilarityBoolean': 'indices/_types/IndexSettings.ts#L184-L186',
'indices._types.SettingsSimilarityDfi': 'indices/_types/IndexSettings.ts#L195-L198',
'indices._types.SettingsSimilarityDfr': 'indices/_types/IndexSettings.ts#L200-L205',
'indices._types.SettingsSimilarityIb': 'indices/_types/IndexSettings.ts#L207-L212',
'indices._types.SettingsSimilarityLmd': 'indices/_types/IndexSettings.ts#L214-L217',
'indices._types.SettingsSimilarityLmj': 'indices/_types/IndexSettings.ts#L219-L222',
'indices._types.SettingsSimilarityScripted': 'indices/_types/IndexSettings.ts#L224-L228',
'indices._types.SlowlogSettings': 'indices/_types/IndexSettings.ts#L507-L512',
'indices._types.SlowlogTresholdLevels': 'indices/_types/IndexSettings.ts#L519-L524',
'indices._types.SlowlogTresholds': 'indices/_types/IndexSettings.ts#L514-L517',
'indices._types.SettingsAnalyze': 'indices/_types/IndexSettings.ts#L236-L239',
'indices._types.SettingsHighlight': 'indices/_types/IndexSettings.ts#L231-L234',
'indices._types.SettingsQueryString': 'indices/_types/IndexSettings.ts#L251-L253',
'indices._types.SettingsSearch': 'indices/_types/IndexSettings.ts#L241-L244',
'indices._types.SettingsSimilarity': 'indices/_types/IndexSettings.ts#L171-L183',
'indices._types.SettingsSimilarityBm25': 'indices/_types/IndexSettings.ts#L189-L194',
'indices._types.SettingsSimilarityBoolean': 'indices/_types/IndexSettings.ts#L185-L187',
'indices._types.SettingsSimilarityDfi': 'indices/_types/IndexSettings.ts#L196-L199',
'indices._types.SettingsSimilarityDfr': 'indices/_types/IndexSettings.ts#L201-L206',
'indices._types.SettingsSimilarityIb': 'indices/_types/IndexSettings.ts#L208-L213',
'indices._types.SettingsSimilarityLmd': 'indices/_types/IndexSettings.ts#L215-L218',
'indices._types.SettingsSimilarityLmj': 'indices/_types/IndexSettings.ts#L220-L223',
'indices._types.SettingsSimilarityScripted': 'indices/_types/IndexSettings.ts#L225-L229',
'indices._types.SlowlogSettings': 'indices/_types/IndexSettings.ts#L508-L513',
'indices._types.SlowlogTresholdLevels': 'indices/_types/IndexSettings.ts#L520-L525',
'indices._types.SlowlogTresholds': 'indices/_types/IndexSettings.ts#L515-L518',
'indices._types.SoftDeletes': 'indices/_types/IndexSettings.ts#L50-L63',
'indices._types.SourceMode': 'indices/_types/IndexSettings.ts#L501-L505',
'indices._types.Storage': 'indices/_types/IndexSettings.ts#L526-L535',
'indices._types.StorageType': 'indices/_types/IndexSettings.ts#L537-L565',
'indices._types.SourceMode': 'indices/_types/IndexSettings.ts#L502-L506',
'indices._types.Storage': 'indices/_types/IndexSettings.ts#L527-L536',
'indices._types.StorageType': 'indices/_types/IndexSettings.ts#L538-L566',
'indices._types.TemplateMapping': 'indices/_types/TemplateMapping.ts#L27-L34',
'indices._types.Translog': 'indices/_types/IndexSettings.ts#L347-L369',
'indices._types.TranslogDurability': 'indices/_types/IndexSettings.ts#L371-L386',
'indices._types.TranslogRetention': 'indices/_types/IndexSettings.ts#L388-L407',
'indices._types.Translog': 'indices/_types/IndexSettings.ts#L348-L370',
'indices._types.TranslogDurability': 'indices/_types/IndexSettings.ts#L372-L387',
'indices._types.TranslogRetention': 'indices/_types/IndexSettings.ts#L389-L408',
'indices.add_block.IndicesBlockOptions': 'indices/add_block/IndicesAddBlockRequest.ts#L45-L50',
'indices.add_block.IndicesBlockStatus': 'indices/add_block/IndicesAddBlockResponse.ts#L30-L33',
'indices.add_block.Request': 'indices/add_block/IndicesAddBlockRequest.ts#L24-L43',
Expand Down Expand Up @@ -1856,8 +1856,8 @@
'ml._types.AnalysisLimits': 'ml/_types/Analysis.ts#L161-L172',
'ml._types.AnalysisMemoryLimit': 'ml/_types/Analysis.ts#L174-L179',
'ml._types.Anomaly': 'ml/_types/Anomaly.ts#L24-L121',
'ml._types.AnomalyCause': 'ml/_types/Anomaly.ts#L123-L138',
'ml._types.AnomalyExplanation': 'ml/_types/Anomaly.ts#L156-L197',
'ml._types.AnomalyCause': 'ml/_types/Anomaly.ts#L123-L139',
'ml._types.AnomalyExplanation': 'ml/_types/Anomaly.ts#L157-L198',
'ml._types.ApiKeyAuthorization': 'ml/_types/Authorization.ts#L20-L29',
'ml._types.AppliesTo': 'ml/_types/Rule.ts#L67-L72',
'ml._types.BucketInfluencer': 'ml/_types/Bucket.ts#L79-L127',
Expand Down Expand Up @@ -1934,14 +1934,14 @@
'ml._types.Filter': 'ml/_types/Filter.ts#L22-L29',
'ml._types.FilterRef': 'ml/_types/Filter.ts#L31-L41',
'ml._types.FilterType': 'ml/_types/Filter.ts#L43-L46',
'ml._types.GeoResults': 'ml/_types/Anomaly.ts#L145-L154',
'ml._types.GeoResults': 'ml/_types/Anomaly.ts#L146-L155',
'ml._types.Hyperparameter': 'ml/_types/TrainedModel.ts#L261-L275',
'ml._types.Hyperparameters': 'ml/_types/DataframeAnalytics.ts#L420-L526',
'ml._types.Include': 'ml/_types/Include.ts#L20-L47',
'ml._types.InferenceConfigCreateContainer': 'ml/_types/inference.ts#L23-L80',
'ml._types.InferenceConfigUpdateContainer': 'ml/_types/inference.ts#L284-L306',
'ml._types.InferenceResponseResult': 'ml/_types/inference.ts#L447-L495',
'ml._types.Influence': 'ml/_types/Anomaly.ts#L140-L143',
'ml._types.Influence': 'ml/_types/Anomaly.ts#L141-L144',
'ml._types.Influencer': 'ml/_types/Influencer.ts#L24-L76',
'ml._types.Job': 'ml/_types/Job.ts#L61-L180',
'ml._types.JobBlocked': 'ml/_types/Job.ts#L392-L395',
Expand Down Expand Up @@ -2642,8 +2642,10 @@
'shutdown.get_node.ShutdownType': 'shutdown/get_node/ShutdownGetNodeResponse.ts#L40-L43',
'shutdown.put_node.Request': 'shutdown/put_node/ShutdownPutNodeRequest.ts#L25-L102',
'shutdown.put_node.Response': 'shutdown/put_node/ShutdownPutNodeResponse.ts#L22-L24',
'simulate.ingest.IngestDocumentSimulation': 'simulate/ingest/SimulateIngestResponse.ts#L35-L78',
'simulate.ingest.Request': 'simulate/ingest/SimulateIngestRequest.ts#L29-L90',
'simulate.ingest.Response': 'simulate/ingest/SimulateIngestResponse.ts#L22-L24',
'simulate.ingest.Response': 'simulate/ingest/SimulateIngestResponse.ts#L27-L29',
'simulate.ingest.SimulateIngestDocumentResult': 'simulate/ingest/SimulateIngestResponse.ts#L31-L33',
'slm._types.Configuration': 'slm/_types/SnapshotLifecycle.ts#L109-L139',
'slm._types.InProgress': 'slm/_types/SnapshotLifecycle.ts#L141-L146',
'slm._types.Invocation': 'slm/_types/SnapshotLifecycle.ts#L148-L151',
Expand Down Expand Up @@ -3038,10 +3040,10 @@
if (hash.length > 1) {
hash = hash.substring(1);
}
window.location = "https://github.com/elastic/elasticsearch-specification/tree/38010a06f1aa679f9429f12a2c65cfeb9a4ac287/specification/" + (paths[hash] || "");
window.location = "https://github.com/elastic/elasticsearch-specification/tree/84ad6dc6dc148b339efb98e35ec166a97774ea92/specification/" + (paths[hash] || "");
</script>
</head>
<body>
Please see the <a href="https://github.com/elastic/elasticsearch-specification/tree/38010a06f1aa679f9429f12a2c65cfeb9a4ac287/specification/">Elasticsearch API specification</a>.
Please see the <a href="https://github.com/elastic/elasticsearch-specification/tree/84ad6dc6dc148b339efb98e35ec166a97774ea92/specification/">Elasticsearch API specification</a>.
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package co.elastic.clients.elasticsearch.indices;

import co.elastic.clients.json.JsonData;
import co.elastic.clients.json.JsonEnum;
import co.elastic.clients.json.JsonpDeserializable;
import co.elastic.clients.json.JsonpDeserializer;
Expand All @@ -29,10 +30,11 @@
import co.elastic.clients.json.ObjectDeserializer;
import co.elastic.clients.util.ApiTypeHelper;
import co.elastic.clients.util.ObjectBuilder;
import co.elastic.clients.util.TaggedUnion;
import co.elastic.clients.util.OpenTaggedUnion;
import co.elastic.clients.util.TaggedUnionUtils;
import co.elastic.clients.util.WithJsonObjectBuilderBase;
import jakarta.json.stream.JsonGenerator;
import java.lang.Object;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -61,10 +63,7 @@
* specification</a>
*/
@JsonpDeserializable
public class SettingsSimilarity
implements
TaggedUnion<SettingsSimilarity.Kind, SettingsSimilarityVariant>,
JsonpSerializable {
public class SettingsSimilarity implements OpenTaggedUnion<SettingsSimilarity.Kind, Object>, JsonpSerializable {

/**
* {@link SettingsSimilarity} variant kinds.
Expand All @@ -91,6 +90,9 @@ public enum Kind implements JsonEnum {

Scripted("scripted"),

/** A custom {@code SettingsSimilarity} defined by a plugin */
_Custom(null)

;

private final String jsonValue;
Expand All @@ -106,36 +108,48 @@ public String jsonValue() {
}

private final Kind _kind;
private final SettingsSimilarityVariant _value;
private final Object _value;

@Override
public final Kind _kind() {
return _kind;
}

@Override
public final SettingsSimilarityVariant _get() {
public final Object _get() {
return _value;
}

public SettingsSimilarity(SettingsSimilarityVariant value) {

this._kind = ApiTypeHelper.requireNonNull(value._settingsSimilarityKind(), this, "<variant kind>");
this._value = ApiTypeHelper.requireNonNull(value, this, "<variant value>");
this._customKind = null;

}

private SettingsSimilarity(Builder builder) {

this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, "<variant kind>");
this._value = ApiTypeHelper.requireNonNull(builder._value, builder, "<variant value>");
this._customKind = builder._customKind;

}

public static SettingsSimilarity of(Function<Builder, ObjectBuilder<SettingsSimilarity>> fn) {
return fn.apply(new Builder()).build();
}

/**
* Build a custom plugin-defined {@code SettingsSimilarity}, given its kind and
* some JSON data
*/
public SettingsSimilarity(String kind, JsonData value) {
this._kind = Kind._Custom;
this._value = value;
this._customKind = kind;
}

/**
* Is this variant instance of kind {@code BM25}?
*/
Expand Down Expand Up @@ -273,6 +287,35 @@ public SettingsSimilarityScripted scripted() {
return TaggedUnionUtils.get(this, Kind.Scripted);
}

@Nullable
private final String _customKind;

/**
* Is this a custom {@code SettingsSimilarity} defined by a plugin?
*/
public boolean _isCustom() {
return _kind == Kind._Custom;
}

/**
* Get the actual kind when {@code _kind()} equals {@link Kind#_Custom}
* (plugin-defined variant).
*/
@Nullable
public final String _customKind() {
return _customKind;
}

/**
* Get the custom plugin-defined variant value.
*
* @throws IllegalStateException
* if the current variant is not {@link Kind#_Custom}.
*/
public JsonData _custom() {
return TaggedUnionUtils.get(this, Kind._Custom);
}

@Override
public void serialize(JsonGenerator generator, JsonpMapper mapper) {

Expand All @@ -289,7 +332,8 @@ public static class Builder extends WithJsonObjectBuilderBase<Builder>
implements
ObjectBuilder<SettingsSimilarity> {
private Kind _kind;
private SettingsSimilarityVariant _value;
private Object _value;
private String _customKind;

@Override
protected Builder self() {
Expand Down Expand Up @@ -383,6 +427,22 @@ public ObjectBuilder<SettingsSimilarity> scripted(
return this.scripted(fn.apply(new SettingsSimilarityScripted.Builder()).build());
}

/**
* Define this {@code SettingsSimilarity} as a plugin-defined variant.
*
* @param name
* the plugin-defined identifier
* @param data
* the data for this custom {@code SettingsSimilarity}. It is
* converted internally to {@link JsonData}.
*/
public ObjectBuilder<SettingsSimilarity> _custom(String name, Object data) {
this._kind = Kind._Custom;
this._customKind = name;
this._value = JsonData.of(data);
return this;
}

public SettingsSimilarity build() {
_checkSingleUse();
return new SettingsSimilarity(this);
Expand All @@ -401,6 +461,11 @@ protected static void setupSettingsSimilarityDeserializer(ObjectDeserializer<Bui
op.add(Builder::lmjelinekmercer, SettingsSimilarityLmj._DESERIALIZER, "LMJelinekMercer");
op.add(Builder::scripted, SettingsSimilarityScripted._DESERIALIZER, "scripted");

op.setUnknownFieldHandler((builder, name, parser, mapper) -> {
JsonpUtils.ensureCustomVariantsAllowed(parser, mapper);
builder._custom(name, JsonData._DESERIALIZER.deserialize(parser, mapper));
});

op.setTypeProperty("type", null);

}
Expand Down
Loading

0 comments on commit f46b8b0

Please sign in to comment.