Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-generated client code using latest OpenSearch API specification #1465

Merged
merged 1 commit into from
Mar 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -87,6 +87,9 @@ public class PluginStats implements PlainJsonSerializable, ToCopyableBuilder<Plu
@Nonnull
private final String opensearchVersion;

@Nonnull
private final List<String> optionalExtendedPlugins;

@Nonnull
private final String version;

@@ -102,6 +105,7 @@ private PluginStats(Builder builder) {
this.licensed = builder.licensed;
this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name");
this.opensearchVersion = ApiTypeHelper.requireNonNull(builder.opensearchVersion, this, "opensearchVersion");
this.optionalExtendedPlugins = ApiTypeHelper.unmodifiable(builder.optionalExtendedPlugins);
this.version = ApiTypeHelper.requireNonNull(builder.version, this, "version");
}

@@ -180,6 +184,14 @@ public final String opensearchVersion() {
return this.opensearchVersion;
}

/**
* API name: {@code optional_extended_plugins}
*/
@Nonnull
public final List<String> optionalExtendedPlugins() {
return this.optionalExtendedPlugins;
}

/**
* Required - API name: {@code version}
*/
@@ -234,6 +246,15 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.writeKey("opensearch_version");
generator.write(this.opensearchVersion);

if (ApiTypeHelper.isDefined(this.optionalExtendedPlugins)) {
generator.writeKey("optional_extended_plugins");
generator.writeStartArray();
for (String item0 : this.optionalExtendedPlugins) {
generator.write(item0);
}
generator.writeEnd();
}

generator.writeKey("version");
generator.write(this.version);
}
@@ -266,6 +287,8 @@ public static class Builder extends ObjectBuilderBase implements CopyableBuilder
private Boolean licensed;
private String name;
private String opensearchVersion;
@Nullable
private List<String> optionalExtendedPlugins;
private String version;

public Builder() {}
@@ -280,6 +303,7 @@ private Builder(PluginStats o) {
this.licensed = o.licensed;
this.name = o.name;
this.opensearchVersion = o.opensearchVersion;
this.optionalExtendedPlugins = _listCopy(o.optionalExtendedPlugins);
this.version = o.version;
}

@@ -293,6 +317,7 @@ private Builder(Builder o) {
this.licensed = o.licensed;
this.name = o.name;
this.opensearchVersion = o.opensearchVersion;
this.optionalExtendedPlugins = _listCopy(o.optionalExtendedPlugins);
this.version = o.version;
}

@@ -400,6 +425,32 @@ public final Builder opensearchVersion(String value) {
return this;
}

/**
* API name: {@code optional_extended_plugins}
*
* <p>
* Adds all elements of <code>list</code> to <code>optionalExtendedPlugins</code>.
* </p>
*/
@Nonnull
public final Builder optionalExtendedPlugins(List<String> list) {
this.optionalExtendedPlugins = _listAddAll(this.optionalExtendedPlugins, list);
return this;
}

/**
* API name: {@code optional_extended_plugins}
*
* <p>
* Adds one or more values to <code>optionalExtendedPlugins</code>.
* </p>
*/
@Nonnull
public final Builder optionalExtendedPlugins(String value, String... values) {
this.optionalExtendedPlugins = _listAdd(this.optionalExtendedPlugins, value, values);
return this;
}

/**
* Required - API name: {@code version}
*/
@@ -443,6 +494,11 @@ protected static void setupPluginStatsDeserializer(ObjectDeserializer<PluginStat
op.add(Builder::licensed, JsonpDeserializer.booleanDeserializer(), "licensed");
op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name");
op.add(Builder::opensearchVersion, JsonpDeserializer.stringDeserializer(), "opensearch_version");
op.add(
Builder::optionalExtendedPlugins,
JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()),
"optional_extended_plugins"
);
op.add(Builder::version, JsonpDeserializer.stringDeserializer(), "version");
}

@@ -458,6 +514,7 @@ public int hashCode() {
result = 31 * result + Objects.hashCode(this.licensed);
result = 31 * result + this.name.hashCode();
result = 31 * result + this.opensearchVersion.hashCode();
result = 31 * result + Objects.hashCode(this.optionalExtendedPlugins);
result = 31 * result + this.version.hashCode();
return result;
}
@@ -476,6 +533,7 @@ public boolean equals(Object o) {
&& Objects.equals(this.licensed, other.licensed)
&& this.name.equals(other.name)
&& this.opensearchVersion.equals(other.opensearchVersion)
&& Objects.equals(this.optionalExtendedPlugins, other.optionalExtendedPlugins)
&& this.version.equals(other.version);
}
}
685 changes: 483 additions & 202 deletions java-codegen/opensearch-openapi.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -474,20 +474,20 @@ private Shape visit(
taggedUnion.addVariant(name, mapType(s));
});
} else {
if (unionSchema.isObject()) {
taggedUnion.setExternallyDiscriminated(
unionSchema.getMinProperties().orElse(0) == 1
? TaggedUnionShape.ExternallyDiscriminated.REQUIRED
: TaggedUnionShape.ExternallyDiscriminated.OPTIONAL
);
unionSchema.getProperties().ifPresent(props -> props.forEach((k, v) -> taggedUnion.addVariant(k, mapType(v))));
} else {
if (oneOrAnyOf != null) {
taggedUnion.setExternallyDiscriminated(TaggedUnionShape.ExternallyDiscriminated.REQUIRED);
oneOrAnyOf.forEach(s -> {
var prop = s.getProperties().flatMap(m -> m.entrySet().stream().findFirst()).orElseThrow();

taggedUnion.addVariant(prop.getKey(), mapType(prop.getValue()));
});
} else {
taggedUnion.setExternallyDiscriminated(
unionSchema.getMinProperties().orElse(0) == 1
? TaggedUnionShape.ExternallyDiscriminated.REQUIRED
: TaggedUnionShape.ExternallyDiscriminated.OPTIONAL
);
unionSchema.getProperties().ifPresent(props -> props.forEach((k, v) -> taggedUnion.addVariant(k, mapType(v))));
}
}
} else if (isShortcutPropertyObject || schema.determineSingleType().orElse(null) == OpenApiSchemaType.Object) {
@@ -1031,8 +1031,6 @@ private static boolean isExternallyTaggedUnion(List<OpenApiSchema> oneOf) {
}

private static boolean isExternallyTaggedUnionVariant(OpenApiSchema schema) {
return schema.isObject()
&& schema.getProperties().map(Map::size).orElse(0) == 1
&& schema.getRequired().map(Set::size).orElse(0) == 1;
return schema.getProperties().map(Map::size).orElse(0) == 1 && schema.getRequired().map(Set::size).orElse(0) == 1;
}
}
Original file line number Diff line number Diff line change
@@ -74,7 +74,9 @@ private static JsonPointer schema(String namespace, String name) {
)
.with(
schema("_common.aggregations", "AggregationContainer").append("allOf", "0"),
so -> so.withProperties(p -> p.with("aggregations", po -> po.withAliases(Set.of("aggs"))))
so -> so.withProperties(
p -> p.with("aggregations", po -> po.withAliases(Set.of("aggs"))).with("aggs", po -> po.withIgnore(true))
)
)
.with(
schema("_common.aggregations", "BucketsQueryContainer"),