From 4f3946f59f93ace5ee7f5f474667b54a9ba909be Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Mon, 13 Feb 2023 12:29:05 +1300 Subject: [PATCH 01/50] OpenAPI generator from scratch Signed-off-by: Thomas Farr --- java-codegen/build.gradle.kts | 222 ++++++++++++++++++ .../client/codegen/ApiSpecification.java | 108 +++++++++ .../opensearch/client/codegen/Generator.java | 20 ++ .../org/opensearch/client/codegen/Main.java | 14 ++ .../client/codegen/NameSanitizer.java | 20 ++ .../opensearch/client/codegen/Renderer.java | 58 +++++ .../opensearch/client/codegen/TypeMapper.java | 85 +++++++ .../ApiSpecificationParseException.java | 7 + .../codegen/exceptions/RenderException.java | 7 + .../client/codegen/model/Field.java | 17 ++ .../codegen/model/OperationRequest.java | 37 +++ .../opensearch/client/codegen/model/Type.java | 212 +++++++++++++++++ .../client/codegen/utils/Schemas.java | 15 ++ .../templates/OperationRequest.mustache | 160 +++++++++++++ .../client/codegen/version.properties | 10 + settings.gradle.kts | 1 + 16 files changed, 993 insertions(+) create mode 100644 java-codegen/build.gradle.kts create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/Main.java create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/NameSanitizer.java create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/exceptions/ApiSpecificationParseException.java create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/exceptions/RenderException.java create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/model/OperationRequest.java create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/utils/Schemas.java create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/version.properties diff --git a/java-codegen/build.gradle.kts b/java-codegen/build.gradle.kts new file mode 100644 index 0000000000..fdc0380c24 --- /dev/null +++ b/java-codegen/build.gradle.kts @@ -0,0 +1,222 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +import com.github.jk1.license.ProjectData +import com.github.jk1.license.render.ReportRenderer +import java.io.FileWriter + +buildscript { + repositories { + mavenLocal() + maven(url = "https://aws.oss.sonatype.org/content/repositories/snapshots") + mavenCentral() + maven(url = "https://plugins.gradle.org/m2/") + } + dependencies { + "classpath"(group = "org.opensearch.gradle", name = "build-tools", version = "3.0.0-SNAPSHOT") + } +} + +plugins { + java + `java-library` + checkstyle + `maven-publish` + id("com.github.jk1.dependency-license-report") version "1.19" +} +apply(plugin = "opensearch.repositories") + +checkstyle { + toolVersion = "10.0" +} + +java { + targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_11 + + withJavadocJar() + withSourcesJar() +} + +tasks.withType { + expand( + "version" to version, + "git_revision" to (if (rootProject.extra.has("gitHashFull")) rootProject.extra["gitHashFull"] else "unknown") + ) +} + +tasks.withType().configureEach{ + options { + encoding = "UTF-8" + } +} + +tasks.withType { + doFirst { + if (rootProject.extra.has("gitHashFull")) { + val jar = this as Jar + jar.manifest.attributes["X-Git-Revision"] = rootProject.extra["gitHashFull"] + jar.manifest.attributes["X-Git-Commit-Time"] = rootProject .extra["gitCommitTime"] + } else { + throw GradleException("No git information available") + } + } + + manifest { + attributes["Implementation-Title"] = "OpenSearch Java client code generator" + attributes["Implementation-Vendor"] = "OpenSearch" + attributes["Implementation-URL"] = "https://github.com/opensearch-project/opensearch-java/" + attributes["Build-Date"] = rootProject.extra["buildTime"] + } + + metaInf { + from("../LICENSE.txt") + from("../NOTICE.txt") + } +} + +dependencies { + // Apache 2.0 + implementation("org.openapi4j:openapi-parser:1.0.7") + + // (New) BSD + implementation("com.samskivert:jmustache:1.15") + + // Apache 2.0 + implementation("org.apache.commons:commons-text:1.10.0") + + // Apache 2.0 + implementation("com.fasterxml.jackson.core:jackson-core:2.14.2") + implementation("com.fasterxml.jackson.core:jackson-databind:2.14.2") + + // Apache 2.0 + implementation("com.google.googlejavaformat:google-java-format:1.15.0") + + // Apache 2.0 + // https://search.maven.org/artifact/com.google.code.findbugs/jsr305 + api("com.google.code.findbugs:jsr305:3.0.2") + + // Eclipse 1.0 + testImplementation("junit", "junit" , "4.13.2") { + exclude(group = "org.hamcrest") + } +} + +licenseReport { + renderers = arrayOf(SpdxReporter(File(rootProject.buildDir, "release/codegen-dependencies.csv"))) + excludeGroups = arrayOf() +} + +class SpdxReporter(val dest: File) : ReportRenderer { + // License names to their SPDX identifier + val spdxIds = mapOf( + "Apache License, Version 2.0" to "Apache-2.0", + "The Apache Software License, Version 2.0" to "Apache-2.0", + "BSD Zero Clause License" to "0BSD", + "Eclipse Public License 2.0" to "EPL-2.0", + "Eclipse Public License v. 2.0" to "EPL-2.0", + "GNU General Public License, version 2 with the GNU Classpath Exception" to "GPL-2.0 WITH Classpath-exception-2.0", + "COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0" to "CDDL-1.0" + ) + + private fun quote(str: String) : String { + return if (str.contains(',') || str.contains("\"")) { + "\"" + str.replace("\"", "\"\"") + "\"" + } else { + str + } + } + + override fun render(data: ProjectData?) { + dest.parentFile.mkdirs() + FileWriter(dest).use { out -> + out.append("name,url,version,revision,license\n") + data?.allDependencies?.forEach { dep -> + val info = com.github.jk1.license.render.LicenseDataCollector.multiModuleLicenseInfo(dep) + + val depVersion = dep.version + val depName = dep.group + ":" + dep.name + val depUrl = info.moduleUrls.first() + + val licenseIds = info.licenses.mapNotNull { license -> + license.name?.let { + checkNotNull(spdxIds[it]) { "No SPDX identifier for $license" } + } + }.toSet() + + // Combine multiple licenses. + // See https://spdx.github.io/spdx-spec/appendix-IV-SPDX-license-expressions/#composite-license-expressions + val licenseId = licenseIds.joinToString(" OR ") + out.append("${quote(depName)},${quote(depUrl)},${quote(depVersion)},,${quote(licenseId)}\n") + } + } + } +} + +tasks.withType { + doLast { + ant.withGroovyBuilder { + "checksum"("algorithm" to "md5", "file" to archivePath) + "checksum"("algorithm" to "sha1", "file" to archivePath) + "checksum"("algorithm" to "sha-256", "file" to archivePath, "fileext" to ".sha256") + "checksum"("algorithm" to "sha-512", "file" to archivePath, "fileext" to ".sha512") + } + } +} + +publishing { + repositories{ + if (version.toString().endsWith("SNAPSHOT")) { + maven("https://aws.oss.sonatype.org/content/repositories/snapshots/") { + name = "Snapshots" + credentials { + username = System.getenv("SONATYPE_USERNAME") + password = System.getenv("SONATYPE_PASSWORD") + } + } + } + maven("${rootProject.buildDir}/repository") { + name = "localRepo" + } + } + publications { + create("publishMaven") { + from(components["java"]) + pom { + name.set("OpenSearch Java Client Code Generator") + packaging = "jar" + artifactId = "opensearch-java-codegen" + description.set("Code generator for the OpenSearch Java Client.") + url.set("https://github.com/opensearch-project/opensearch-java/") + scm { + connection.set("scm:git@github.com:opensearch-project/opensearch-java.git") + developerConnection.set("scm:git@github.com:opensearch-project/opensearch-java.git") + url.set("git@github.com:opensearch-project/opensearch-java.git") + } + licenses { + license { + name.set("The Apache License, Version 2.0") + url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") + } + } + developers { + developer { + name.set("opensearch-project") + url.set("https://www.opensearch.org") + inceptionYear.set("2021") + } + } + } + } + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java b/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java new file mode 100644 index 0000000000..181b193854 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java @@ -0,0 +1,108 @@ +package org.opensearch.client.codegen; + +import org.openapi4j.core.exception.DecodeException; +import org.openapi4j.core.exception.ResolutionException; +import org.openapi4j.core.model.OAIContext; +import org.openapi4j.core.model.reference.Reference; +import org.openapi4j.core.validation.ValidationException; +import org.openapi4j.parser.OpenApi3Parser; +import org.openapi4j.parser.model.AbsRefOpenApiSchema; +import org.openapi4j.parser.model.v3.*; +import org.opensearch.client.codegen.exceptions.ApiSpecificationParseException; +import org.opensearch.client.codegen.model.Field; +import org.opensearch.client.codegen.model.OperationRequest; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; + +public class ApiSpecification { + private final OpenApi3 api; + private final OAIContext context; + private final List operationRequests; + private final TypeMapper typeMapper; + + private ApiSpecification(OpenApi3 api) throws ApiSpecificationParseException { + this.api = api; + context = api.getContext(); + operationRequests = new ArrayList<>(); + typeMapper = new TypeMapper(this.api); + visit(this.api); + } + + public static ApiSpecification parse(File schemaFile) throws ApiSpecificationParseException { + try { + OpenApi3 api = new OpenApi3Parser().parse(schemaFile, true); + return new ApiSpecification(api); + } catch (ResolutionException | ValidationException e) { + throw new ApiSpecificationParseException("Failed to parse schema: " + schemaFile, e); + } + } + + public List getOperationRequests() { + return Collections.unmodifiableList(operationRequests); + } + + private void visit(OpenApi3 api) throws ApiSpecificationParseException { + for (Map.Entry entry : api.getPaths().entrySet()) { + String httpPath = entry.getKey(); + Path path = entry.getValue(); + + visit(httpPath, path); + } + } + + private void visit(String httpPath, Path path) throws ApiSpecificationParseException { + for (Map.Entry entry : path.getOperations().entrySet()) { + String httpMethod = entry.getKey(); + Operation operation = entry.getValue(); + visit(httpPath, path, httpMethod, operation); + } + } + + private void visit(String httpPath, Path path, String httpMethod, Operation operation) throws ApiSpecificationParseException { + OperationRequest operationRequest = new OperationRequest(); + operationRequest.operationId = operation.getOperationId(); + operationRequest.description = operation.getDescription(); + operationRequest.httpMethod = httpMethod; + operationRequest.httpPath = httpPath; + + RequestBody requestBody = resolve(operation.getRequestBody()); + + if (requestBody != null) { + resolve(requestBody.getContentMediaType("application/json").getSchema()) + .getProperties() + .forEach((name, schema) -> operationRequest.addBodyField(new Field(name, typeMapper.mapType(schema)))); + } + + Stream.of(path.getParametersIn(context, "query"), operation.getParametersIn(context, "query")) + .flatMap(List::stream) + .map(p -> new Field(p.getName(), typeMapper.mapType(p.getSchema()))) + .forEach(operationRequest::addQueryParam); + + operationRequests.add(operationRequest); + } + + private RequestBody resolve(RequestBody body) throws ApiSpecificationParseException { + return resolve(body, RequestBody.class); + } + + private Schema resolve(Schema schema) throws ApiSpecificationParseException { + return resolve(schema, Schema.class); + } + + private > S resolve(S schema, Class clazz) throws ApiSpecificationParseException { + while (schema != null && schema.isRef()) { + Reference ref = schema.getReference(api.getContext()); + try { + schema = ref.getMappedContent(clazz); + } catch (DecodeException e) { + throw new ApiSpecificationParseException("Failed to decode reference as " + schema.getClass() + ": " + ref, e); + } + } + return schema; + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java b/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java new file mode 100644 index 0000000000..668284ac2e --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java @@ -0,0 +1,20 @@ +package org.opensearch.client.codegen; + +import org.opensearch.client.codegen.exceptions.ApiSpecificationParseException; +import org.opensearch.client.codegen.exceptions.RenderException; + +import java.io.File; + +public class Generator { + private final ApiSpecification apiSpecification; + private final Renderer renderer; + + public Generator(File schemaFile) throws ApiSpecificationParseException { + apiSpecification = ApiSpecification.parse(schemaFile); + renderer = new Renderer(); + } + + public void generate() throws RenderException { + renderer.render(apiSpecification.getOperationRequests().get(12)); + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/Main.java b/java-codegen/src/main/java/org/opensearch/client/codegen/Main.java new file mode 100644 index 0000000000..66bf6351e0 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/Main.java @@ -0,0 +1,14 @@ +package org.opensearch.client.codegen; + +import java.io.File; + +public class Main { + public static void main(String[] args) { + try { + Generator generator = new Generator(new File(args[0])); + generator.generate(); + } catch (Throwable e) { + e.printStackTrace(System.err); + } + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/NameSanitizer.java b/java-codegen/src/main/java/org/opensearch/client/codegen/NameSanitizer.java new file mode 100644 index 0000000000..2e4421ae48 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/NameSanitizer.java @@ -0,0 +1,20 @@ +package org.opensearch.client.codegen; + +import org.apache.commons.text.CaseUtils; + +import java.util.HashSet; +import java.util.Set; + +public class NameSanitizer { + private static final Set reservedWords = new HashSet<>(){{ + add("transient"); + }}; + + public static String wireNameToField(String wireName) { + String name = CaseUtils.toCamelCase(wireName, false, '_'); + if (reservedWords.contains(name)) { + name += "_"; + } + return name; + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java b/java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java new file mode 100644 index 0000000000..f9082a46a2 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java @@ -0,0 +1,58 @@ +package org.opensearch.client.codegen; + +import com.google.googlejavaformat.java.Formatter; +import com.google.googlejavaformat.java.FormatterException; +import com.google.googlejavaformat.java.JavaFormatterOptions; +import com.samskivert.mustache.Mustache; +import com.samskivert.mustache.MustacheException; +import com.samskivert.mustache.Template; +import org.apache.commons.text.StringEscapeUtils; +import org.opensearch.client.codegen.exceptions.RenderException; + +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.StringWriter; +import java.io.Writer; +import java.util.HashMap; +import java.util.Map; +import java.util.MissingResourceException; + +public class Renderer { + private static final Map lambdas = new HashMap<>() {{ + put("dq", (frag, out) -> out.write('\"' + StringEscapeUtils.escapeJava(frag.execute()) + '\"')); + }}; + + private final Mustache.Compiler compiler; + private final Formatter formatter; + + public Renderer() { + compiler = Mustache.compiler().withLoader(name -> { + InputStream stream = Renderer.class.getResourceAsStream("templates/" + name + ".mustache"); + if (stream == null) { + throw new MissingResourceException("Unable to find template", Renderer.class.getName(), name); + } + return new InputStreamReader(stream); + }); + formatter = new Formatter( + JavaFormatterOptions.builder() + .style(JavaFormatterOptions.Style.AOSP) + .formatJavadoc(true) + .build()); + } + + public void render(T object) throws RenderException { + try { + Template template = compiler.loadTemplate(object.getClass().getSimpleName()); + Writer writer = new StringWriter(); + + template.execute(object, lambdas, writer); + + String output = writer.toString(); + output = true ? formatter.formatSource(output) : output; + + System.out.println(output); + } catch (MustacheException | FormatterException e) { + throw new RenderException("Failed to render: " + object, e); + } + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java b/java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java new file mode 100644 index 0000000000..d950c7ca7c --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java @@ -0,0 +1,85 @@ +package org.opensearch.client.codegen; + +import org.openapi4j.core.model.v3.OAI3SchemaKeywords; +import org.openapi4j.parser.model.v3.OpenApi3; +import org.openapi4j.parser.model.v3.Schema; +import org.opensearch.client.codegen.model.Type; +import org.opensearch.client.codegen.utils.Schemas; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public class TypeMapper { + private final OpenApi3 api; + private final Map cache = new ConcurrentHashMap<>(); + + public TypeMapper(OpenApi3 api) { + this.api = api; + } + + public Type mapType(Schema schema) { + return mapType(schema, false); + } + + public Type mapType(Schema schema, boolean boxed) { + Type type = cache.computeIfAbsent(schema, this::mapTypeInner); + return boxed ? type.boxed() : type; + } + + private Type mapTypeInner(Schema schema) { + if (schema.isRef()) { + Schema target = schema.getFlatSchema(api.getContext()); + + if (!shouldKeepRef(target)) { + return mapType(target); + } + + if (Schemas.isObject(target) && target.getProperties() == null) { + return new Type(target, "Map", "String", "JsonData"); + } + + String[] refParts = schema.getRef().split("/"); + return new Type(target, refParts[refParts.length - 1]); + } + + String type = schema.getType(); + + if (type == null) { + return new Type(schema, "JsonData"); + } + + switch (type) { + case OAI3SchemaKeywords.TYPE_ARRAY: + return new Type(schema, "List", mapType(schema.getItemsSchema(), true)); + case OAI3SchemaKeywords.TYPE_STRING: + return new Type(schema, "String"); + case OAI3SchemaKeywords.TYPE_BOOLEAN: + return new Type(schema, "boolean"); + case OAI3SchemaKeywords.TYPE_INTEGER: + String format = schema.getFormat(); + if (format == null) format = OAI3SchemaKeywords.FORMAT_INT32; + switch (format) { + case OAI3SchemaKeywords.FORMAT_INT32: + return new Type(schema, "int"); + case OAI3SchemaKeywords.FORMAT_INT64: + return new Type(schema, "long"); + default: + throw new UnsupportedOperationException("Can not get type name for integer with format: " + format); + } + } + + throw new UnsupportedOperationException("Can not get type name for: " + type); + } + + private boolean shouldKeepRef(Schema schema) { + if (Schemas.isObject(schema)) { + return true; + } + + if (Schemas.isString(schema)) { + return schema.hasEnums(); + } + + return false; + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/exceptions/ApiSpecificationParseException.java b/java-codegen/src/main/java/org/opensearch/client/codegen/exceptions/ApiSpecificationParseException.java new file mode 100644 index 0000000000..042ad5f8fc --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/exceptions/ApiSpecificationParseException.java @@ -0,0 +1,7 @@ +package org.opensearch.client.codegen.exceptions; + +public class ApiSpecificationParseException extends Exception { + public ApiSpecificationParseException(String msg, Exception inner) { + super(msg, inner); + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/exceptions/RenderException.java b/java-codegen/src/main/java/org/opensearch/client/codegen/exceptions/RenderException.java new file mode 100644 index 0000000000..e3724207d1 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/exceptions/RenderException.java @@ -0,0 +1,7 @@ +package org.opensearch.client.codegen.exceptions; + +public class RenderException extends Exception { + public RenderException(String msg, Exception inner) { + super(msg, inner); + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java new file mode 100644 index 0000000000..3b042a2c5a --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java @@ -0,0 +1,17 @@ +package org.opensearch.client.codegen.model; + +import org.opensearch.client.codegen.NameSanitizer; + +public class Field { + public String wireName; + public Type type; + + public Field(String wireName, Type type) { + this.wireName = wireName; + this.type = type; + } + + public String name() { + return NameSanitizer.wireNameToField(wireName); + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/OperationRequest.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/OperationRequest.java new file mode 100644 index 0000000000..f668c68701 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/OperationRequest.java @@ -0,0 +1,37 @@ +package org.opensearch.client.codegen.model; + +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class OperationRequest { + public String operationId; + public String description; + public String httpMethod; + public String httpPath; + private Map bodyFields = new TreeMap<>(); + private Map queryParams = new TreeMap<>(); + private Map fields = new TreeMap<>(); + + public String className() { + return operationId + "Request"; + } + + public String responseType() { return operationId + "Response"; } + + public boolean hasRequestBody() { return !bodyFields.isEmpty(); } + + public Collection bodyFields() { return bodyFields.values(); } + public Collection queryParams() { return queryParams.values(); } + public Collection fields() { return fields.values(); } + + public void addBodyField(Field field) { + bodyFields.put(field.wireName, field); + fields.put(field.wireName, field); + } + + public void addQueryParam(Field field) { + queryParams.put(field.wireName, field); + fields.put(field.wireName, field); + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java new file mode 100644 index 0000000000..1e7efb8158 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java @@ -0,0 +1,212 @@ +package org.opensearch.client.codegen.model; + +import com.samskivert.mustache.Mustache; +import org.openapi4j.parser.model.v3.Schema; +import org.opensearch.client.codegen.utils.Schemas; + +import java.io.IOException; +import java.io.Writer; +import java.util.Arrays; +import java.util.Set; +import java.util.stream.Collectors; + +public class Type { + private static final Set PRIMITIVES = Set.of( + "String", + "boolean", "Boolean", + "char", "Character", + "byte", "Byte", + "short", "Short", + "int", "Integer", + "long", "Long", + "float", "Float", + "double", "Double" + ); + + private final Schema schema; + private final String name; + private final Type[] genericArgs; + + private Type(String name) { + this(null, name); + } + + public Type(Schema schema, String name) { + this.schema = schema; + this.name = name; + this.genericArgs = null; + } + + public Type(Schema schema, String name, String... genericArgs) { + this(schema, name, Arrays.stream(genericArgs).map(Type::new).toArray(Type[]::new)); + } + + public Type(Schema schema, String name, Type... genericArgs) { + this.schema = schema; + this.name = name; + this.genericArgs = genericArgs; + } + + @Override + public String toString() { + String str = name; + if (genericArgs != null && genericArgs.length > 0) { + str += "<"; + str += Arrays.stream(genericArgs) + .map(Type::toString) + .collect(Collectors.joining(", ")); + str += ">"; + } + return str; + } + + public Type boxed() { + switch (name) { + case "char": return new Type(schema, "Character"); + case "boolean": return new Type(schema, "Boolean"); + case "byte": return new Type(schema, "Byte"); + case "short": return new Type(schema, "Short"); + case "int": return new Type(schema, "Integer"); + case "long": return new Type(schema, "Long"); + case "float": return new Type(schema, "Float"); + case "double": return new Type(schema, "Double"); + default: return this; + } + } + + public boolean isMap() { return "Map".equals(name); } + + public Type mapEntryType() { + if (!isMap()) return null; + + return new Type(null, "Map.Entry", this.genericArgs); + } + + public Type mapKeyType() { + if (!isMap()) return null; + + return this.genericArgs[0]; + } + + public Type mapValueType() { + if (!isMap()) return null; + + return this.genericArgs[1]; + } + + public boolean isList() { return "List".equals(name); } + + public Type listValueType() { + if (!isList()) return null; + + return this.genericArgs[0]; + } + + public boolean isListOrMap() { return isList() || isMap(); } + + public boolean isPrimitive() { return PRIMITIVES.contains(name); } + + public boolean isBuiltIn() { return isListOrMap() || isPrimitive(); } + + public Type builderType() { + if (isBuiltIn()) return null; + + return new Type(name + ".Builder"); + } + + public Type builderFuncType() { + if (isBuiltIn()) return null; + + return new Type(null, "Function", builderType(), new Type(null, "ObjectBuilder", this)); + } + + public Mustache.Lambda isDefined() { + return (frag, out) -> { + String value = frag.execute(); + if (isListOrMap()) { + out.write("ApiTypeHelper.isDefined(" + value + ")"); + } else { + out.write(value + " != null"); + } + }; + } + + public Mustache.Lambda serializer() { + return (frag, out) -> serializer(frag.execute(), out, 0); + } + + private void serializer(String value, Writer out, int depth) throws IOException { + if (isMap()) { + String item = "item" + depth; + out.write("generator.writeStartObject();\n"); + out.write("for (" + mapEntryType() + " " + item + " : " + value + ".entrySet()) {\n"); + out.write(" generator.writeKey(" + item + ".getKey());\n"); + mapValueType().serializer(item + ".getValue()", out, depth + 1); + out.write("\n}\n"); + out.write("generator.writeEnd();"); + } else if (isList()) { + String item = "item" + depth; + out.write("generator.writeStartArray();\n"); + out.write("for (" + listValueType() + " " + item + " : " + value + ") {\n"); + listValueType().serializer(item, out, depth + 1); + out.write("\n}\n"); + out.write("generator.writeEnd();"); + } else if (isPrimitive()) { + out.write("generator.write(" + value + ");"); + } else { + out.write(value + ".serialize(generator, mapper);"); + } + } + + public String deserializer() { + switch (name) { + case "String": + return "JsonpDeserializer.stringDeserializer()"; + + case "boolean": + case "Boolean": + return "JsonpDeserializer.booleanDeserializer()"; + + case "int": + case "Integer": + return "JsonpDeserializer.integerDeserializer()"; + + case "long": + case "Long": + return "JsonpDeserializer.longDeserializer()"; + + case "float": + case "Float": + return "JsonpDeserializer.floatDeserializer()"; + + case "double": + case "Double": + return "JsonpDeserializer.doubleDeserializer()"; + + case "List": + return "JsonpDeserializer.arrayDeserializer(" + listValueType().deserializer() + ")"; + + case "Map": + return "JsonpDeserializer.stringMapDeserializer(" + mapValueType().deserializer() + ")"; + + default: + return name + "._DESERIALIZER"; + } + } + + public Mustache.Lambda queryParamify() { + return (frag, out) -> out.write(queryParamify(frag.execute())); + } + + public String queryParamify(String value) { + if (Schemas.isString(schema) || "String".equals(name)) { + return Schemas.hasEnums(schema) ? value + ".jsonValue()" : value; + } else if (isPrimitive()) { + return "String.valueOf(" + value + ")"; + } else if (isList()) { + return value + ".stream().map(v -> " + listValueType().queryParamify("v") + ").collect(Collectors.joining(\",\"))"; + } + + throw new UnsupportedOperationException("Don't know how to queryParamify " + value + " with type: " + this); + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Schemas.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Schemas.java new file mode 100644 index 0000000000..f551403972 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Schemas.java @@ -0,0 +1,15 @@ +package org.opensearch.client.codegen.utils; + +import org.openapi4j.core.model.v3.OAI3SchemaKeywords; +import org.openapi4j.parser.model.v3.Schema; + +public final class Schemas { + public static String getType(Schema schema) { return schema != null ? schema.getType() : null; } + public static boolean is(Schema schema, String type) { return type.equals(getType(schema)); } + + public static boolean isObject(Schema schema) { return is(schema, OAI3SchemaKeywords.TYPE_OBJECT); } + + public static boolean isString(Schema schema) { return is(schema, OAI3SchemaKeywords.TYPE_STRING); } + + public static boolean hasEnums(Schema schema) { return schema != null && schema.hasEnums(); } +} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache new file mode 100644 index 0000000000..789fda14ff --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache @@ -0,0 +1,160 @@ +package org.opensearch.client; + +import org.opensearch.client.opensearch._types.*; +{{#hasRequestBody}}import org.opensearch.client.json.*;{{/hasRequestBody}} +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +{{#hasRequestBody}}import jakarta.json.stream.JsonGenerator;{{/hasRequestBody}} +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +/** + * {{description}} + */ +{{#hasRequestBody}}@JsonpDeserializable{{/hasRequestBody}} +public class {{className}} extends RequestBase{{#hasRequestBody}} implements JsonpSerializable{{/hasRequestBody}} { + {{#fields}} + private final {{{type}}} {{name}}; + {{/fields}} + + public {{className}}(Builder builder) { + {{#fields}} + {{#type.isListOrMap}} + this.{{name}} = ApiTypeHelper.unmodifiable(builder.{{name}}); + {{/type.isListOrMap}} + {{^type.isListOrMap}} + this.{{name}} = builder.{{name}}; + {{/type.isListOrMap}} + {{/fields}} + } + + public static {{className}} of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + {{#fields}} + public final {{{type}}} {{name}}() { + return this.{{name}}; + } + + {{/fields}} + {{#hasRequestBody}} + public void serialize(JsonGenerator generator, JsonMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonMapper mapper) { + {{#bodyFields}} + if ({{#type.isDefined}}this.{{name}}{{/type.isDefined}}) { + generator.writeKey({{#dq}}{{wireName}}{{/dq}}); + {{#type.serializer}}this.{{name}}{{/type.serializer}} + } + + {{/bodyFields}} + } + {{/hasRequestBody}} + + /** + * Builder for {@link {{className}}}. + */ + public static class Builder extends ObjectBuilderBase implements ObjectBuilder<{{className}}> { + {{#fields}} + private {{{type}}} {{name}}; + {{/fields}} + + {{#fields}} + {{#type.isMap}} + public final Builder {{name}}({{{type}}} map) { + this.{{name}} = _mapPutAll(this.{{name}}, map); + return this; + } + + public final Builder {{name}}({{{type.mapKeyType}}} key, {{{type.mapValueType}}} value) { + this.{{name}} = _mapPut(this.{{name}}, key, value); + return this; + } + {{/type.isMap}} + {{#type.isList}} + public final Builder {{name}}({{{type}}} list) { + this.{{name}} = _listAddAll(this.{{name}}, list); + return this; + } + + public final Builder {{name}}({{{type.listValueType}}} value, {{{type.listValueType}}}... values) { + this.{{name}} = _listAdd(this.{{name}}, value, values); + return this; + } + {{^type.listValueType.isBuiltIn}} + + public final Builder {{name}}({{{type.listValueType.builderFuncType}}} fn) { + return {{name}}(fn.apply(new {{{type.listValueType.builderType}}}()).build()); + } + {{/type.listValueType.isBuiltIn}} + {{/type.isList}} + {{^type.isListOrMap}} + public final Builder {{name}}({{{type}}} value) { + this.{{name}} = value; + return this; + } + {{^type.isPrimitive}} + + public final Builder {{name}}({{{type.builderFuncType}}} fn) { + return {{name}}(fn.apply(new {{{type.builderType}}}()).build()); + } + {{/type.isPrimitive}} + {{/type.isListOrMap}} + + {{/fields}} + /** + * Builds a {@link {{className}}}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public {{className}} build() { + _checkSingleUse(); + + return new {{className}}(this); + } + } + + {{#hasRequestBody}} + public static final JsonpDeserializer<{{className}}> _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, {{className}}::setup{{className}}Deserializer); + + protected static void setup{{className}}Deserializer( + ObjectDeserializer<{{className}}.Builder> op) { + {{#bodyFields}} + op.add(Builder::{{name}}, {{{type.deserializer}}}, {{#dq}}{{wireName}}{{/dq}}); + {{/bodyFields}} + } + {{/hasRequestBody}} + + public static final Endpoint<{{className}}, {{responseType}}, ErrorResponse> _ENDPOINT = new SimpleEndpoint<>( + // Request method + request -> { + return {{#dq}}{{httpMethod}}{{/dq}}; + }, + // Request path + request -> { + return {{#dq}}{{httpPath}}{{/dq}}; + }, + // Request parameters + request -> { + Map params = new HashMap<>(); + {{#queryParams}} + if ({{#type.isDefined}}request.{{name}}{{/type.isDefined}}) { + params.put({{#dq}}{{wireName}}{{/dq}}, {{#type.queryParamify}}request.{{name}}{{/type.queryParamify}}); + } + {{/queryParams}} + return params; + }, + SimpleEndpoint.emptyMap(), + {{hasRequestBody}}, + {{responseType}}._DESERIALIZER + ); +} \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/version.properties b/java-codegen/src/main/resources/org/opensearch/client/codegen/version.properties new file mode 100644 index 0000000000..0ff7450868 --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/version.properties @@ -0,0 +1,10 @@ +# +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. +# + +version=${version} +git_revision=${git_revision} diff --git a/settings.gradle.kts b/settings.gradle.kts index 9c04316123..ae27c7cf6c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -36,4 +36,5 @@ plugins { rootProject.name = "opensearch-java" include("java-client") +include("java-codegen") include("samples") From f070ed10e9022e373359453c920d724a788a2e9d Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Tue, 14 Feb 2023 13:08:58 +1300 Subject: [PATCH 02/50] Write to files and generate object shapes Signed-off-by: Thomas Farr --- java-client/build.gradle.kts | 8 + .../opensearch/ActionObjectStructure.java | 124 + .../client/opensearch/DeleteIndexRequest.java | 154 + .../opensearch/GetCatIndicesRequest.java | 213 ++ .../GetCatIndicesWithIndexRequest.java | 214 ++ .../client/opensearch/GetCatNodesRequest.java | 179 ++ .../opensearch/GetClusterInfoRequest.java | 58 + .../opensearch/GetClusterSettingsRequest.java | 125 + .../opensearch/GetDocumentDocRequest.java | 215 ++ .../opensearch/GetDocumentSourceRequest.java | 215 ++ .../opensearch/GetSettingsIndexRequest.java | 193 ++ .../GetSettingsIndexSettingRequest.java | 194 ++ .../client/opensearch/PostAliasesRequest.java | 142 + .../PostRemoteStoreRestoreRequest.java | 142 + .../client/opensearch/PostSearchRequest.java | 934 ++++++ .../PostSearchWithIndexRequest.java | 954 ++++++ .../opensearch/PutCreateIndexRequest.java | 249 ++ .../PutIndexMappingWithIndexRequest.java | 236 ++ .../PutUpdateClusterSettingsRequest.java | 206 ++ .../UserDefinedObjectStructure.java | 1179 +++++++ .../opensearch/UserDefinedStructure.java | 277 ++ java-codegen/OpenSearch.openapi.json | 2844 +++++++++++++++++ java-codegen/build.gradle.kts | 23 +- .../client/codegen/ApiSpecification.java | 38 +- .../opensearch/client/codegen/Generator.java | 33 +- .../org/opensearch/client/codegen/Main.java | 12 +- .../opensearch/client/codegen/Renderer.java | 20 +- .../opensearch/client/codegen/TypeMapper.java | 17 +- .../client/codegen/model/ObjectShape.java | 22 + .../codegen/model/OperationRequest.java | 8 +- .../opensearch/client/codegen/model/Type.java | 2 +- .../codegen/templates/ObjectShape.mustache | 129 + .../templates/OperationRequest.mustache | 10 +- 33 files changed, 9335 insertions(+), 34 deletions(-) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/ActionObjectStructure.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesRequest.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesRequest.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoRequest.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsRequest.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesRequest.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreRequest.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchRequest.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsRequest.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedObjectStructure.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedStructure.java create mode 100644 java-codegen/OpenSearch.openapi.json create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache diff --git a/java-client/build.gradle.kts b/java-client/build.gradle.kts index cfd9ad3a9d..5b225c3214 100644 --- a/java-client/build.gradle.kts +++ b/java-client/build.gradle.kts @@ -87,6 +87,14 @@ java { } } +sourceSets { + main { + java { + srcDir("src/generated/java") + } + } +} + tasks.withType { expand( "version" to version, diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ActionObjectStructure.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ActionObjectStructure.java new file mode 100644 index 0000000000..d4d7603ea4 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ActionObjectStructure.java @@ -0,0 +1,124 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class ActionObjectStructure implements JsonpSerializable { + private final UserDefinedStructure add; + private final UserDefinedStructure remove; + private final UserDefinedStructure removeIndex; + + public ActionObjectStructure(Builder builder) { + this.add = builder.add; + this.remove = builder.remove; + this.removeIndex = builder.removeIndex; + } + + public static ActionObjectStructure of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final UserDefinedStructure add() { + return this.add; + } + + public final UserDefinedStructure remove() { + return this.remove; + } + + public final UserDefinedStructure removeIndex() { + return this.removeIndex; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.add != null) { + generator.writeKey("add"); + this.add.serialize(generator, mapper); + } + + if (this.remove != null) { + generator.writeKey("remove"); + this.remove.serialize(generator, mapper); + } + + if (this.removeIndex != null) { + generator.writeKey("remove_index"); + this.removeIndex.serialize(generator, mapper); + } + } + + /** Builder for {@link ActionObjectStructure}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private UserDefinedStructure add; + private UserDefinedStructure remove; + private UserDefinedStructure removeIndex; + + public final Builder add(UserDefinedStructure value) { + this.add = value; + return this; + } + + public final Builder add( + Function> fn) { + return add(fn.apply(new UserDefinedStructure.Builder()).build()); + } + + public final Builder remove(UserDefinedStructure value) { + this.remove = value; + return this; + } + + public final Builder remove( + Function> fn) { + return remove(fn.apply(new UserDefinedStructure.Builder()).build()); + } + + public final Builder removeIndex(UserDefinedStructure value) { + this.removeIndex = value; + return this; + } + + public final Builder removeIndex( + Function> fn) { + return removeIndex(fn.apply(new UserDefinedStructure.Builder()).build()); + } + + /** + * Builds a {@link ActionObjectStructure}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public ActionObjectStructure build() { + _checkSingleUse(); + + return new ActionObjectStructure(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, ActionObjectStructure::setupActionObjectStructureDeserializer); + + protected static void setupActionObjectStructureDeserializer( + ObjectDeserializer op) { + op.add(Builder::add, UserDefinedStructure._DESERIALIZER, "add"); + op.add(Builder::remove, UserDefinedStructure._DESERIALIZER, "remove"); + op.add(Builder::removeIndex, UserDefinedStructure._DESERIALIZER, "remove_index"); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java new file mode 100644 index 0000000000..8697ecf91f --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java @@ -0,0 +1,154 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; + +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; + +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +/** Removes a document from the index. */ +public class DeleteIndexRequest extends RequestBase { + private final boolean allowNoIndices; + private final String clusterManagerTimeout; + private final ExpandWildcards expandWildcards; + private final boolean ignoreUnavailable; + private final String masterTimeout; + private final String timeout; + + public DeleteIndexRequest(Builder builder) { + this.allowNoIndices = builder.allowNoIndices; + this.clusterManagerTimeout = builder.clusterManagerTimeout; + this.expandWildcards = builder.expandWildcards; + this.ignoreUnavailable = builder.ignoreUnavailable; + this.masterTimeout = builder.masterTimeout; + this.timeout = builder.timeout; + } + + public static DeleteIndexRequest of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final boolean allowNoIndices() { + return this.allowNoIndices; + } + + public final String clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + + public final ExpandWildcards expandWildcards() { + return this.expandWildcards; + } + + public final boolean ignoreUnavailable() { + return this.ignoreUnavailable; + } + + public final String masterTimeout() { + return this.masterTimeout; + } + + public final String timeout() { + return this.timeout; + } + + /** Builder for {@link DeleteIndexRequest}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private boolean allowNoIndices; + private String clusterManagerTimeout; + private ExpandWildcards expandWildcards; + private boolean ignoreUnavailable; + private String masterTimeout; + private String timeout; + + public final Builder allowNoIndices(boolean value) { + this.allowNoIndices = value; + return this; + } + + public final Builder clusterManagerTimeout(String value) { + this.clusterManagerTimeout = value; + return this; + } + + public final Builder expandWildcards(ExpandWildcards value) { + this.expandWildcards = value; + return this; + } + + public final Builder expandWildcards( + Function> fn) { + return expandWildcards(fn.apply(new ExpandWildcards.Builder()).build()); + } + + public final Builder ignoreUnavailable(boolean value) { + this.ignoreUnavailable = value; + return this; + } + + public final Builder masterTimeout(String value) { + this.masterTimeout = value; + return this; + } + + public final Builder timeout(String value) { + this.timeout = value; + return this; + } + + /** + * Builds a {@link DeleteIndexRequest}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public DeleteIndexRequest build() { + _checkSingleUse(); + + return new DeleteIndexRequest(this); + } + } + + public static final Endpoint _ENDPOINT = + new SimpleEndpoint<>( + // Request method + request -> { + return "delete"; + }, + // Request path + request -> { + return "/{index}"; + }, + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.allowNoIndices != null) { + params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); + } + if (request.clusterManagerTimeout != null) { + params.put("cluster_manager_timeout", request.clusterManagerTimeout); + } + if (request.expandWildcards != null) { + params.put("expand_wildcards", request.expandWildcards.jsonValue()); + } + if (request.ignoreUnavailable != null) { + params.put( + "ignore_unavailable", + String.valueOf(request.ignoreUnavailable)); + } + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout); + } + if (request.timeout != null) { + params.put("timeout", request.timeout); + } + return params; + }, + SimpleEndpoint.emptyMap(), + false, + DeleteIndexResponse._DESERIALIZER); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesRequest.java new file mode 100644 index 0000000000..1990a51ce4 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesRequest.java @@ -0,0 +1,213 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; + +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; + +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +/** + * Returns information about indices: number of primaries and replicas, document counts, disk size, + * etc. + */ +public class GetCatIndicesRequest extends RequestBase { + private final int bytes; + private final String clusterManagerTimeout; + private final ExpandWildcards expandWildcards; + private final String format; + private final HealthStatus health; + private final boolean includeUnloadedSegments; + private final String masterTimeout; + private final boolean pri; + private final String time; + + public GetCatIndicesRequest(Builder builder) { + this.bytes = builder.bytes; + this.clusterManagerTimeout = builder.clusterManagerTimeout; + this.expandWildcards = builder.expandWildcards; + this.format = builder.format; + this.health = builder.health; + this.includeUnloadedSegments = builder.includeUnloadedSegments; + this.masterTimeout = builder.masterTimeout; + this.pri = builder.pri; + this.time = builder.time; + } + + public static GetCatIndicesRequest of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final int bytes() { + return this.bytes; + } + + public final String clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + + public final ExpandWildcards expandWildcards() { + return this.expandWildcards; + } + + public final String format() { + return this.format; + } + + public final HealthStatus health() { + return this.health; + } + + public final boolean includeUnloadedSegments() { + return this.includeUnloadedSegments; + } + + public final String masterTimeout() { + return this.masterTimeout; + } + + public final boolean pri() { + return this.pri; + } + + public final String time() { + return this.time; + } + + /** Builder for {@link GetCatIndicesRequest}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private int bytes; + private String clusterManagerTimeout; + private ExpandWildcards expandWildcards; + private String format; + private HealthStatus health; + private boolean includeUnloadedSegments; + private String masterTimeout; + private boolean pri; + private String time; + + public final Builder bytes(int value) { + this.bytes = value; + return this; + } + + public final Builder clusterManagerTimeout(String value) { + this.clusterManagerTimeout = value; + return this; + } + + public final Builder expandWildcards(ExpandWildcards value) { + this.expandWildcards = value; + return this; + } + + public final Builder expandWildcards( + Function> fn) { + return expandWildcards(fn.apply(new ExpandWildcards.Builder()).build()); + } + + public final Builder format(String value) { + this.format = value; + return this; + } + + public final Builder health(HealthStatus value) { + this.health = value; + return this; + } + + public final Builder health( + Function> fn) { + return health(fn.apply(new HealthStatus.Builder()).build()); + } + + public final Builder includeUnloadedSegments(boolean value) { + this.includeUnloadedSegments = value; + return this; + } + + public final Builder masterTimeout(String value) { + this.masterTimeout = value; + return this; + } + + public final Builder pri(boolean value) { + this.pri = value; + return this; + } + + public final Builder time(String value) { + this.time = value; + return this; + } + + /** + * Builds a {@link GetCatIndicesRequest}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public GetCatIndicesRequest build() { + _checkSingleUse(); + + return new GetCatIndicesRequest(this); + } + } + + public static final Endpoint + _ENDPOINT = + new SimpleEndpoint<>( + // Request method + request -> { + return "get"; + }, + // Request path + request -> { + return "/_cat/indices"; + }, + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.bytes != null) { + params.put("bytes", String.valueOf(request.bytes)); + } + if (request.clusterManagerTimeout != null) { + params.put( + "cluster_manager_timeout", + request.clusterManagerTimeout); + } + if (request.expandWildcards != null) { + params.put( + "expand_wildcards", + request.expandWildcards.jsonValue()); + } + if (request.format != null) { + params.put("format", request.format); + } + if (request.health != null) { + params.put("health", request.health.jsonValue()); + } + if (request.includeUnloadedSegments != null) { + params.put( + "include_unloaded_segments", + String.valueOf(request.includeUnloadedSegments)); + } + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout); + } + if (request.pri != null) { + params.put("pri", String.valueOf(request.pri)); + } + if (request.time != null) { + params.put("time", request.time); + } + return params; + }, + SimpleEndpoint.emptyMap(), + false, + GetCatIndicesResponse._DESERIALIZER); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java new file mode 100644 index 0000000000..8386e1b321 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java @@ -0,0 +1,214 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; + +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; + +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +/** + * Returns information about indices: number of primaries and replicas, document counts, disk size, + * etc. + */ +public class GetCatIndicesWithIndexRequest extends RequestBase { + private final int bytes; + private final String clusterManagerTimeout; + private final ExpandWildcards expandWildcards; + private final String format; + private final HealthStatus health; + private final boolean includeUnloadedSegments; + private final String masterTimeout; + private final boolean pri; + private final String time; + + public GetCatIndicesWithIndexRequest(Builder builder) { + this.bytes = builder.bytes; + this.clusterManagerTimeout = builder.clusterManagerTimeout; + this.expandWildcards = builder.expandWildcards; + this.format = builder.format; + this.health = builder.health; + this.includeUnloadedSegments = builder.includeUnloadedSegments; + this.masterTimeout = builder.masterTimeout; + this.pri = builder.pri; + this.time = builder.time; + } + + public static GetCatIndicesWithIndexRequest of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final int bytes() { + return this.bytes; + } + + public final String clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + + public final ExpandWildcards expandWildcards() { + return this.expandWildcards; + } + + public final String format() { + return this.format; + } + + public final HealthStatus health() { + return this.health; + } + + public final boolean includeUnloadedSegments() { + return this.includeUnloadedSegments; + } + + public final String masterTimeout() { + return this.masterTimeout; + } + + public final boolean pri() { + return this.pri; + } + + public final String time() { + return this.time; + } + + /** Builder for {@link GetCatIndicesWithIndexRequest}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private int bytes; + private String clusterManagerTimeout; + private ExpandWildcards expandWildcards; + private String format; + private HealthStatus health; + private boolean includeUnloadedSegments; + private String masterTimeout; + private boolean pri; + private String time; + + public final Builder bytes(int value) { + this.bytes = value; + return this; + } + + public final Builder clusterManagerTimeout(String value) { + this.clusterManagerTimeout = value; + return this; + } + + public final Builder expandWildcards(ExpandWildcards value) { + this.expandWildcards = value; + return this; + } + + public final Builder expandWildcards( + Function> fn) { + return expandWildcards(fn.apply(new ExpandWildcards.Builder()).build()); + } + + public final Builder format(String value) { + this.format = value; + return this; + } + + public final Builder health(HealthStatus value) { + this.health = value; + return this; + } + + public final Builder health( + Function> fn) { + return health(fn.apply(new HealthStatus.Builder()).build()); + } + + public final Builder includeUnloadedSegments(boolean value) { + this.includeUnloadedSegments = value; + return this; + } + + public final Builder masterTimeout(String value) { + this.masterTimeout = value; + return this; + } + + public final Builder pri(boolean value) { + this.pri = value; + return this; + } + + public final Builder time(String value) { + this.time = value; + return this; + } + + /** + * Builds a {@link GetCatIndicesWithIndexRequest}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public GetCatIndicesWithIndexRequest build() { + _checkSingleUse(); + + return new GetCatIndicesWithIndexRequest(this); + } + } + + public static final Endpoint< + GetCatIndicesWithIndexRequest, GetCatIndicesWithIndexResponse, ErrorResponse> + _ENDPOINT = + new SimpleEndpoint<>( + // Request method + request -> { + return "get"; + }, + // Request path + request -> { + return "/_cat/indices/{index}"; + }, + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.bytes != null) { + params.put("bytes", String.valueOf(request.bytes)); + } + if (request.clusterManagerTimeout != null) { + params.put( + "cluster_manager_timeout", + request.clusterManagerTimeout); + } + if (request.expandWildcards != null) { + params.put( + "expand_wildcards", + request.expandWildcards.jsonValue()); + } + if (request.format != null) { + params.put("format", request.format); + } + if (request.health != null) { + params.put("health", request.health.jsonValue()); + } + if (request.includeUnloadedSegments != null) { + params.put( + "include_unloaded_segments", + String.valueOf(request.includeUnloadedSegments)); + } + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout); + } + if (request.pri != null) { + params.put("pri", String.valueOf(request.pri)); + } + if (request.time != null) { + params.put("time", request.time); + } + return params; + }, + SimpleEndpoint.emptyMap(), + false, + GetCatIndicesWithIndexResponse._DESERIALIZER); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesRequest.java new file mode 100644 index 0000000000..8342d8795a --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesRequest.java @@ -0,0 +1,179 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; + +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; + +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +/** Returns basic statistics about performance of cluster nodes. */ +public class GetCatNodesRequest extends RequestBase { + private final int bytes; + private final String clusterManagerTimeout; + private final String format; + private final boolean fullId; + private final boolean includeUnloadedSegments; + private final boolean local; + private final String masterTimeout; + private final String time; + + public GetCatNodesRequest(Builder builder) { + this.bytes = builder.bytes; + this.clusterManagerTimeout = builder.clusterManagerTimeout; + this.format = builder.format; + this.fullId = builder.fullId; + this.includeUnloadedSegments = builder.includeUnloadedSegments; + this.local = builder.local; + this.masterTimeout = builder.masterTimeout; + this.time = builder.time; + } + + public static GetCatNodesRequest of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final int bytes() { + return this.bytes; + } + + public final String clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + + public final String format() { + return this.format; + } + + public final boolean fullId() { + return this.fullId; + } + + public final boolean includeUnloadedSegments() { + return this.includeUnloadedSegments; + } + + public final boolean local() { + return this.local; + } + + public final String masterTimeout() { + return this.masterTimeout; + } + + public final String time() { + return this.time; + } + + /** Builder for {@link GetCatNodesRequest}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private int bytes; + private String clusterManagerTimeout; + private String format; + private boolean fullId; + private boolean includeUnloadedSegments; + private boolean local; + private String masterTimeout; + private String time; + + public final Builder bytes(int value) { + this.bytes = value; + return this; + } + + public final Builder clusterManagerTimeout(String value) { + this.clusterManagerTimeout = value; + return this; + } + + public final Builder format(String value) { + this.format = value; + return this; + } + + public final Builder fullId(boolean value) { + this.fullId = value; + return this; + } + + public final Builder includeUnloadedSegments(boolean value) { + this.includeUnloadedSegments = value; + return this; + } + + public final Builder local(boolean value) { + this.local = value; + return this; + } + + public final Builder masterTimeout(String value) { + this.masterTimeout = value; + return this; + } + + public final Builder time(String value) { + this.time = value; + return this; + } + + /** + * Builds a {@link GetCatNodesRequest}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public GetCatNodesRequest build() { + _checkSingleUse(); + + return new GetCatNodesRequest(this); + } + } + + public static final Endpoint _ENDPOINT = + new SimpleEndpoint<>( + // Request method + request -> { + return "get"; + }, + // Request path + request -> { + return "/_cat/nodes"; + }, + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.bytes != null) { + params.put("bytes", String.valueOf(request.bytes)); + } + if (request.clusterManagerTimeout != null) { + params.put("cluster_manager_timeout", request.clusterManagerTimeout); + } + if (request.format != null) { + params.put("format", request.format); + } + if (request.fullId != null) { + params.put("full_id", String.valueOf(request.fullId)); + } + if (request.includeUnloadedSegments != null) { + params.put( + "include_unloaded_segments", + String.valueOf(request.includeUnloadedSegments)); + } + if (request.local != null) { + params.put("local", String.valueOf(request.local)); + } + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout); + } + if (request.time != null) { + params.put("time", request.time); + } + return params; + }, + SimpleEndpoint.emptyMap(), + false, + GetCatNodesResponse._DESERIALIZER); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoRequest.java new file mode 100644 index 0000000000..def287e015 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoRequest.java @@ -0,0 +1,58 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; + +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; + +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +/** Returns whether the cluster is running. */ +public class GetClusterInfoRequest extends RequestBase { + + public GetClusterInfoRequest(Builder builder) {} + + public static GetClusterInfoRequest of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** Builder for {@link GetClusterInfoRequest}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + + /** + * Builds a {@link GetClusterInfoRequest}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public GetClusterInfoRequest build() { + _checkSingleUse(); + + return new GetClusterInfoRequest(this); + } + } + + public static final Endpoint + _ENDPOINT = + new SimpleEndpoint<>( + // Request method + request -> { + return "get"; + }, + // Request path + request -> { + return "/"; + }, + // Request parameters + request -> { + Map params = new HashMap<>(); + return params; + }, + SimpleEndpoint.emptyMap(), + false, + GetClusterInfoResponse._DESERIALIZER); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsRequest.java new file mode 100644 index 0000000000..d694742eec --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsRequest.java @@ -0,0 +1,125 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; + +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; + +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +/** Returns cluster settings. */ +public class GetClusterSettingsRequest extends RequestBase { + private final String clusterManagerTimeout; + private final boolean flatSettings; + private final boolean includeDefaults; + private final String masterTimeout; + + public GetClusterSettingsRequest(Builder builder) { + this.clusterManagerTimeout = builder.clusterManagerTimeout; + this.flatSettings = builder.flatSettings; + this.includeDefaults = builder.includeDefaults; + this.masterTimeout = builder.masterTimeout; + } + + public static GetClusterSettingsRequest of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final String clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + + public final boolean flatSettings() { + return this.flatSettings; + } + + public final boolean includeDefaults() { + return this.includeDefaults; + } + + public final String masterTimeout() { + return this.masterTimeout; + } + + /** Builder for {@link GetClusterSettingsRequest}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private String clusterManagerTimeout; + private boolean flatSettings; + private boolean includeDefaults; + private String masterTimeout; + + public final Builder clusterManagerTimeout(String value) { + this.clusterManagerTimeout = value; + return this; + } + + public final Builder flatSettings(boolean value) { + this.flatSettings = value; + return this; + } + + public final Builder includeDefaults(boolean value) { + this.includeDefaults = value; + return this; + } + + public final Builder masterTimeout(String value) { + this.masterTimeout = value; + return this; + } + + /** + * Builds a {@link GetClusterSettingsRequest}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public GetClusterSettingsRequest build() { + _checkSingleUse(); + + return new GetClusterSettingsRequest(this); + } + } + + public static final Endpoint< + GetClusterSettingsRequest, GetClusterSettingsResponse, ErrorResponse> + _ENDPOINT = + new SimpleEndpoint<>( + // Request method + request -> { + return "get"; + }, + // Request path + request -> { + return "/_cluster/settings"; + }, + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.clusterManagerTimeout != null) { + params.put( + "cluster_manager_timeout", + request.clusterManagerTimeout); + } + if (request.flatSettings != null) { + params.put( + "flat_settings", String.valueOf(request.flatSettings)); + } + if (request.includeDefaults != null) { + params.put( + "include_defaults", + String.valueOf(request.includeDefaults)); + } + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout); + } + return params; + }, + SimpleEndpoint.emptyMap(), + false, + GetClusterSettingsResponse._DESERIALIZER); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java new file mode 100644 index 0000000000..13484d34fe --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java @@ -0,0 +1,215 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; + +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; + +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +/** Returns a document */ +public class GetDocumentDocRequest extends RequestBase { + private final String source; + private final String sourceExcludes; + private final String sourceIncludes; + private final String preference; + private final boolean realtime; + private final boolean refresh; + private final String routing; + private final boolean storedFields; + private final int version; + private final VersionType versionType; + + public GetDocumentDocRequest(Builder builder) { + this.source = builder.source; + this.sourceExcludes = builder.sourceExcludes; + this.sourceIncludes = builder.sourceIncludes; + this.preference = builder.preference; + this.realtime = builder.realtime; + this.refresh = builder.refresh; + this.routing = builder.routing; + this.storedFields = builder.storedFields; + this.version = builder.version; + this.versionType = builder.versionType; + } + + public static GetDocumentDocRequest of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final String source() { + return this.source; + } + + public final String sourceExcludes() { + return this.sourceExcludes; + } + + public final String sourceIncludes() { + return this.sourceIncludes; + } + + public final String preference() { + return this.preference; + } + + public final boolean realtime() { + return this.realtime; + } + + public final boolean refresh() { + return this.refresh; + } + + public final String routing() { + return this.routing; + } + + public final boolean storedFields() { + return this.storedFields; + } + + public final int version() { + return this.version; + } + + public final VersionType versionType() { + return this.versionType; + } + + /** Builder for {@link GetDocumentDocRequest}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private String source; + private String sourceExcludes; + private String sourceIncludes; + private String preference; + private boolean realtime; + private boolean refresh; + private String routing; + private boolean storedFields; + private int version; + private VersionType versionType; + + public final Builder source(String value) { + this.source = value; + return this; + } + + public final Builder sourceExcludes(String value) { + this.sourceExcludes = value; + return this; + } + + public final Builder sourceIncludes(String value) { + this.sourceIncludes = value; + return this; + } + + public final Builder preference(String value) { + this.preference = value; + return this; + } + + public final Builder realtime(boolean value) { + this.realtime = value; + return this; + } + + public final Builder refresh(boolean value) { + this.refresh = value; + return this; + } + + public final Builder routing(String value) { + this.routing = value; + return this; + } + + public final Builder storedFields(boolean value) { + this.storedFields = value; + return this; + } + + public final Builder version(int value) { + this.version = value; + return this; + } + + public final Builder versionType(VersionType value) { + this.versionType = value; + return this; + } + + public final Builder versionType( + Function> fn) { + return versionType(fn.apply(new VersionType.Builder()).build()); + } + + /** + * Builds a {@link GetDocumentDocRequest}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public GetDocumentDocRequest build() { + _checkSingleUse(); + + return new GetDocumentDocRequest(this); + } + } + + public static final Endpoint + _ENDPOINT = + new SimpleEndpoint<>( + // Request method + request -> { + return "get"; + }, + // Request path + request -> { + return "/{index}/_doc/{id}"; + }, + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.source != null) { + params.put("_source", request.source); + } + if (request.sourceExcludes != null) { + params.put("_source_excludes", request.sourceExcludes); + } + if (request.sourceIncludes != null) { + params.put("_source_includes", request.sourceIncludes); + } + if (request.preference != null) { + params.put("preference", request.preference); + } + if (request.realtime != null) { + params.put("realtime", String.valueOf(request.realtime)); + } + if (request.refresh != null) { + params.put("refresh", String.valueOf(request.refresh)); + } + if (request.routing != null) { + params.put("routing", request.routing); + } + if (request.storedFields != null) { + params.put( + "stored_fields", String.valueOf(request.storedFields)); + } + if (request.version != null) { + params.put("version", String.valueOf(request.version)); + } + if (request.versionType != null) { + params.put("version_type", request.versionType.jsonValue()); + } + return params; + }, + SimpleEndpoint.emptyMap(), + false, + GetDocumentDocResponse._DESERIALIZER); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java new file mode 100644 index 0000000000..cadb33117f --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java @@ -0,0 +1,215 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; + +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; + +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +/** Returns a document. */ +public class GetDocumentSourceRequest extends RequestBase { + private final String source; + private final String sourceExcludes; + private final String sourceIncludes; + private final String preference; + private final boolean realtime; + private final boolean refresh; + private final String routing; + private final boolean storedFields; + private final int version; + private final VersionType versionType; + + public GetDocumentSourceRequest(Builder builder) { + this.source = builder.source; + this.sourceExcludes = builder.sourceExcludes; + this.sourceIncludes = builder.sourceIncludes; + this.preference = builder.preference; + this.realtime = builder.realtime; + this.refresh = builder.refresh; + this.routing = builder.routing; + this.storedFields = builder.storedFields; + this.version = builder.version; + this.versionType = builder.versionType; + } + + public static GetDocumentSourceRequest of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final String source() { + return this.source; + } + + public final String sourceExcludes() { + return this.sourceExcludes; + } + + public final String sourceIncludes() { + return this.sourceIncludes; + } + + public final String preference() { + return this.preference; + } + + public final boolean realtime() { + return this.realtime; + } + + public final boolean refresh() { + return this.refresh; + } + + public final String routing() { + return this.routing; + } + + public final boolean storedFields() { + return this.storedFields; + } + + public final int version() { + return this.version; + } + + public final VersionType versionType() { + return this.versionType; + } + + /** Builder for {@link GetDocumentSourceRequest}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private String source; + private String sourceExcludes; + private String sourceIncludes; + private String preference; + private boolean realtime; + private boolean refresh; + private String routing; + private boolean storedFields; + private int version; + private VersionType versionType; + + public final Builder source(String value) { + this.source = value; + return this; + } + + public final Builder sourceExcludes(String value) { + this.sourceExcludes = value; + return this; + } + + public final Builder sourceIncludes(String value) { + this.sourceIncludes = value; + return this; + } + + public final Builder preference(String value) { + this.preference = value; + return this; + } + + public final Builder realtime(boolean value) { + this.realtime = value; + return this; + } + + public final Builder refresh(boolean value) { + this.refresh = value; + return this; + } + + public final Builder routing(String value) { + this.routing = value; + return this; + } + + public final Builder storedFields(boolean value) { + this.storedFields = value; + return this; + } + + public final Builder version(int value) { + this.version = value; + return this; + } + + public final Builder versionType(VersionType value) { + this.versionType = value; + return this; + } + + public final Builder versionType( + Function> fn) { + return versionType(fn.apply(new VersionType.Builder()).build()); + } + + /** + * Builds a {@link GetDocumentSourceRequest}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public GetDocumentSourceRequest build() { + _checkSingleUse(); + + return new GetDocumentSourceRequest(this); + } + } + + public static final Endpoint + _ENDPOINT = + new SimpleEndpoint<>( + // Request method + request -> { + return "get"; + }, + // Request path + request -> { + return "/{index}/_source/{id}"; + }, + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.source != null) { + params.put("_source", request.source); + } + if (request.sourceExcludes != null) { + params.put("_source_excludes", request.sourceExcludes); + } + if (request.sourceIncludes != null) { + params.put("_source_includes", request.sourceIncludes); + } + if (request.preference != null) { + params.put("preference", request.preference); + } + if (request.realtime != null) { + params.put("realtime", String.valueOf(request.realtime)); + } + if (request.refresh != null) { + params.put("refresh", String.valueOf(request.refresh)); + } + if (request.routing != null) { + params.put("routing", request.routing); + } + if (request.storedFields != null) { + params.put( + "stored_fields", String.valueOf(request.storedFields)); + } + if (request.version != null) { + params.put("version", String.valueOf(request.version)); + } + if (request.versionType != null) { + params.put("version_type", request.versionType.jsonValue()); + } + return params; + }, + SimpleEndpoint.emptyMap(), + false, + GetDocumentSourceResponse._DESERIALIZER); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java new file mode 100644 index 0000000000..8534b7250a --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java @@ -0,0 +1,193 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; + +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; + +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +/** The get settings API operation returns all the settings in your index. */ +public class GetSettingsIndexRequest extends RequestBase { + private final boolean allowNoIndices; + private final String clusterManagerTimeout; + private final ExpandWildcards expandWildcards; + private final boolean flatSettings; + private final boolean ignoreUnavailable; + private final String includeDefaults; + private final boolean local; + private final String masterTimeout; + + public GetSettingsIndexRequest(Builder builder) { + this.allowNoIndices = builder.allowNoIndices; + this.clusterManagerTimeout = builder.clusterManagerTimeout; + this.expandWildcards = builder.expandWildcards; + this.flatSettings = builder.flatSettings; + this.ignoreUnavailable = builder.ignoreUnavailable; + this.includeDefaults = builder.includeDefaults; + this.local = builder.local; + this.masterTimeout = builder.masterTimeout; + } + + public static GetSettingsIndexRequest of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final boolean allowNoIndices() { + return this.allowNoIndices; + } + + public final String clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + + public final ExpandWildcards expandWildcards() { + return this.expandWildcards; + } + + public final boolean flatSettings() { + return this.flatSettings; + } + + public final boolean ignoreUnavailable() { + return this.ignoreUnavailable; + } + + public final String includeDefaults() { + return this.includeDefaults; + } + + public final boolean local() { + return this.local; + } + + public final String masterTimeout() { + return this.masterTimeout; + } + + /** Builder for {@link GetSettingsIndexRequest}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private boolean allowNoIndices; + private String clusterManagerTimeout; + private ExpandWildcards expandWildcards; + private boolean flatSettings; + private boolean ignoreUnavailable; + private String includeDefaults; + private boolean local; + private String masterTimeout; + + public final Builder allowNoIndices(boolean value) { + this.allowNoIndices = value; + return this; + } + + public final Builder clusterManagerTimeout(String value) { + this.clusterManagerTimeout = value; + return this; + } + + public final Builder expandWildcards(ExpandWildcards value) { + this.expandWildcards = value; + return this; + } + + public final Builder expandWildcards( + Function> fn) { + return expandWildcards(fn.apply(new ExpandWildcards.Builder()).build()); + } + + public final Builder flatSettings(boolean value) { + this.flatSettings = value; + return this; + } + + public final Builder ignoreUnavailable(boolean value) { + this.ignoreUnavailable = value; + return this; + } + + public final Builder includeDefaults(String value) { + this.includeDefaults = value; + return this; + } + + public final Builder local(boolean value) { + this.local = value; + return this; + } + + public final Builder masterTimeout(String value) { + this.masterTimeout = value; + return this; + } + + /** + * Builds a {@link GetSettingsIndexRequest}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public GetSettingsIndexRequest build() { + _checkSingleUse(); + + return new GetSettingsIndexRequest(this); + } + } + + public static final Endpoint + _ENDPOINT = + new SimpleEndpoint<>( + // Request method + request -> { + return "get"; + }, + // Request path + request -> { + return "/{index}/_settings"; + }, + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.allowNoIndices != null) { + params.put( + "allow_no_indices", + String.valueOf(request.allowNoIndices)); + } + if (request.clusterManagerTimeout != null) { + params.put( + "cluster_manager_timeout", + request.clusterManagerTimeout); + } + if (request.expandWildcards != null) { + params.put( + "expand_wildcards", + request.expandWildcards.jsonValue()); + } + if (request.flatSettings != null) { + params.put( + "flat_settings", String.valueOf(request.flatSettings)); + } + if (request.ignoreUnavailable != null) { + params.put( + "ignore_unavailable", + String.valueOf(request.ignoreUnavailable)); + } + if (request.includeDefaults != null) { + params.put("include_defaults", request.includeDefaults); + } + if (request.local != null) { + params.put("local", String.valueOf(request.local)); + } + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout); + } + return params; + }, + SimpleEndpoint.emptyMap(), + false, + GetSettingsIndexResponse._DESERIALIZER); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java new file mode 100644 index 0000000000..87d34dab93 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java @@ -0,0 +1,194 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; + +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; + +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +/** The get settings API operation returns all the settings in your index. */ +public class GetSettingsIndexSettingRequest extends RequestBase { + private final boolean allowNoIndices; + private final String clusterManagerTimeout; + private final ExpandWildcards expandWildcards; + private final boolean flatSettings; + private final boolean ignoreUnavailable; + private final String includeDefaults; + private final boolean local; + private final String masterTimeout; + + public GetSettingsIndexSettingRequest(Builder builder) { + this.allowNoIndices = builder.allowNoIndices; + this.clusterManagerTimeout = builder.clusterManagerTimeout; + this.expandWildcards = builder.expandWildcards; + this.flatSettings = builder.flatSettings; + this.ignoreUnavailable = builder.ignoreUnavailable; + this.includeDefaults = builder.includeDefaults; + this.local = builder.local; + this.masterTimeout = builder.masterTimeout; + } + + public static GetSettingsIndexSettingRequest of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final boolean allowNoIndices() { + return this.allowNoIndices; + } + + public final String clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + + public final ExpandWildcards expandWildcards() { + return this.expandWildcards; + } + + public final boolean flatSettings() { + return this.flatSettings; + } + + public final boolean ignoreUnavailable() { + return this.ignoreUnavailable; + } + + public final String includeDefaults() { + return this.includeDefaults; + } + + public final boolean local() { + return this.local; + } + + public final String masterTimeout() { + return this.masterTimeout; + } + + /** Builder for {@link GetSettingsIndexSettingRequest}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private boolean allowNoIndices; + private String clusterManagerTimeout; + private ExpandWildcards expandWildcards; + private boolean flatSettings; + private boolean ignoreUnavailable; + private String includeDefaults; + private boolean local; + private String masterTimeout; + + public final Builder allowNoIndices(boolean value) { + this.allowNoIndices = value; + return this; + } + + public final Builder clusterManagerTimeout(String value) { + this.clusterManagerTimeout = value; + return this; + } + + public final Builder expandWildcards(ExpandWildcards value) { + this.expandWildcards = value; + return this; + } + + public final Builder expandWildcards( + Function> fn) { + return expandWildcards(fn.apply(new ExpandWildcards.Builder()).build()); + } + + public final Builder flatSettings(boolean value) { + this.flatSettings = value; + return this; + } + + public final Builder ignoreUnavailable(boolean value) { + this.ignoreUnavailable = value; + return this; + } + + public final Builder includeDefaults(String value) { + this.includeDefaults = value; + return this; + } + + public final Builder local(boolean value) { + this.local = value; + return this; + } + + public final Builder masterTimeout(String value) { + this.masterTimeout = value; + return this; + } + + /** + * Builds a {@link GetSettingsIndexSettingRequest}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public GetSettingsIndexSettingRequest build() { + _checkSingleUse(); + + return new GetSettingsIndexSettingRequest(this); + } + } + + public static final Endpoint< + GetSettingsIndexSettingRequest, GetSettingsIndexSettingResponse, ErrorResponse> + _ENDPOINT = + new SimpleEndpoint<>( + // Request method + request -> { + return "get"; + }, + // Request path + request -> { + return "/{index}/_settings/{setting}"; + }, + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.allowNoIndices != null) { + params.put( + "allow_no_indices", + String.valueOf(request.allowNoIndices)); + } + if (request.clusterManagerTimeout != null) { + params.put( + "cluster_manager_timeout", + request.clusterManagerTimeout); + } + if (request.expandWildcards != null) { + params.put( + "expand_wildcards", + request.expandWildcards.jsonValue()); + } + if (request.flatSettings != null) { + params.put( + "flat_settings", String.valueOf(request.flatSettings)); + } + if (request.ignoreUnavailable != null) { + params.put( + "ignore_unavailable", + String.valueOf(request.ignoreUnavailable)); + } + if (request.includeDefaults != null) { + params.put("include_defaults", request.includeDefaults); + } + if (request.local != null) { + params.put("local", String.valueOf(request.local)); + } + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout); + } + return params; + }, + SimpleEndpoint.emptyMap(), + false, + GetSettingsIndexSettingResponse._DESERIALIZER); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesRequest.java new file mode 100644 index 0000000000..7f92d4c003 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesRequest.java @@ -0,0 +1,142 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +/** Adds or removes index aliases. */ +@JsonpDeserializable +public class PostAliasesRequest extends RequestBase implements JsonpSerializable { + private final ActionObjectStructure actions; + private final String clusterManagerTimeout; + private final String masterTimeout; + private final String timeout; + + public PostAliasesRequest(Builder builder) { + this.actions = builder.actions; + this.clusterManagerTimeout = builder.clusterManagerTimeout; + this.masterTimeout = builder.masterTimeout; + this.timeout = builder.timeout; + } + + public static PostAliasesRequest of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final ActionObjectStructure actions() { + return this.actions; + } + + public final String clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + + public final String masterTimeout() { + return this.masterTimeout; + } + + public final String timeout() { + return this.timeout; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.actions != null) { + generator.writeKey("actions"); + this.actions.serialize(generator, mapper); + } + } + + /** Builder for {@link PostAliasesRequest}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private ActionObjectStructure actions; + private String clusterManagerTimeout; + private String masterTimeout; + private String timeout; + + public final Builder actions(ActionObjectStructure value) { + this.actions = value; + return this; + } + + public final Builder actions( + Function> fn) { + return actions(fn.apply(new ActionObjectStructure.Builder()).build()); + } + + public final Builder clusterManagerTimeout(String value) { + this.clusterManagerTimeout = value; + return this; + } + + public final Builder masterTimeout(String value) { + this.masterTimeout = value; + return this; + } + + public final Builder timeout(String value) { + this.timeout = value; + return this; + } + + /** + * Builds a {@link PostAliasesRequest}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public PostAliasesRequest build() { + _checkSingleUse(); + + return new PostAliasesRequest(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, PostAliasesRequest::setupPostAliasesRequestDeserializer); + + protected static void setupPostAliasesRequestDeserializer( + ObjectDeserializer op) { + op.add(Builder::actions, ActionObjectStructure._DESERIALIZER, "actions"); + } + + public static final Endpoint _ENDPOINT = + new SimpleEndpoint<>( + // Request method + request -> { + return "post"; + }, + // Request path + request -> { + return "/_aliases"; + }, + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.clusterManagerTimeout != null) { + params.put("cluster_manager_timeout", request.clusterManagerTimeout); + } + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout); + } + if (request.timeout != null) { + params.put("timeout", request.timeout); + } + return params; + }, + SimpleEndpoint.emptyMap(), + true, + PostAliasesResponse._DESERIALIZER); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreRequest.java new file mode 100644 index 0000000000..09dc536214 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreRequest.java @@ -0,0 +1,142 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +/** Restore one or more indices from a remote backup. */ +@JsonpDeserializable +public class PostRemoteStoreRestoreRequest extends RequestBase implements JsonpSerializable { + private final String clusterManagerTimeout; + private final List indices; + private final boolean waitForCompletion; + + public PostRemoteStoreRestoreRequest(Builder builder) { + this.clusterManagerTimeout = builder.clusterManagerTimeout; + this.indices = ApiTypeHelper.unmodifiable(builder.indices); + this.waitForCompletion = builder.waitForCompletion; + } + + public static PostRemoteStoreRestoreRequest of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final String clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + + public final List indices() { + return this.indices; + } + + public final boolean waitForCompletion() { + return this.waitForCompletion; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (ApiTypeHelper.isDefined(this.indices)) { + generator.writeKey("indices"); + generator.writeStartArray(); + for (String item0 : this.indices) { + generator.write(item0); + } + generator.writeEnd(); + } + } + + /** Builder for {@link PostRemoteStoreRestoreRequest}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private String clusterManagerTimeout; + private List indices; + private boolean waitForCompletion; + + public final Builder clusterManagerTimeout(String value) { + this.clusterManagerTimeout = value; + return this; + } + + public final Builder indices(List list) { + this.indices = _listAddAll(this.indices, list); + return this; + } + + public final Builder indices(String value, String... values) { + this.indices = _listAdd(this.indices, value, values); + return this; + } + + public final Builder waitForCompletion(boolean value) { + this.waitForCompletion = value; + return this; + } + + /** + * Builds a {@link PostRemoteStoreRestoreRequest}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public PostRemoteStoreRestoreRequest build() { + _checkSingleUse(); + + return new PostRemoteStoreRestoreRequest(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, + PostRemoteStoreRestoreRequest::setupPostRemoteStoreRestoreRequestDeserializer); + + protected static void setupPostRemoteStoreRestoreRequestDeserializer( + ObjectDeserializer op) { + op.add( + Builder::indices, + JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), + "indices"); + } + + public static final Endpoint< + PostRemoteStoreRestoreRequest, PostRemoteStoreRestoreResponse, ErrorResponse> + _ENDPOINT = + new SimpleEndpoint<>( + // Request method + request -> { + return "post"; + }, + // Request path + request -> { + return "/_remotestore/_restore"; + }, + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.clusterManagerTimeout != null) { + params.put( + "cluster_manager_timeout", + request.clusterManagerTimeout); + } + if (request.waitForCompletion != null) { + params.put( + "wait_for_completion", + String.valueOf(request.waitForCompletion)); + } + return params; + }, + SimpleEndpoint.emptyMap(), + true, + PostRemoteStoreRestoreResponse._DESERIALIZER); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchRequest.java new file mode 100644 index 0000000000..61ff931723 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchRequest.java @@ -0,0 +1,934 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +/** Returns results matching a query. */ +@JsonpDeserializable +public class PostSearchRequest extends RequestBase implements JsonpSerializable { + private final boolean allowNoIndices; + private final boolean allowPartialSearchResults; + private final boolean analyzeWildcard; + private final String analyzer; + private final int batchedReduceSize; + private final boolean ccsMinimizeRoundtrips; + private final DefaultOperator defaultOperator; + private final String df; + private final String docvalueFields; + private final ExpandWildcards expandWildcards; + private final boolean explain; + private final List fields; + private final int from; + private final boolean ignoreThrottled; + private final boolean ignoreUnavailable; + private final List indicesBoost; + private final boolean lenient; + private final long maxConcurrentShardRequests; + private final int minScore; + private final long preFilterShardSize; + private final String preference; + private final String q; + private final UserDefinedObjectStructure query; + private final boolean requestCache; + private final boolean restTotalHitsAsInt; + private final String routing; + private final String scroll; + private final SearchType searchType; + private final boolean seqNoPrimaryTerm; + private final int size; + private final List sort; + private final String source; + private final List sourceExcludes; + private final List sourceIncludes; + private final String stats; + private final boolean storedFields; + private final String suggestField; + private final SuggestMode suggestMode; + private final long suggestSize; + private final String suggestText; + private final int terminateAfter; + private final String timeout; + private final boolean trackScores; + private final int trackTotalHits; + private final boolean typedKeys; + private final boolean version; + + public PostSearchRequest(Builder builder) { + this.allowNoIndices = builder.allowNoIndices; + this.allowPartialSearchResults = builder.allowPartialSearchResults; + this.analyzeWildcard = builder.analyzeWildcard; + this.analyzer = builder.analyzer; + this.batchedReduceSize = builder.batchedReduceSize; + this.ccsMinimizeRoundtrips = builder.ccsMinimizeRoundtrips; + this.defaultOperator = builder.defaultOperator; + this.df = builder.df; + this.docvalueFields = builder.docvalueFields; + this.expandWildcards = builder.expandWildcards; + this.explain = builder.explain; + this.fields = ApiTypeHelper.unmodifiable(builder.fields); + this.from = builder.from; + this.ignoreThrottled = builder.ignoreThrottled; + this.ignoreUnavailable = builder.ignoreUnavailable; + this.indicesBoost = ApiTypeHelper.unmodifiable(builder.indicesBoost); + this.lenient = builder.lenient; + this.maxConcurrentShardRequests = builder.maxConcurrentShardRequests; + this.minScore = builder.minScore; + this.preFilterShardSize = builder.preFilterShardSize; + this.preference = builder.preference; + this.q = builder.q; + this.query = builder.query; + this.requestCache = builder.requestCache; + this.restTotalHitsAsInt = builder.restTotalHitsAsInt; + this.routing = builder.routing; + this.scroll = builder.scroll; + this.searchType = builder.searchType; + this.seqNoPrimaryTerm = builder.seqNoPrimaryTerm; + this.size = builder.size; + this.sort = ApiTypeHelper.unmodifiable(builder.sort); + this.source = builder.source; + this.sourceExcludes = ApiTypeHelper.unmodifiable(builder.sourceExcludes); + this.sourceIncludes = ApiTypeHelper.unmodifiable(builder.sourceIncludes); + this.stats = builder.stats; + this.storedFields = builder.storedFields; + this.suggestField = builder.suggestField; + this.suggestMode = builder.suggestMode; + this.suggestSize = builder.suggestSize; + this.suggestText = builder.suggestText; + this.terminateAfter = builder.terminateAfter; + this.timeout = builder.timeout; + this.trackScores = builder.trackScores; + this.trackTotalHits = builder.trackTotalHits; + this.typedKeys = builder.typedKeys; + this.version = builder.version; + } + + public static PostSearchRequest of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final boolean allowNoIndices() { + return this.allowNoIndices; + } + + public final boolean allowPartialSearchResults() { + return this.allowPartialSearchResults; + } + + public final boolean analyzeWildcard() { + return this.analyzeWildcard; + } + + public final String analyzer() { + return this.analyzer; + } + + public final int batchedReduceSize() { + return this.batchedReduceSize; + } + + public final boolean ccsMinimizeRoundtrips() { + return this.ccsMinimizeRoundtrips; + } + + public final DefaultOperator defaultOperator() { + return this.defaultOperator; + } + + public final String df() { + return this.df; + } + + public final String docvalueFields() { + return this.docvalueFields; + } + + public final ExpandWildcards expandWildcards() { + return this.expandWildcards; + } + + public final boolean explain() { + return this.explain; + } + + public final List fields() { + return this.fields; + } + + public final int from() { + return this.from; + } + + public final boolean ignoreThrottled() { + return this.ignoreThrottled; + } + + public final boolean ignoreUnavailable() { + return this.ignoreUnavailable; + } + + public final List indicesBoost() { + return this.indicesBoost; + } + + public final boolean lenient() { + return this.lenient; + } + + public final long maxConcurrentShardRequests() { + return this.maxConcurrentShardRequests; + } + + public final int minScore() { + return this.minScore; + } + + public final long preFilterShardSize() { + return this.preFilterShardSize; + } + + public final String preference() { + return this.preference; + } + + public final String q() { + return this.q; + } + + public final UserDefinedObjectStructure query() { + return this.query; + } + + public final boolean requestCache() { + return this.requestCache; + } + + public final boolean restTotalHitsAsInt() { + return this.restTotalHitsAsInt; + } + + public final String routing() { + return this.routing; + } + + public final String scroll() { + return this.scroll; + } + + public final SearchType searchType() { + return this.searchType; + } + + public final boolean seqNoPrimaryTerm() { + return this.seqNoPrimaryTerm; + } + + public final int size() { + return this.size; + } + + public final List sort() { + return this.sort; + } + + public final String source() { + return this.source; + } + + public final List sourceExcludes() { + return this.sourceExcludes; + } + + public final List sourceIncludes() { + return this.sourceIncludes; + } + + public final String stats() { + return this.stats; + } + + public final boolean storedFields() { + return this.storedFields; + } + + public final String suggestField() { + return this.suggestField; + } + + public final SuggestMode suggestMode() { + return this.suggestMode; + } + + public final long suggestSize() { + return this.suggestSize; + } + + public final String suggestText() { + return this.suggestText; + } + + public final int terminateAfter() { + return this.terminateAfter; + } + + public final String timeout() { + return this.timeout; + } + + public final boolean trackScores() { + return this.trackScores; + } + + public final int trackTotalHits() { + return this.trackTotalHits; + } + + public final boolean typedKeys() { + return this.typedKeys; + } + + public final boolean version() { + return this.version; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.docvalueFields != null) { + generator.writeKey("docvalue_fields"); + generator.write(this.docvalueFields); + } + + if (this.explain != null) { + generator.writeKey("explain"); + generator.write(this.explain); + } + + if (ApiTypeHelper.isDefined(this.fields)) { + generator.writeKey("fields"); + generator.writeStartArray(); + for (String item0 : this.fields) { + generator.write(item0); + } + generator.writeEnd(); + } + + if (this.from != null) { + generator.writeKey("from"); + generator.write(this.from); + } + + if (ApiTypeHelper.isDefined(this.indicesBoost)) { + generator.writeKey("indices_boost"); + generator.writeStartArray(); + for (JsonData item0 : this.indicesBoost) { + item0.serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (this.minScore != null) { + generator.writeKey("min_score"); + generator.write(this.minScore); + } + + if (this.query != null) { + generator.writeKey("query"); + this.query.serialize(generator, mapper); + } + + if (this.seqNoPrimaryTerm != null) { + generator.writeKey("seq_no_primary_term"); + generator.write(this.seqNoPrimaryTerm); + } + + if (this.size != null) { + generator.writeKey("size"); + generator.write(this.size); + } + + if (this.source != null) { + generator.writeKey("source"); + generator.write(this.source); + } + + if (this.stats != null) { + generator.writeKey("stats"); + generator.write(this.stats); + } + + if (this.terminateAfter != null) { + generator.writeKey("terminate_after"); + generator.write(this.terminateAfter); + } + + if (this.timeout != null) { + generator.writeKey("timeout"); + generator.write(this.timeout); + } + + if (this.version != null) { + generator.writeKey("version"); + generator.write(this.version); + } + } + + /** Builder for {@link PostSearchRequest}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private boolean allowNoIndices; + private boolean allowPartialSearchResults; + private boolean analyzeWildcard; + private String analyzer; + private int batchedReduceSize; + private boolean ccsMinimizeRoundtrips; + private DefaultOperator defaultOperator; + private String df; + private String docvalueFields; + private ExpandWildcards expandWildcards; + private boolean explain; + private List fields; + private int from; + private boolean ignoreThrottled; + private boolean ignoreUnavailable; + private List indicesBoost; + private boolean lenient; + private long maxConcurrentShardRequests; + private int minScore; + private long preFilterShardSize; + private String preference; + private String q; + private UserDefinedObjectStructure query; + private boolean requestCache; + private boolean restTotalHitsAsInt; + private String routing; + private String scroll; + private SearchType searchType; + private boolean seqNoPrimaryTerm; + private int size; + private List sort; + private String source; + private List sourceExcludes; + private List sourceIncludes; + private String stats; + private boolean storedFields; + private String suggestField; + private SuggestMode suggestMode; + private long suggestSize; + private String suggestText; + private int terminateAfter; + private String timeout; + private boolean trackScores; + private int trackTotalHits; + private boolean typedKeys; + private boolean version; + + public final Builder allowNoIndices(boolean value) { + this.allowNoIndices = value; + return this; + } + + public final Builder allowPartialSearchResults(boolean value) { + this.allowPartialSearchResults = value; + return this; + } + + public final Builder analyzeWildcard(boolean value) { + this.analyzeWildcard = value; + return this; + } + + public final Builder analyzer(String value) { + this.analyzer = value; + return this; + } + + public final Builder batchedReduceSize(int value) { + this.batchedReduceSize = value; + return this; + } + + public final Builder ccsMinimizeRoundtrips(boolean value) { + this.ccsMinimizeRoundtrips = value; + return this; + } + + public final Builder defaultOperator(DefaultOperator value) { + this.defaultOperator = value; + return this; + } + + public final Builder defaultOperator( + Function> fn) { + return defaultOperator(fn.apply(new DefaultOperator.Builder()).build()); + } + + public final Builder df(String value) { + this.df = value; + return this; + } + + public final Builder docvalueFields(String value) { + this.docvalueFields = value; + return this; + } + + public final Builder expandWildcards(ExpandWildcards value) { + this.expandWildcards = value; + return this; + } + + public final Builder expandWildcards( + Function> fn) { + return expandWildcards(fn.apply(new ExpandWildcards.Builder()).build()); + } + + public final Builder explain(boolean value) { + this.explain = value; + return this; + } + + public final Builder fields(List list) { + this.fields = _listAddAll(this.fields, list); + return this; + } + + public final Builder fields(String value, String... values) { + this.fields = _listAdd(this.fields, value, values); + return this; + } + + public final Builder from(int value) { + this.from = value; + return this; + } + + public final Builder ignoreThrottled(boolean value) { + this.ignoreThrottled = value; + return this; + } + + public final Builder ignoreUnavailable(boolean value) { + this.ignoreUnavailable = value; + return this; + } + + public final Builder indicesBoost(List list) { + this.indicesBoost = _listAddAll(this.indicesBoost, list); + return this; + } + + public final Builder indicesBoost(JsonData value, JsonData... values) { + this.indicesBoost = _listAdd(this.indicesBoost, value, values); + return this; + } + + public final Builder lenient(boolean value) { + this.lenient = value; + return this; + } + + public final Builder maxConcurrentShardRequests(long value) { + this.maxConcurrentShardRequests = value; + return this; + } + + public final Builder minScore(int value) { + this.minScore = value; + return this; + } + + public final Builder preFilterShardSize(long value) { + this.preFilterShardSize = value; + return this; + } + + public final Builder preference(String value) { + this.preference = value; + return this; + } + + public final Builder q(String value) { + this.q = value; + return this; + } + + public final Builder query(UserDefinedObjectStructure value) { + this.query = value; + return this; + } + + public final Builder query( + Function< + UserDefinedObjectStructure.Builder, + ObjectBuilder> + fn) { + return query(fn.apply(new UserDefinedObjectStructure.Builder()).build()); + } + + public final Builder requestCache(boolean value) { + this.requestCache = value; + return this; + } + + public final Builder restTotalHitsAsInt(boolean value) { + this.restTotalHitsAsInt = value; + return this; + } + + public final Builder routing(String value) { + this.routing = value; + return this; + } + + public final Builder scroll(String value) { + this.scroll = value; + return this; + } + + public final Builder searchType(SearchType value) { + this.searchType = value; + return this; + } + + public final Builder searchType( + Function> fn) { + return searchType(fn.apply(new SearchType.Builder()).build()); + } + + public final Builder seqNoPrimaryTerm(boolean value) { + this.seqNoPrimaryTerm = value; + return this; + } + + public final Builder size(int value) { + this.size = value; + return this; + } + + public final Builder sort(List list) { + this.sort = _listAddAll(this.sort, list); + return this; + } + + public final Builder sort(String value, String... values) { + this.sort = _listAdd(this.sort, value, values); + return this; + } + + public final Builder source(String value) { + this.source = value; + return this; + } + + public final Builder sourceExcludes(List list) { + this.sourceExcludes = _listAddAll(this.sourceExcludes, list); + return this; + } + + public final Builder sourceExcludes(String value, String... values) { + this.sourceExcludes = _listAdd(this.sourceExcludes, value, values); + return this; + } + + public final Builder sourceIncludes(List list) { + this.sourceIncludes = _listAddAll(this.sourceIncludes, list); + return this; + } + + public final Builder sourceIncludes(String value, String... values) { + this.sourceIncludes = _listAdd(this.sourceIncludes, value, values); + return this; + } + + public final Builder stats(String value) { + this.stats = value; + return this; + } + + public final Builder storedFields(boolean value) { + this.storedFields = value; + return this; + } + + public final Builder suggestField(String value) { + this.suggestField = value; + return this; + } + + public final Builder suggestMode(SuggestMode value) { + this.suggestMode = value; + return this; + } + + public final Builder suggestMode( + Function> fn) { + return suggestMode(fn.apply(new SuggestMode.Builder()).build()); + } + + public final Builder suggestSize(long value) { + this.suggestSize = value; + return this; + } + + public final Builder suggestText(String value) { + this.suggestText = value; + return this; + } + + public final Builder terminateAfter(int value) { + this.terminateAfter = value; + return this; + } + + public final Builder timeout(String value) { + this.timeout = value; + return this; + } + + public final Builder trackScores(boolean value) { + this.trackScores = value; + return this; + } + + public final Builder trackTotalHits(int value) { + this.trackTotalHits = value; + return this; + } + + public final Builder typedKeys(boolean value) { + this.typedKeys = value; + return this; + } + + public final Builder version(boolean value) { + this.version = value; + return this; + } + + /** + * Builds a {@link PostSearchRequest}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public PostSearchRequest build() { + _checkSingleUse(); + + return new PostSearchRequest(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, PostSearchRequest::setupPostSearchRequestDeserializer); + + protected static void setupPostSearchRequestDeserializer( + ObjectDeserializer op) { + op.add(Builder::docvalueFields, JsonpDeserializer.stringDeserializer(), "docvalue_fields"); + op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); + op.add( + Builder::fields, + JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), + "fields"); + op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); + op.add( + Builder::indicesBoost, + JsonpDeserializer.arrayDeserializer(JsonData._DESERIALIZER), + "indices_boost"); + op.add(Builder::minScore, JsonpDeserializer.integerDeserializer(), "min_score"); + op.add(Builder::query, UserDefinedObjectStructure._DESERIALIZER, "query"); + op.add( + Builder::seqNoPrimaryTerm, + JsonpDeserializer.booleanDeserializer(), + "seq_no_primary_term"); + op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); + op.add(Builder::source, JsonpDeserializer.stringDeserializer(), "source"); + op.add(Builder::stats, JsonpDeserializer.stringDeserializer(), "stats"); + op.add(Builder::terminateAfter, JsonpDeserializer.integerDeserializer(), "terminate_after"); + op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); + op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); + } + + public static final Endpoint _ENDPOINT = + new SimpleEndpoint<>( + // Request method + request -> { + return "post"; + }, + // Request path + request -> { + return "/_search"; + }, + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.allowNoIndices != null) { + params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); + } + if (request.allowPartialSearchResults != null) { + params.put( + "allow_partial_search_results", + String.valueOf(request.allowPartialSearchResults)); + } + if (request.analyzeWildcard != null) { + params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); + } + if (request.analyzer != null) { + params.put("analyzer", request.analyzer); + } + if (request.batchedReduceSize != null) { + params.put( + "batched_reduce_size", + String.valueOf(request.batchedReduceSize)); + } + if (request.ccsMinimizeRoundtrips != null) { + params.put( + "ccs_minimize_roundtrips", + String.valueOf(request.ccsMinimizeRoundtrips)); + } + if (request.defaultOperator != null) { + params.put("default_operator", request.defaultOperator.jsonValue()); + } + if (request.df != null) { + params.put("df", request.df); + } + if (request.docvalueFields != null) { + params.put("docvalue_fields", request.docvalueFields); + } + if (request.expandWildcards != null) { + params.put("expand_wildcards", request.expandWildcards.jsonValue()); + } + if (request.explain != null) { + params.put("explain", String.valueOf(request.explain)); + } + if (request.from != null) { + params.put("from", String.valueOf(request.from)); + } + if (request.ignoreThrottled != null) { + params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); + } + if (request.ignoreUnavailable != null) { + params.put( + "ignore_unavailable", + String.valueOf(request.ignoreUnavailable)); + } + if (request.lenient != null) { + params.put("lenient", String.valueOf(request.lenient)); + } + if (request.maxConcurrentShardRequests != null) { + params.put( + "max_concurrent_shard_requests", + String.valueOf(request.maxConcurrentShardRequests)); + } + if (request.preFilterShardSize != null) { + params.put( + "pre_filter_shard_size", + String.valueOf(request.preFilterShardSize)); + } + if (request.preference != null) { + params.put("preference", request.preference); + } + if (request.q != null) { + params.put("q", request.q); + } + if (request.requestCache != null) { + params.put("request_cache", String.valueOf(request.requestCache)); + } + if (request.restTotalHitsAsInt != null) { + params.put( + "rest_total_hits_as_int", + String.valueOf(request.restTotalHitsAsInt)); + } + if (request.routing != null) { + params.put("routing", request.routing); + } + if (request.scroll != null) { + params.put("scroll", request.scroll); + } + if (request.searchType != null) { + params.put("search_type", request.searchType.jsonValue()); + } + if (request.seqNoPrimaryTerm != null) { + params.put( + "seq_no_primary_term", + String.valueOf(request.seqNoPrimaryTerm)); + } + if (request.size != null) { + params.put("size", String.valueOf(request.size)); + } + if (ApiTypeHelper.isDefined(request.sort)) { + params.put( + "sort", + request.sort.stream() + .map(v -> v) + .collect(Collectors.joining(","))); + } + if (request.source != null) { + params.put("source", request.source); + } + if (ApiTypeHelper.isDefined(request.sourceExcludes)) { + params.put( + "source_excludes", + request.sourceExcludes.stream() + .map(v -> v) + .collect(Collectors.joining(","))); + } + if (ApiTypeHelper.isDefined(request.sourceIncludes)) { + params.put( + "source_includes", + request.sourceIncludes.stream() + .map(v -> v) + .collect(Collectors.joining(","))); + } + if (request.stats != null) { + params.put("stats", request.stats); + } + if (request.storedFields != null) { + params.put("stored_fields", String.valueOf(request.storedFields)); + } + if (request.suggestField != null) { + params.put("suggest_field", request.suggestField); + } + if (request.suggestMode != null) { + params.put("suggest_mode", request.suggestMode.jsonValue()); + } + if (request.suggestSize != null) { + params.put("suggest_size", String.valueOf(request.suggestSize)); + } + if (request.suggestText != null) { + params.put("suggest_text", request.suggestText); + } + if (request.terminateAfter != null) { + params.put("terminate_after", String.valueOf(request.terminateAfter)); + } + if (request.timeout != null) { + params.put("timeout", request.timeout); + } + if (request.trackScores != null) { + params.put("track_scores", String.valueOf(request.trackScores)); + } + if (request.trackTotalHits != null) { + params.put("track_total_hits", String.valueOf(request.trackTotalHits)); + } + if (request.typedKeys != null) { + params.put("typed_keys", String.valueOf(request.typedKeys)); + } + if (request.version != null) { + params.put("version", String.valueOf(request.version)); + } + return params; + }, + SimpleEndpoint.emptyMap(), + true, + PostSearchResponse._DESERIALIZER); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java new file mode 100644 index 0000000000..16c12646c5 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java @@ -0,0 +1,954 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +/** Returns results matching a query. */ +@JsonpDeserializable +public class PostSearchWithIndexRequest extends RequestBase implements JsonpSerializable { + private final boolean allowNoIndices; + private final boolean allowPartialSearchResults; + private final boolean analyzeWildcard; + private final String analyzer; + private final int batchedReduceSize; + private final boolean ccsMinimizeRoundtrips; + private final DefaultOperator defaultOperator; + private final String df; + private final String docvalueFields; + private final ExpandWildcards expandWildcards; + private final boolean explain; + private final List fields; + private final int from; + private final boolean ignoreThrottled; + private final boolean ignoreUnavailable; + private final List indicesBoost; + private final boolean lenient; + private final long maxConcurrentShardRequests; + private final int minScore; + private final long preFilterShardSize; + private final String preference; + private final String q; + private final UserDefinedObjectStructure query; + private final boolean requestCache; + private final boolean restTotalHitsAsInt; + private final String routing; + private final String scroll; + private final SearchType searchType; + private final boolean seqNoPrimaryTerm; + private final int size; + private final List sort; + private final String source; + private final List sourceExcludes; + private final List sourceIncludes; + private final String stats; + private final boolean storedFields; + private final String suggestField; + private final SuggestMode suggestMode; + private final long suggestSize; + private final String suggestText; + private final int terminateAfter; + private final String timeout; + private final boolean trackScores; + private final int trackTotalHits; + private final boolean typedKeys; + private final boolean version; + + public PostSearchWithIndexRequest(Builder builder) { + this.allowNoIndices = builder.allowNoIndices; + this.allowPartialSearchResults = builder.allowPartialSearchResults; + this.analyzeWildcard = builder.analyzeWildcard; + this.analyzer = builder.analyzer; + this.batchedReduceSize = builder.batchedReduceSize; + this.ccsMinimizeRoundtrips = builder.ccsMinimizeRoundtrips; + this.defaultOperator = builder.defaultOperator; + this.df = builder.df; + this.docvalueFields = builder.docvalueFields; + this.expandWildcards = builder.expandWildcards; + this.explain = builder.explain; + this.fields = ApiTypeHelper.unmodifiable(builder.fields); + this.from = builder.from; + this.ignoreThrottled = builder.ignoreThrottled; + this.ignoreUnavailable = builder.ignoreUnavailable; + this.indicesBoost = ApiTypeHelper.unmodifiable(builder.indicesBoost); + this.lenient = builder.lenient; + this.maxConcurrentShardRequests = builder.maxConcurrentShardRequests; + this.minScore = builder.minScore; + this.preFilterShardSize = builder.preFilterShardSize; + this.preference = builder.preference; + this.q = builder.q; + this.query = builder.query; + this.requestCache = builder.requestCache; + this.restTotalHitsAsInt = builder.restTotalHitsAsInt; + this.routing = builder.routing; + this.scroll = builder.scroll; + this.searchType = builder.searchType; + this.seqNoPrimaryTerm = builder.seqNoPrimaryTerm; + this.size = builder.size; + this.sort = ApiTypeHelper.unmodifiable(builder.sort); + this.source = builder.source; + this.sourceExcludes = ApiTypeHelper.unmodifiable(builder.sourceExcludes); + this.sourceIncludes = ApiTypeHelper.unmodifiable(builder.sourceIncludes); + this.stats = builder.stats; + this.storedFields = builder.storedFields; + this.suggestField = builder.suggestField; + this.suggestMode = builder.suggestMode; + this.suggestSize = builder.suggestSize; + this.suggestText = builder.suggestText; + this.terminateAfter = builder.terminateAfter; + this.timeout = builder.timeout; + this.trackScores = builder.trackScores; + this.trackTotalHits = builder.trackTotalHits; + this.typedKeys = builder.typedKeys; + this.version = builder.version; + } + + public static PostSearchWithIndexRequest of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final boolean allowNoIndices() { + return this.allowNoIndices; + } + + public final boolean allowPartialSearchResults() { + return this.allowPartialSearchResults; + } + + public final boolean analyzeWildcard() { + return this.analyzeWildcard; + } + + public final String analyzer() { + return this.analyzer; + } + + public final int batchedReduceSize() { + return this.batchedReduceSize; + } + + public final boolean ccsMinimizeRoundtrips() { + return this.ccsMinimizeRoundtrips; + } + + public final DefaultOperator defaultOperator() { + return this.defaultOperator; + } + + public final String df() { + return this.df; + } + + public final String docvalueFields() { + return this.docvalueFields; + } + + public final ExpandWildcards expandWildcards() { + return this.expandWildcards; + } + + public final boolean explain() { + return this.explain; + } + + public final List fields() { + return this.fields; + } + + public final int from() { + return this.from; + } + + public final boolean ignoreThrottled() { + return this.ignoreThrottled; + } + + public final boolean ignoreUnavailable() { + return this.ignoreUnavailable; + } + + public final List indicesBoost() { + return this.indicesBoost; + } + + public final boolean lenient() { + return this.lenient; + } + + public final long maxConcurrentShardRequests() { + return this.maxConcurrentShardRequests; + } + + public final int minScore() { + return this.minScore; + } + + public final long preFilterShardSize() { + return this.preFilterShardSize; + } + + public final String preference() { + return this.preference; + } + + public final String q() { + return this.q; + } + + public final UserDefinedObjectStructure query() { + return this.query; + } + + public final boolean requestCache() { + return this.requestCache; + } + + public final boolean restTotalHitsAsInt() { + return this.restTotalHitsAsInt; + } + + public final String routing() { + return this.routing; + } + + public final String scroll() { + return this.scroll; + } + + public final SearchType searchType() { + return this.searchType; + } + + public final boolean seqNoPrimaryTerm() { + return this.seqNoPrimaryTerm; + } + + public final int size() { + return this.size; + } + + public final List sort() { + return this.sort; + } + + public final String source() { + return this.source; + } + + public final List sourceExcludes() { + return this.sourceExcludes; + } + + public final List sourceIncludes() { + return this.sourceIncludes; + } + + public final String stats() { + return this.stats; + } + + public final boolean storedFields() { + return this.storedFields; + } + + public final String suggestField() { + return this.suggestField; + } + + public final SuggestMode suggestMode() { + return this.suggestMode; + } + + public final long suggestSize() { + return this.suggestSize; + } + + public final String suggestText() { + return this.suggestText; + } + + public final int terminateAfter() { + return this.terminateAfter; + } + + public final String timeout() { + return this.timeout; + } + + public final boolean trackScores() { + return this.trackScores; + } + + public final int trackTotalHits() { + return this.trackTotalHits; + } + + public final boolean typedKeys() { + return this.typedKeys; + } + + public final boolean version() { + return this.version; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.docvalueFields != null) { + generator.writeKey("docvalue_fields"); + generator.write(this.docvalueFields); + } + + if (this.explain != null) { + generator.writeKey("explain"); + generator.write(this.explain); + } + + if (ApiTypeHelper.isDefined(this.fields)) { + generator.writeKey("fields"); + generator.writeStartArray(); + for (String item0 : this.fields) { + generator.write(item0); + } + generator.writeEnd(); + } + + if (this.from != null) { + generator.writeKey("from"); + generator.write(this.from); + } + + if (ApiTypeHelper.isDefined(this.indicesBoost)) { + generator.writeKey("indices_boost"); + generator.writeStartArray(); + for (JsonData item0 : this.indicesBoost) { + item0.serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (this.minScore != null) { + generator.writeKey("min_score"); + generator.write(this.minScore); + } + + if (this.query != null) { + generator.writeKey("query"); + this.query.serialize(generator, mapper); + } + + if (this.seqNoPrimaryTerm != null) { + generator.writeKey("seq_no_primary_term"); + generator.write(this.seqNoPrimaryTerm); + } + + if (this.size != null) { + generator.writeKey("size"); + generator.write(this.size); + } + + if (this.source != null) { + generator.writeKey("source"); + generator.write(this.source); + } + + if (this.stats != null) { + generator.writeKey("stats"); + generator.write(this.stats); + } + + if (this.terminateAfter != null) { + generator.writeKey("terminate_after"); + generator.write(this.terminateAfter); + } + + if (this.timeout != null) { + generator.writeKey("timeout"); + generator.write(this.timeout); + } + + if (this.version != null) { + generator.writeKey("version"); + generator.write(this.version); + } + } + + /** Builder for {@link PostSearchWithIndexRequest}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private boolean allowNoIndices; + private boolean allowPartialSearchResults; + private boolean analyzeWildcard; + private String analyzer; + private int batchedReduceSize; + private boolean ccsMinimizeRoundtrips; + private DefaultOperator defaultOperator; + private String df; + private String docvalueFields; + private ExpandWildcards expandWildcards; + private boolean explain; + private List fields; + private int from; + private boolean ignoreThrottled; + private boolean ignoreUnavailable; + private List indicesBoost; + private boolean lenient; + private long maxConcurrentShardRequests; + private int minScore; + private long preFilterShardSize; + private String preference; + private String q; + private UserDefinedObjectStructure query; + private boolean requestCache; + private boolean restTotalHitsAsInt; + private String routing; + private String scroll; + private SearchType searchType; + private boolean seqNoPrimaryTerm; + private int size; + private List sort; + private String source; + private List sourceExcludes; + private List sourceIncludes; + private String stats; + private boolean storedFields; + private String suggestField; + private SuggestMode suggestMode; + private long suggestSize; + private String suggestText; + private int terminateAfter; + private String timeout; + private boolean trackScores; + private int trackTotalHits; + private boolean typedKeys; + private boolean version; + + public final Builder allowNoIndices(boolean value) { + this.allowNoIndices = value; + return this; + } + + public final Builder allowPartialSearchResults(boolean value) { + this.allowPartialSearchResults = value; + return this; + } + + public final Builder analyzeWildcard(boolean value) { + this.analyzeWildcard = value; + return this; + } + + public final Builder analyzer(String value) { + this.analyzer = value; + return this; + } + + public final Builder batchedReduceSize(int value) { + this.batchedReduceSize = value; + return this; + } + + public final Builder ccsMinimizeRoundtrips(boolean value) { + this.ccsMinimizeRoundtrips = value; + return this; + } + + public final Builder defaultOperator(DefaultOperator value) { + this.defaultOperator = value; + return this; + } + + public final Builder defaultOperator( + Function> fn) { + return defaultOperator(fn.apply(new DefaultOperator.Builder()).build()); + } + + public final Builder df(String value) { + this.df = value; + return this; + } + + public final Builder docvalueFields(String value) { + this.docvalueFields = value; + return this; + } + + public final Builder expandWildcards(ExpandWildcards value) { + this.expandWildcards = value; + return this; + } + + public final Builder expandWildcards( + Function> fn) { + return expandWildcards(fn.apply(new ExpandWildcards.Builder()).build()); + } + + public final Builder explain(boolean value) { + this.explain = value; + return this; + } + + public final Builder fields(List list) { + this.fields = _listAddAll(this.fields, list); + return this; + } + + public final Builder fields(String value, String... values) { + this.fields = _listAdd(this.fields, value, values); + return this; + } + + public final Builder from(int value) { + this.from = value; + return this; + } + + public final Builder ignoreThrottled(boolean value) { + this.ignoreThrottled = value; + return this; + } + + public final Builder ignoreUnavailable(boolean value) { + this.ignoreUnavailable = value; + return this; + } + + public final Builder indicesBoost(List list) { + this.indicesBoost = _listAddAll(this.indicesBoost, list); + return this; + } + + public final Builder indicesBoost(JsonData value, JsonData... values) { + this.indicesBoost = _listAdd(this.indicesBoost, value, values); + return this; + } + + public final Builder lenient(boolean value) { + this.lenient = value; + return this; + } + + public final Builder maxConcurrentShardRequests(long value) { + this.maxConcurrentShardRequests = value; + return this; + } + + public final Builder minScore(int value) { + this.minScore = value; + return this; + } + + public final Builder preFilterShardSize(long value) { + this.preFilterShardSize = value; + return this; + } + + public final Builder preference(String value) { + this.preference = value; + return this; + } + + public final Builder q(String value) { + this.q = value; + return this; + } + + public final Builder query(UserDefinedObjectStructure value) { + this.query = value; + return this; + } + + public final Builder query( + Function< + UserDefinedObjectStructure.Builder, + ObjectBuilder> + fn) { + return query(fn.apply(new UserDefinedObjectStructure.Builder()).build()); + } + + public final Builder requestCache(boolean value) { + this.requestCache = value; + return this; + } + + public final Builder restTotalHitsAsInt(boolean value) { + this.restTotalHitsAsInt = value; + return this; + } + + public final Builder routing(String value) { + this.routing = value; + return this; + } + + public final Builder scroll(String value) { + this.scroll = value; + return this; + } + + public final Builder searchType(SearchType value) { + this.searchType = value; + return this; + } + + public final Builder searchType( + Function> fn) { + return searchType(fn.apply(new SearchType.Builder()).build()); + } + + public final Builder seqNoPrimaryTerm(boolean value) { + this.seqNoPrimaryTerm = value; + return this; + } + + public final Builder size(int value) { + this.size = value; + return this; + } + + public final Builder sort(List list) { + this.sort = _listAddAll(this.sort, list); + return this; + } + + public final Builder sort(String value, String... values) { + this.sort = _listAdd(this.sort, value, values); + return this; + } + + public final Builder source(String value) { + this.source = value; + return this; + } + + public final Builder sourceExcludes(List list) { + this.sourceExcludes = _listAddAll(this.sourceExcludes, list); + return this; + } + + public final Builder sourceExcludes(String value, String... values) { + this.sourceExcludes = _listAdd(this.sourceExcludes, value, values); + return this; + } + + public final Builder sourceIncludes(List list) { + this.sourceIncludes = _listAddAll(this.sourceIncludes, list); + return this; + } + + public final Builder sourceIncludes(String value, String... values) { + this.sourceIncludes = _listAdd(this.sourceIncludes, value, values); + return this; + } + + public final Builder stats(String value) { + this.stats = value; + return this; + } + + public final Builder storedFields(boolean value) { + this.storedFields = value; + return this; + } + + public final Builder suggestField(String value) { + this.suggestField = value; + return this; + } + + public final Builder suggestMode(SuggestMode value) { + this.suggestMode = value; + return this; + } + + public final Builder suggestMode( + Function> fn) { + return suggestMode(fn.apply(new SuggestMode.Builder()).build()); + } + + public final Builder suggestSize(long value) { + this.suggestSize = value; + return this; + } + + public final Builder suggestText(String value) { + this.suggestText = value; + return this; + } + + public final Builder terminateAfter(int value) { + this.terminateAfter = value; + return this; + } + + public final Builder timeout(String value) { + this.timeout = value; + return this; + } + + public final Builder trackScores(boolean value) { + this.trackScores = value; + return this; + } + + public final Builder trackTotalHits(int value) { + this.trackTotalHits = value; + return this; + } + + public final Builder typedKeys(boolean value) { + this.typedKeys = value; + return this; + } + + public final Builder version(boolean value) { + this.version = value; + return this; + } + + /** + * Builds a {@link PostSearchWithIndexRequest}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public PostSearchWithIndexRequest build() { + _checkSingleUse(); + + return new PostSearchWithIndexRequest(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, + PostSearchWithIndexRequest::setupPostSearchWithIndexRequestDeserializer); + + protected static void setupPostSearchWithIndexRequestDeserializer( + ObjectDeserializer op) { + op.add(Builder::docvalueFields, JsonpDeserializer.stringDeserializer(), "docvalue_fields"); + op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); + op.add( + Builder::fields, + JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), + "fields"); + op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); + op.add( + Builder::indicesBoost, + JsonpDeserializer.arrayDeserializer(JsonData._DESERIALIZER), + "indices_boost"); + op.add(Builder::minScore, JsonpDeserializer.integerDeserializer(), "min_score"); + op.add(Builder::query, UserDefinedObjectStructure._DESERIALIZER, "query"); + op.add( + Builder::seqNoPrimaryTerm, + JsonpDeserializer.booleanDeserializer(), + "seq_no_primary_term"); + op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); + op.add(Builder::source, JsonpDeserializer.stringDeserializer(), "source"); + op.add(Builder::stats, JsonpDeserializer.stringDeserializer(), "stats"); + op.add(Builder::terminateAfter, JsonpDeserializer.integerDeserializer(), "terminate_after"); + op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); + op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); + } + + public static final Endpoint< + PostSearchWithIndexRequest, PostSearchWithIndexResponse, ErrorResponse> + _ENDPOINT = + new SimpleEndpoint<>( + // Request method + request -> { + return "post"; + }, + // Request path + request -> { + return "/{index}/_search"; + }, + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.allowNoIndices != null) { + params.put( + "allow_no_indices", + String.valueOf(request.allowNoIndices)); + } + if (request.allowPartialSearchResults != null) { + params.put( + "allow_partial_search_results", + String.valueOf(request.allowPartialSearchResults)); + } + if (request.analyzeWildcard != null) { + params.put( + "analyze_wildcard", + String.valueOf(request.analyzeWildcard)); + } + if (request.analyzer != null) { + params.put("analyzer", request.analyzer); + } + if (request.batchedReduceSize != null) { + params.put( + "batched_reduce_size", + String.valueOf(request.batchedReduceSize)); + } + if (request.ccsMinimizeRoundtrips != null) { + params.put( + "ccs_minimize_roundtrips", + String.valueOf(request.ccsMinimizeRoundtrips)); + } + if (request.defaultOperator != null) { + params.put( + "default_operator", + request.defaultOperator.jsonValue()); + } + if (request.df != null) { + params.put("df", request.df); + } + if (request.docvalueFields != null) { + params.put("docvalue_fields", request.docvalueFields); + } + if (request.expandWildcards != null) { + params.put( + "expand_wildcards", + request.expandWildcards.jsonValue()); + } + if (request.explain != null) { + params.put("explain", String.valueOf(request.explain)); + } + if (request.from != null) { + params.put("from", String.valueOf(request.from)); + } + if (request.ignoreThrottled != null) { + params.put( + "ignore_throttled", + String.valueOf(request.ignoreThrottled)); + } + if (request.ignoreUnavailable != null) { + params.put( + "ignore_unavailable", + String.valueOf(request.ignoreUnavailable)); + } + if (request.lenient != null) { + params.put("lenient", String.valueOf(request.lenient)); + } + if (request.maxConcurrentShardRequests != null) { + params.put( + "max_concurrent_shard_requests", + String.valueOf(request.maxConcurrentShardRequests)); + } + if (request.preFilterShardSize != null) { + params.put( + "pre_filter_shard_size", + String.valueOf(request.preFilterShardSize)); + } + if (request.preference != null) { + params.put("preference", request.preference); + } + if (request.q != null) { + params.put("q", request.q); + } + if (request.requestCache != null) { + params.put( + "request_cache", String.valueOf(request.requestCache)); + } + if (request.restTotalHitsAsInt != null) { + params.put( + "rest_total_hits_as_int", + String.valueOf(request.restTotalHitsAsInt)); + } + if (request.routing != null) { + params.put("routing", request.routing); + } + if (request.scroll != null) { + params.put("scroll", request.scroll); + } + if (request.searchType != null) { + params.put("search_type", request.searchType.jsonValue()); + } + if (request.seqNoPrimaryTerm != null) { + params.put( + "seq_no_primary_term", + String.valueOf(request.seqNoPrimaryTerm)); + } + if (request.size != null) { + params.put("size", String.valueOf(request.size)); + } + if (ApiTypeHelper.isDefined(request.sort)) { + params.put( + "sort", + request.sort.stream() + .map(v -> v) + .collect(Collectors.joining(","))); + } + if (request.source != null) { + params.put("source", request.source); + } + if (ApiTypeHelper.isDefined(request.sourceExcludes)) { + params.put( + "source_excludes", + request.sourceExcludes.stream() + .map(v -> v) + .collect(Collectors.joining(","))); + } + if (ApiTypeHelper.isDefined(request.sourceIncludes)) { + params.put( + "source_includes", + request.sourceIncludes.stream() + .map(v -> v) + .collect(Collectors.joining(","))); + } + if (request.stats != null) { + params.put("stats", request.stats); + } + if (request.storedFields != null) { + params.put( + "stored_fields", String.valueOf(request.storedFields)); + } + if (request.suggestField != null) { + params.put("suggest_field", request.suggestField); + } + if (request.suggestMode != null) { + params.put("suggest_mode", request.suggestMode.jsonValue()); + } + if (request.suggestSize != null) { + params.put("suggest_size", String.valueOf(request.suggestSize)); + } + if (request.suggestText != null) { + params.put("suggest_text", request.suggestText); + } + if (request.terminateAfter != null) { + params.put( + "terminate_after", + String.valueOf(request.terminateAfter)); + } + if (request.timeout != null) { + params.put("timeout", request.timeout); + } + if (request.trackScores != null) { + params.put("track_scores", String.valueOf(request.trackScores)); + } + if (request.trackTotalHits != null) { + params.put( + "track_total_hits", + String.valueOf(request.trackTotalHits)); + } + if (request.typedKeys != null) { + params.put("typed_keys", String.valueOf(request.typedKeys)); + } + if (request.version != null) { + params.put("version", String.valueOf(request.version)); + } + return params; + }, + SimpleEndpoint.emptyMap(), + true, + PostSearchWithIndexResponse._DESERIALIZER); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java new file mode 100644 index 0000000000..5587a1c0a1 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java @@ -0,0 +1,249 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +/** Creates index mappings. */ +@JsonpDeserializable +public class PutCreateIndexRequest extends RequestBase implements JsonpSerializable { + private final Map aliases; + private final String clusterManagerTimeout; + private final boolean includeTypeName; + private final Map mapping; + private final String masterTimeout; + private final Map settings; + private final String timeout; + private final String waitForActiveShards; + + public PutCreateIndexRequest(Builder builder) { + this.aliases = ApiTypeHelper.unmodifiable(builder.aliases); + this.clusterManagerTimeout = builder.clusterManagerTimeout; + this.includeTypeName = builder.includeTypeName; + this.mapping = ApiTypeHelper.unmodifiable(builder.mapping); + this.masterTimeout = builder.masterTimeout; + this.settings = ApiTypeHelper.unmodifiable(builder.settings); + this.timeout = builder.timeout; + this.waitForActiveShards = builder.waitForActiveShards; + } + + public static PutCreateIndexRequest of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final Map aliases() { + return this.aliases; + } + + public final String clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + + public final boolean includeTypeName() { + return this.includeTypeName; + } + + public final Map mapping() { + return this.mapping; + } + + public final String masterTimeout() { + return this.masterTimeout; + } + + public final Map settings() { + return this.settings; + } + + public final String timeout() { + return this.timeout; + } + + public final String waitForActiveShards() { + return this.waitForActiveShards; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (ApiTypeHelper.isDefined(this.aliases)) { + generator.writeKey("aliases"); + generator.writeStartObject(); + for (Map.Entry item0 : this.aliases.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (ApiTypeHelper.isDefined(this.mapping)) { + generator.writeKey("mapping"); + generator.writeStartObject(); + for (Map.Entry item0 : this.mapping.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (ApiTypeHelper.isDefined(this.settings)) { + generator.writeKey("settings"); + generator.writeStartObject(); + for (Map.Entry item0 : this.settings.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + } + + /** Builder for {@link PutCreateIndexRequest}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private Map aliases; + private String clusterManagerTimeout; + private boolean includeTypeName; + private Map mapping; + private String masterTimeout; + private Map settings; + private String timeout; + private String waitForActiveShards; + + public final Builder aliases(Map map) { + this.aliases = _mapPutAll(this.aliases, map); + return this; + } + + public final Builder aliases(String key, JsonData value) { + this.aliases = _mapPut(this.aliases, key, value); + return this; + } + + public final Builder clusterManagerTimeout(String value) { + this.clusterManagerTimeout = value; + return this; + } + + public final Builder includeTypeName(boolean value) { + this.includeTypeName = value; + return this; + } + + public final Builder mapping(Map map) { + this.mapping = _mapPutAll(this.mapping, map); + return this; + } + + public final Builder mapping(String key, JsonData value) { + this.mapping = _mapPut(this.mapping, key, value); + return this; + } + + public final Builder masterTimeout(String value) { + this.masterTimeout = value; + return this; + } + + public final Builder settings(Map map) { + this.settings = _mapPutAll(this.settings, map); + return this; + } + + public final Builder settings(String key, JsonData value) { + this.settings = _mapPut(this.settings, key, value); + return this; + } + + public final Builder timeout(String value) { + this.timeout = value; + return this; + } + + public final Builder waitForActiveShards(String value) { + this.waitForActiveShards = value; + return this; + } + + /** + * Builds a {@link PutCreateIndexRequest}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public PutCreateIndexRequest build() { + _checkSingleUse(); + + return new PutCreateIndexRequest(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, PutCreateIndexRequest::setupPutCreateIndexRequestDeserializer); + + protected static void setupPutCreateIndexRequestDeserializer( + ObjectDeserializer op) { + op.add( + Builder::aliases, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "aliases"); + op.add( + Builder::mapping, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "mapping"); + op.add( + Builder::settings, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "settings"); + } + + public static final Endpoint + _ENDPOINT = + new SimpleEndpoint<>( + // Request method + request -> { + return "put"; + }, + // Request path + request -> { + return "/{index}"; + }, + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.clusterManagerTimeout != null) { + params.put( + "cluster_manager_timeout", + request.clusterManagerTimeout); + } + if (request.includeTypeName != null) { + params.put( + "include_type_name", + String.valueOf(request.includeTypeName)); + } + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout); + } + if (request.timeout != null) { + params.put("timeout", request.timeout); + } + if (request.waitForActiveShards != null) { + params.put( + "wait_for_active_shards", request.waitForActiveShards); + } + return params; + }, + SimpleEndpoint.emptyMap(), + true, + PutCreateIndexResponse._DESERIALIZER); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java new file mode 100644 index 0000000000..04e336cf75 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java @@ -0,0 +1,236 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +/** The put mapping API operation lets you add new mappings and fields to an index. */ +@JsonpDeserializable +public class PutIndexMappingWithIndexRequest extends RequestBase implements JsonpSerializable { + private final boolean allowNoIndices; + private final String clusterManagerTimeout; + private final ExpandWildcards expandWildcards; + private final boolean ignoreUnavailable; + private final boolean includeTypeName; + private final String masterTimeout; + private final JsonData properties; + private final String timeout; + private final boolean writeIndexOnly; + + public PutIndexMappingWithIndexRequest(Builder builder) { + this.allowNoIndices = builder.allowNoIndices; + this.clusterManagerTimeout = builder.clusterManagerTimeout; + this.expandWildcards = builder.expandWildcards; + this.ignoreUnavailable = builder.ignoreUnavailable; + this.includeTypeName = builder.includeTypeName; + this.masterTimeout = builder.masterTimeout; + this.properties = builder.properties; + this.timeout = builder.timeout; + this.writeIndexOnly = builder.writeIndexOnly; + } + + public static PutIndexMappingWithIndexRequest of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final boolean allowNoIndices() { + return this.allowNoIndices; + } + + public final String clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + + public final ExpandWildcards expandWildcards() { + return this.expandWildcards; + } + + public final boolean ignoreUnavailable() { + return this.ignoreUnavailable; + } + + public final boolean includeTypeName() { + return this.includeTypeName; + } + + public final String masterTimeout() { + return this.masterTimeout; + } + + public final JsonData properties() { + return this.properties; + } + + public final String timeout() { + return this.timeout; + } + + public final boolean writeIndexOnly() { + return this.writeIndexOnly; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.properties != null) { + generator.writeKey("properties"); + this.properties.serialize(generator, mapper); + } + } + + /** Builder for {@link PutIndexMappingWithIndexRequest}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private boolean allowNoIndices; + private String clusterManagerTimeout; + private ExpandWildcards expandWildcards; + private boolean ignoreUnavailable; + private boolean includeTypeName; + private String masterTimeout; + private JsonData properties; + private String timeout; + private boolean writeIndexOnly; + + public final Builder allowNoIndices(boolean value) { + this.allowNoIndices = value; + return this; + } + + public final Builder clusterManagerTimeout(String value) { + this.clusterManagerTimeout = value; + return this; + } + + public final Builder expandWildcards(ExpandWildcards value) { + this.expandWildcards = value; + return this; + } + + public final Builder expandWildcards( + Function> fn) { + return expandWildcards(fn.apply(new ExpandWildcards.Builder()).build()); + } + + public final Builder ignoreUnavailable(boolean value) { + this.ignoreUnavailable = value; + return this; + } + + public final Builder includeTypeName(boolean value) { + this.includeTypeName = value; + return this; + } + + public final Builder masterTimeout(String value) { + this.masterTimeout = value; + return this; + } + + public final Builder properties(JsonData value) { + this.properties = value; + return this; + } + + public final Builder timeout(String value) { + this.timeout = value; + return this; + } + + public final Builder writeIndexOnly(boolean value) { + this.writeIndexOnly = value; + return this; + } + + /** + * Builds a {@link PutIndexMappingWithIndexRequest}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public PutIndexMappingWithIndexRequest build() { + _checkSingleUse(); + + return new PutIndexMappingWithIndexRequest(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, + PutIndexMappingWithIndexRequest + ::setupPutIndexMappingWithIndexRequestDeserializer); + + protected static void setupPutIndexMappingWithIndexRequestDeserializer( + ObjectDeserializer op) { + op.add(Builder::properties, JsonData._DESERIALIZER, "properties"); + } + + public static final Endpoint< + PutIndexMappingWithIndexRequest, + PutIndexMappingWithIndexResponse, + ErrorResponse> + _ENDPOINT = + new SimpleEndpoint<>( + // Request method + request -> { + return "put"; + }, + // Request path + request -> { + return "/{index}/_mapping"; + }, + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.allowNoIndices != null) { + params.put( + "allow_no_indices", + String.valueOf(request.allowNoIndices)); + } + if (request.clusterManagerTimeout != null) { + params.put( + "cluster_manager_timeout", + request.clusterManagerTimeout); + } + if (request.expandWildcards != null) { + params.put( + "expand_wildcards", + request.expandWildcards.jsonValue()); + } + if (request.ignoreUnavailable != null) { + params.put( + "ignore_unavailable", + String.valueOf(request.ignoreUnavailable)); + } + if (request.includeTypeName != null) { + params.put( + "include_type_name", + String.valueOf(request.includeTypeName)); + } + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout); + } + if (request.timeout != null) { + params.put("timeout", request.timeout); + } + if (request.writeIndexOnly != null) { + params.put( + "write_index_only", + String.valueOf(request.writeIndexOnly)); + } + return params; + }, + SimpleEndpoint.emptyMap(), + true, + PutIndexMappingWithIndexResponse._DESERIALIZER); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsRequest.java new file mode 100644 index 0000000000..6380fa9d3e --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsRequest.java @@ -0,0 +1,206 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +/** Updates the cluster settings. */ +@JsonpDeserializable +public class PutUpdateClusterSettingsRequest extends RequestBase implements JsonpSerializable { + private final String clusterManagerTimeout; + private final boolean flatSettings; + private final String masterTimeout; + private final Map persistent; + private final String timeout; + private final Map transient_; + + public PutUpdateClusterSettingsRequest(Builder builder) { + this.clusterManagerTimeout = builder.clusterManagerTimeout; + this.flatSettings = builder.flatSettings; + this.masterTimeout = builder.masterTimeout; + this.persistent = ApiTypeHelper.unmodifiable(builder.persistent); + this.timeout = builder.timeout; + this.transient_ = ApiTypeHelper.unmodifiable(builder.transient_); + } + + public static PutUpdateClusterSettingsRequest of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final String clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + + public final boolean flatSettings() { + return this.flatSettings; + } + + public final String masterTimeout() { + return this.masterTimeout; + } + + public final Map persistent() { + return this.persistent; + } + + public final String timeout() { + return this.timeout; + } + + public final Map transient_() { + return this.transient_; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (ApiTypeHelper.isDefined(this.persistent)) { + generator.writeKey("persistent"); + generator.writeStartObject(); + for (Map.Entry item0 : this.persistent.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (ApiTypeHelper.isDefined(this.transient_)) { + generator.writeKey("transient"); + generator.writeStartObject(); + for (Map.Entry item0 : this.transient_.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + } + + /** Builder for {@link PutUpdateClusterSettingsRequest}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private String clusterManagerTimeout; + private boolean flatSettings; + private String masterTimeout; + private Map persistent; + private String timeout; + private Map transient_; + + public final Builder clusterManagerTimeout(String value) { + this.clusterManagerTimeout = value; + return this; + } + + public final Builder flatSettings(boolean value) { + this.flatSettings = value; + return this; + } + + public final Builder masterTimeout(String value) { + this.masterTimeout = value; + return this; + } + + public final Builder persistent(Map map) { + this.persistent = _mapPutAll(this.persistent, map); + return this; + } + + public final Builder persistent(String key, JsonData value) { + this.persistent = _mapPut(this.persistent, key, value); + return this; + } + + public final Builder timeout(String value) { + this.timeout = value; + return this; + } + + public final Builder transient_(Map map) { + this.transient_ = _mapPutAll(this.transient_, map); + return this; + } + + public final Builder transient_(String key, JsonData value) { + this.transient_ = _mapPut(this.transient_, key, value); + return this; + } + + /** + * Builds a {@link PutUpdateClusterSettingsRequest}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public PutUpdateClusterSettingsRequest build() { + _checkSingleUse(); + + return new PutUpdateClusterSettingsRequest(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, + PutUpdateClusterSettingsRequest + ::setupPutUpdateClusterSettingsRequestDeserializer); + + protected static void setupPutUpdateClusterSettingsRequestDeserializer( + ObjectDeserializer op) { + op.add( + Builder::persistent, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "persistent"); + op.add( + Builder::transient_, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "transient"); + } + + public static final Endpoint< + PutUpdateClusterSettingsRequest, + PutUpdateClusterSettingsResponse, + ErrorResponse> + _ENDPOINT = + new SimpleEndpoint<>( + // Request method + request -> { + return "put"; + }, + // Request path + request -> { + return "/_cluster/settings"; + }, + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.clusterManagerTimeout != null) { + params.put( + "cluster_manager_timeout", + request.clusterManagerTimeout); + } + if (request.flatSettings != null) { + params.put( + "flat_settings", String.valueOf(request.flatSettings)); + } + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout); + } + if (request.timeout != null) { + params.put("timeout", request.timeout); + } + return params; + }, + SimpleEndpoint.emptyMap(), + true, + PutUpdateClusterSettingsResponse._DESERIALIZER); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedObjectStructure.java b/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedObjectStructure.java new file mode 100644 index 0000000000..bf36d2dba1 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedObjectStructure.java @@ -0,0 +1,1179 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class UserDefinedObjectStructure implements JsonpSerializable { + private final JsonData bool; + private final JsonData boosting; + private final JsonData combinedFields; + private final JsonData constantScore; + private final JsonData disMax; + private final JsonData distanceFeature; + private final JsonData exists; + private final JsonData fieldMaskingSpan; + private final JsonData functionScore; + private final Map fuzzy; + private final JsonData geoBoundingBox; + private final JsonData geoDistance; + private final JsonData geoPolygon; + private final JsonData geoShape; + private final JsonData hasChild; + private final JsonData hasParent; + private final JsonData ids; + private final Map intervals; + private final JsonData knn; + private final Map match; + private final JsonData matchAll; + private final Map matchBoolPrefix; + private final JsonData matchNone; + private final Map matchPhrase; + private final Map matchPhrasePrefix; + private final JsonData moreLikeThis; + private final JsonData multiMatch; + private final JsonData nested; + private final JsonData parentId; + private final JsonData percolate; + private final JsonData pinned; + private final Map prefix; + private final JsonData queryString; + private final Map range; + private final JsonData rankFeature; + private final Map regexp; + private final JsonData script; + private final JsonData scriptScore; + private final JsonData shape; + private final JsonData simpleQueryString; + private final JsonData spanContaining; + private final JsonData spanFirst; + private final JsonData spanMulti; + private final JsonData spanNear; + private final JsonData spanNot; + private final JsonData spanOr; + private final Map spanTerm; + private final JsonData spanWithin; + private final Map term; + private final JsonData terms; + private final Map termsSet; + private final Map wildcard; + private final JsonData wrapper; + + public UserDefinedObjectStructure(Builder builder) { + this.bool = builder.bool; + this.boosting = builder.boosting; + this.combinedFields = builder.combinedFields; + this.constantScore = builder.constantScore; + this.disMax = builder.disMax; + this.distanceFeature = builder.distanceFeature; + this.exists = builder.exists; + this.fieldMaskingSpan = builder.fieldMaskingSpan; + this.functionScore = builder.functionScore; + this.fuzzy = ApiTypeHelper.unmodifiable(builder.fuzzy); + this.geoBoundingBox = builder.geoBoundingBox; + this.geoDistance = builder.geoDistance; + this.geoPolygon = builder.geoPolygon; + this.geoShape = builder.geoShape; + this.hasChild = builder.hasChild; + this.hasParent = builder.hasParent; + this.ids = builder.ids; + this.intervals = ApiTypeHelper.unmodifiable(builder.intervals); + this.knn = builder.knn; + this.match = ApiTypeHelper.unmodifiable(builder.match); + this.matchAll = builder.matchAll; + this.matchBoolPrefix = ApiTypeHelper.unmodifiable(builder.matchBoolPrefix); + this.matchNone = builder.matchNone; + this.matchPhrase = ApiTypeHelper.unmodifiable(builder.matchPhrase); + this.matchPhrasePrefix = ApiTypeHelper.unmodifiable(builder.matchPhrasePrefix); + this.moreLikeThis = builder.moreLikeThis; + this.multiMatch = builder.multiMatch; + this.nested = builder.nested; + this.parentId = builder.parentId; + this.percolate = builder.percolate; + this.pinned = builder.pinned; + this.prefix = ApiTypeHelper.unmodifiable(builder.prefix); + this.queryString = builder.queryString; + this.range = ApiTypeHelper.unmodifiable(builder.range); + this.rankFeature = builder.rankFeature; + this.regexp = ApiTypeHelper.unmodifiable(builder.regexp); + this.script = builder.script; + this.scriptScore = builder.scriptScore; + this.shape = builder.shape; + this.simpleQueryString = builder.simpleQueryString; + this.spanContaining = builder.spanContaining; + this.spanFirst = builder.spanFirst; + this.spanMulti = builder.spanMulti; + this.spanNear = builder.spanNear; + this.spanNot = builder.spanNot; + this.spanOr = builder.spanOr; + this.spanTerm = ApiTypeHelper.unmodifiable(builder.spanTerm); + this.spanWithin = builder.spanWithin; + this.term = ApiTypeHelper.unmodifiable(builder.term); + this.terms = builder.terms; + this.termsSet = ApiTypeHelper.unmodifiable(builder.termsSet); + this.wildcard = ApiTypeHelper.unmodifiable(builder.wildcard); + this.wrapper = builder.wrapper; + } + + public static UserDefinedObjectStructure of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final JsonData bool() { + return this.bool; + } + + public final JsonData boosting() { + return this.boosting; + } + + public final JsonData combinedFields() { + return this.combinedFields; + } + + public final JsonData constantScore() { + return this.constantScore; + } + + public final JsonData disMax() { + return this.disMax; + } + + public final JsonData distanceFeature() { + return this.distanceFeature; + } + + public final JsonData exists() { + return this.exists; + } + + public final JsonData fieldMaskingSpan() { + return this.fieldMaskingSpan; + } + + public final JsonData functionScore() { + return this.functionScore; + } + + public final Map fuzzy() { + return this.fuzzy; + } + + public final JsonData geoBoundingBox() { + return this.geoBoundingBox; + } + + public final JsonData geoDistance() { + return this.geoDistance; + } + + public final JsonData geoPolygon() { + return this.geoPolygon; + } + + public final JsonData geoShape() { + return this.geoShape; + } + + public final JsonData hasChild() { + return this.hasChild; + } + + public final JsonData hasParent() { + return this.hasParent; + } + + public final JsonData ids() { + return this.ids; + } + + public final Map intervals() { + return this.intervals; + } + + public final JsonData knn() { + return this.knn; + } + + public final Map match() { + return this.match; + } + + public final JsonData matchAll() { + return this.matchAll; + } + + public final Map matchBoolPrefix() { + return this.matchBoolPrefix; + } + + public final JsonData matchNone() { + return this.matchNone; + } + + public final Map matchPhrase() { + return this.matchPhrase; + } + + public final Map matchPhrasePrefix() { + return this.matchPhrasePrefix; + } + + public final JsonData moreLikeThis() { + return this.moreLikeThis; + } + + public final JsonData multiMatch() { + return this.multiMatch; + } + + public final JsonData nested() { + return this.nested; + } + + public final JsonData parentId() { + return this.parentId; + } + + public final JsonData percolate() { + return this.percolate; + } + + public final JsonData pinned() { + return this.pinned; + } + + public final Map prefix() { + return this.prefix; + } + + public final JsonData queryString() { + return this.queryString; + } + + public final Map range() { + return this.range; + } + + public final JsonData rankFeature() { + return this.rankFeature; + } + + public final Map regexp() { + return this.regexp; + } + + public final JsonData script() { + return this.script; + } + + public final JsonData scriptScore() { + return this.scriptScore; + } + + public final JsonData shape() { + return this.shape; + } + + public final JsonData simpleQueryString() { + return this.simpleQueryString; + } + + public final JsonData spanContaining() { + return this.spanContaining; + } + + public final JsonData spanFirst() { + return this.spanFirst; + } + + public final JsonData spanMulti() { + return this.spanMulti; + } + + public final JsonData spanNear() { + return this.spanNear; + } + + public final JsonData spanNot() { + return this.spanNot; + } + + public final JsonData spanOr() { + return this.spanOr; + } + + public final Map spanTerm() { + return this.spanTerm; + } + + public final JsonData spanWithin() { + return this.spanWithin; + } + + public final Map term() { + return this.term; + } + + public final JsonData terms() { + return this.terms; + } + + public final Map termsSet() { + return this.termsSet; + } + + public final Map wildcard() { + return this.wildcard; + } + + public final JsonData wrapper() { + return this.wrapper; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.bool != null) { + generator.writeKey("bool"); + this.bool.serialize(generator, mapper); + } + + if (this.boosting != null) { + generator.writeKey("boosting"); + this.boosting.serialize(generator, mapper); + } + + if (this.combinedFields != null) { + generator.writeKey("combined_fields"); + this.combinedFields.serialize(generator, mapper); + } + + if (this.constantScore != null) { + generator.writeKey("constant_score"); + this.constantScore.serialize(generator, mapper); + } + + if (this.disMax != null) { + generator.writeKey("dis_max"); + this.disMax.serialize(generator, mapper); + } + + if (this.distanceFeature != null) { + generator.writeKey("distance_feature"); + this.distanceFeature.serialize(generator, mapper); + } + + if (this.exists != null) { + generator.writeKey("exists"); + this.exists.serialize(generator, mapper); + } + + if (this.fieldMaskingSpan != null) { + generator.writeKey("field_masking_span"); + this.fieldMaskingSpan.serialize(generator, mapper); + } + + if (this.functionScore != null) { + generator.writeKey("function_score"); + this.functionScore.serialize(generator, mapper); + } + + if (ApiTypeHelper.isDefined(this.fuzzy)) { + generator.writeKey("fuzzy"); + generator.writeStartObject(); + for (Map.Entry item0 : this.fuzzy.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (this.geoBoundingBox != null) { + generator.writeKey("geo_bounding_box"); + this.geoBoundingBox.serialize(generator, mapper); + } + + if (this.geoDistance != null) { + generator.writeKey("geo_distance"); + this.geoDistance.serialize(generator, mapper); + } + + if (this.geoPolygon != null) { + generator.writeKey("geo_polygon"); + this.geoPolygon.serialize(generator, mapper); + } + + if (this.geoShape != null) { + generator.writeKey("geo_shape"); + this.geoShape.serialize(generator, mapper); + } + + if (this.hasChild != null) { + generator.writeKey("has_child"); + this.hasChild.serialize(generator, mapper); + } + + if (this.hasParent != null) { + generator.writeKey("has_parent"); + this.hasParent.serialize(generator, mapper); + } + + if (this.ids != null) { + generator.writeKey("ids"); + this.ids.serialize(generator, mapper); + } + + if (ApiTypeHelper.isDefined(this.intervals)) { + generator.writeKey("intervals"); + generator.writeStartObject(); + for (Map.Entry item0 : this.intervals.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (this.knn != null) { + generator.writeKey("knn"); + this.knn.serialize(generator, mapper); + } + + if (ApiTypeHelper.isDefined(this.match)) { + generator.writeKey("match"); + generator.writeStartObject(); + for (Map.Entry item0 : this.match.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (this.matchAll != null) { + generator.writeKey("match_all"); + this.matchAll.serialize(generator, mapper); + } + + if (ApiTypeHelper.isDefined(this.matchBoolPrefix)) { + generator.writeKey("match_bool_prefix"); + generator.writeStartObject(); + for (Map.Entry item0 : this.matchBoolPrefix.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (this.matchNone != null) { + generator.writeKey("match_none"); + this.matchNone.serialize(generator, mapper); + } + + if (ApiTypeHelper.isDefined(this.matchPhrase)) { + generator.writeKey("match_phrase"); + generator.writeStartObject(); + for (Map.Entry item0 : this.matchPhrase.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (ApiTypeHelper.isDefined(this.matchPhrasePrefix)) { + generator.writeKey("match_phrase_prefix"); + generator.writeStartObject(); + for (Map.Entry item0 : this.matchPhrasePrefix.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (this.moreLikeThis != null) { + generator.writeKey("more_like_this"); + this.moreLikeThis.serialize(generator, mapper); + } + + if (this.multiMatch != null) { + generator.writeKey("multi_match"); + this.multiMatch.serialize(generator, mapper); + } + + if (this.nested != null) { + generator.writeKey("nested"); + this.nested.serialize(generator, mapper); + } + + if (this.parentId != null) { + generator.writeKey("parent_id"); + this.parentId.serialize(generator, mapper); + } + + if (this.percolate != null) { + generator.writeKey("percolate"); + this.percolate.serialize(generator, mapper); + } + + if (this.pinned != null) { + generator.writeKey("pinned"); + this.pinned.serialize(generator, mapper); + } + + if (ApiTypeHelper.isDefined(this.prefix)) { + generator.writeKey("prefix"); + generator.writeStartObject(); + for (Map.Entry item0 : this.prefix.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (this.queryString != null) { + generator.writeKey("query_string"); + this.queryString.serialize(generator, mapper); + } + + if (ApiTypeHelper.isDefined(this.range)) { + generator.writeKey("range"); + generator.writeStartObject(); + for (Map.Entry item0 : this.range.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (this.rankFeature != null) { + generator.writeKey("rank_feature"); + this.rankFeature.serialize(generator, mapper); + } + + if (ApiTypeHelper.isDefined(this.regexp)) { + generator.writeKey("regexp"); + generator.writeStartObject(); + for (Map.Entry item0 : this.regexp.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (this.script != null) { + generator.writeKey("script"); + this.script.serialize(generator, mapper); + } + + if (this.scriptScore != null) { + generator.writeKey("script_score"); + this.scriptScore.serialize(generator, mapper); + } + + if (this.shape != null) { + generator.writeKey("shape"); + this.shape.serialize(generator, mapper); + } + + if (this.simpleQueryString != null) { + generator.writeKey("simple_query_string"); + this.simpleQueryString.serialize(generator, mapper); + } + + if (this.spanContaining != null) { + generator.writeKey("span_containing"); + this.spanContaining.serialize(generator, mapper); + } + + if (this.spanFirst != null) { + generator.writeKey("span_first"); + this.spanFirst.serialize(generator, mapper); + } + + if (this.spanMulti != null) { + generator.writeKey("span_multi"); + this.spanMulti.serialize(generator, mapper); + } + + if (this.spanNear != null) { + generator.writeKey("span_near"); + this.spanNear.serialize(generator, mapper); + } + + if (this.spanNot != null) { + generator.writeKey("span_not"); + this.spanNot.serialize(generator, mapper); + } + + if (this.spanOr != null) { + generator.writeKey("span_or"); + this.spanOr.serialize(generator, mapper); + } + + if (ApiTypeHelper.isDefined(this.spanTerm)) { + generator.writeKey("span_term"); + generator.writeStartObject(); + for (Map.Entry item0 : this.spanTerm.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (this.spanWithin != null) { + generator.writeKey("span_within"); + this.spanWithin.serialize(generator, mapper); + } + + if (ApiTypeHelper.isDefined(this.term)) { + generator.writeKey("term"); + generator.writeStartObject(); + for (Map.Entry item0 : this.term.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (this.terms != null) { + generator.writeKey("terms"); + this.terms.serialize(generator, mapper); + } + + if (ApiTypeHelper.isDefined(this.termsSet)) { + generator.writeKey("terms_set"); + generator.writeStartObject(); + for (Map.Entry item0 : this.termsSet.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (ApiTypeHelper.isDefined(this.wildcard)) { + generator.writeKey("wildcard"); + generator.writeStartObject(); + for (Map.Entry item0 : this.wildcard.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (this.wrapper != null) { + generator.writeKey("wrapper"); + this.wrapper.serialize(generator, mapper); + } + } + + /** Builder for {@link UserDefinedObjectStructure}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private JsonData bool; + private JsonData boosting; + private JsonData combinedFields; + private JsonData constantScore; + private JsonData disMax; + private JsonData distanceFeature; + private JsonData exists; + private JsonData fieldMaskingSpan; + private JsonData functionScore; + private Map fuzzy; + private JsonData geoBoundingBox; + private JsonData geoDistance; + private JsonData geoPolygon; + private JsonData geoShape; + private JsonData hasChild; + private JsonData hasParent; + private JsonData ids; + private Map intervals; + private JsonData knn; + private Map match; + private JsonData matchAll; + private Map matchBoolPrefix; + private JsonData matchNone; + private Map matchPhrase; + private Map matchPhrasePrefix; + private JsonData moreLikeThis; + private JsonData multiMatch; + private JsonData nested; + private JsonData parentId; + private JsonData percolate; + private JsonData pinned; + private Map prefix; + private JsonData queryString; + private Map range; + private JsonData rankFeature; + private Map regexp; + private JsonData script; + private JsonData scriptScore; + private JsonData shape; + private JsonData simpleQueryString; + private JsonData spanContaining; + private JsonData spanFirst; + private JsonData spanMulti; + private JsonData spanNear; + private JsonData spanNot; + private JsonData spanOr; + private Map spanTerm; + private JsonData spanWithin; + private Map term; + private JsonData terms; + private Map termsSet; + private Map wildcard; + private JsonData wrapper; + + public final Builder bool(JsonData value) { + this.bool = value; + return this; + } + + public final Builder boosting(JsonData value) { + this.boosting = value; + return this; + } + + public final Builder combinedFields(JsonData value) { + this.combinedFields = value; + return this; + } + + public final Builder constantScore(JsonData value) { + this.constantScore = value; + return this; + } + + public final Builder disMax(JsonData value) { + this.disMax = value; + return this; + } + + public final Builder distanceFeature(JsonData value) { + this.distanceFeature = value; + return this; + } + + public final Builder exists(JsonData value) { + this.exists = value; + return this; + } + + public final Builder fieldMaskingSpan(JsonData value) { + this.fieldMaskingSpan = value; + return this; + } + + public final Builder functionScore(JsonData value) { + this.functionScore = value; + return this; + } + + public final Builder fuzzy(Map map) { + this.fuzzy = _mapPutAll(this.fuzzy, map); + return this; + } + + public final Builder fuzzy(String key, JsonData value) { + this.fuzzy = _mapPut(this.fuzzy, key, value); + return this; + } + + public final Builder geoBoundingBox(JsonData value) { + this.geoBoundingBox = value; + return this; + } + + public final Builder geoDistance(JsonData value) { + this.geoDistance = value; + return this; + } + + public final Builder geoPolygon(JsonData value) { + this.geoPolygon = value; + return this; + } + + public final Builder geoShape(JsonData value) { + this.geoShape = value; + return this; + } + + public final Builder hasChild(JsonData value) { + this.hasChild = value; + return this; + } + + public final Builder hasParent(JsonData value) { + this.hasParent = value; + return this; + } + + public final Builder ids(JsonData value) { + this.ids = value; + return this; + } + + public final Builder intervals(Map map) { + this.intervals = _mapPutAll(this.intervals, map); + return this; + } + + public final Builder intervals(String key, JsonData value) { + this.intervals = _mapPut(this.intervals, key, value); + return this; + } + + public final Builder knn(JsonData value) { + this.knn = value; + return this; + } + + public final Builder match(Map map) { + this.match = _mapPutAll(this.match, map); + return this; + } + + public final Builder match(String key, JsonData value) { + this.match = _mapPut(this.match, key, value); + return this; + } + + public final Builder matchAll(JsonData value) { + this.matchAll = value; + return this; + } + + public final Builder matchBoolPrefix(Map map) { + this.matchBoolPrefix = _mapPutAll(this.matchBoolPrefix, map); + return this; + } + + public final Builder matchBoolPrefix(String key, JsonData value) { + this.matchBoolPrefix = _mapPut(this.matchBoolPrefix, key, value); + return this; + } + + public final Builder matchNone(JsonData value) { + this.matchNone = value; + return this; + } + + public final Builder matchPhrase(Map map) { + this.matchPhrase = _mapPutAll(this.matchPhrase, map); + return this; + } + + public final Builder matchPhrase(String key, JsonData value) { + this.matchPhrase = _mapPut(this.matchPhrase, key, value); + return this; + } + + public final Builder matchPhrasePrefix(Map map) { + this.matchPhrasePrefix = _mapPutAll(this.matchPhrasePrefix, map); + return this; + } + + public final Builder matchPhrasePrefix(String key, JsonData value) { + this.matchPhrasePrefix = _mapPut(this.matchPhrasePrefix, key, value); + return this; + } + + public final Builder moreLikeThis(JsonData value) { + this.moreLikeThis = value; + return this; + } + + public final Builder multiMatch(JsonData value) { + this.multiMatch = value; + return this; + } + + public final Builder nested(JsonData value) { + this.nested = value; + return this; + } + + public final Builder parentId(JsonData value) { + this.parentId = value; + return this; + } + + public final Builder percolate(JsonData value) { + this.percolate = value; + return this; + } + + public final Builder pinned(JsonData value) { + this.pinned = value; + return this; + } + + public final Builder prefix(Map map) { + this.prefix = _mapPutAll(this.prefix, map); + return this; + } + + public final Builder prefix(String key, JsonData value) { + this.prefix = _mapPut(this.prefix, key, value); + return this; + } + + public final Builder queryString(JsonData value) { + this.queryString = value; + return this; + } + + public final Builder range(Map map) { + this.range = _mapPutAll(this.range, map); + return this; + } + + public final Builder range(String key, JsonData value) { + this.range = _mapPut(this.range, key, value); + return this; + } + + public final Builder rankFeature(JsonData value) { + this.rankFeature = value; + return this; + } + + public final Builder regexp(Map map) { + this.regexp = _mapPutAll(this.regexp, map); + return this; + } + + public final Builder regexp(String key, JsonData value) { + this.regexp = _mapPut(this.regexp, key, value); + return this; + } + + public final Builder script(JsonData value) { + this.script = value; + return this; + } + + public final Builder scriptScore(JsonData value) { + this.scriptScore = value; + return this; + } + + public final Builder shape(JsonData value) { + this.shape = value; + return this; + } + + public final Builder simpleQueryString(JsonData value) { + this.simpleQueryString = value; + return this; + } + + public final Builder spanContaining(JsonData value) { + this.spanContaining = value; + return this; + } + + public final Builder spanFirst(JsonData value) { + this.spanFirst = value; + return this; + } + + public final Builder spanMulti(JsonData value) { + this.spanMulti = value; + return this; + } + + public final Builder spanNear(JsonData value) { + this.spanNear = value; + return this; + } + + public final Builder spanNot(JsonData value) { + this.spanNot = value; + return this; + } + + public final Builder spanOr(JsonData value) { + this.spanOr = value; + return this; + } + + public final Builder spanTerm(Map map) { + this.spanTerm = _mapPutAll(this.spanTerm, map); + return this; + } + + public final Builder spanTerm(String key, JsonData value) { + this.spanTerm = _mapPut(this.spanTerm, key, value); + return this; + } + + public final Builder spanWithin(JsonData value) { + this.spanWithin = value; + return this; + } + + public final Builder term(Map map) { + this.term = _mapPutAll(this.term, map); + return this; + } + + public final Builder term(String key, JsonData value) { + this.term = _mapPut(this.term, key, value); + return this; + } + + public final Builder terms(JsonData value) { + this.terms = value; + return this; + } + + public final Builder termsSet(Map map) { + this.termsSet = _mapPutAll(this.termsSet, map); + return this; + } + + public final Builder termsSet(String key, JsonData value) { + this.termsSet = _mapPut(this.termsSet, key, value); + return this; + } + + public final Builder wildcard(Map map) { + this.wildcard = _mapPutAll(this.wildcard, map); + return this; + } + + public final Builder wildcard(String key, JsonData value) { + this.wildcard = _mapPut(this.wildcard, key, value); + return this; + } + + public final Builder wrapper(JsonData value) { + this.wrapper = value; + return this; + } + + /** + * Builds a {@link UserDefinedObjectStructure}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public UserDefinedObjectStructure build() { + _checkSingleUse(); + + return new UserDefinedObjectStructure(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, + UserDefinedObjectStructure::setupUserDefinedObjectStructureDeserializer); + + protected static void setupUserDefinedObjectStructureDeserializer( + ObjectDeserializer op) { + op.add(Builder::bool, JsonData._DESERIALIZER, "bool"); + op.add(Builder::boosting, JsonData._DESERIALIZER, "boosting"); + op.add(Builder::combinedFields, JsonData._DESERIALIZER, "combined_fields"); + op.add(Builder::constantScore, JsonData._DESERIALIZER, "constant_score"); + op.add(Builder::disMax, JsonData._DESERIALIZER, "dis_max"); + op.add(Builder::distanceFeature, JsonData._DESERIALIZER, "distance_feature"); + op.add(Builder::exists, JsonData._DESERIALIZER, "exists"); + op.add(Builder::fieldMaskingSpan, JsonData._DESERIALIZER, "field_masking_span"); + op.add(Builder::functionScore, JsonData._DESERIALIZER, "function_score"); + op.add( + Builder::fuzzy, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "fuzzy"); + op.add(Builder::geoBoundingBox, JsonData._DESERIALIZER, "geo_bounding_box"); + op.add(Builder::geoDistance, JsonData._DESERIALIZER, "geo_distance"); + op.add(Builder::geoPolygon, JsonData._DESERIALIZER, "geo_polygon"); + op.add(Builder::geoShape, JsonData._DESERIALIZER, "geo_shape"); + op.add(Builder::hasChild, JsonData._DESERIALIZER, "has_child"); + op.add(Builder::hasParent, JsonData._DESERIALIZER, "has_parent"); + op.add(Builder::ids, JsonData._DESERIALIZER, "ids"); + op.add( + Builder::intervals, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "intervals"); + op.add(Builder::knn, JsonData._DESERIALIZER, "knn"); + op.add( + Builder::match, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "match"); + op.add(Builder::matchAll, JsonData._DESERIALIZER, "match_all"); + op.add( + Builder::matchBoolPrefix, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "match_bool_prefix"); + op.add(Builder::matchNone, JsonData._DESERIALIZER, "match_none"); + op.add( + Builder::matchPhrase, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "match_phrase"); + op.add( + Builder::matchPhrasePrefix, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "match_phrase_prefix"); + op.add(Builder::moreLikeThis, JsonData._DESERIALIZER, "more_like_this"); + op.add(Builder::multiMatch, JsonData._DESERIALIZER, "multi_match"); + op.add(Builder::nested, JsonData._DESERIALIZER, "nested"); + op.add(Builder::parentId, JsonData._DESERIALIZER, "parent_id"); + op.add(Builder::percolate, JsonData._DESERIALIZER, "percolate"); + op.add(Builder::pinned, JsonData._DESERIALIZER, "pinned"); + op.add( + Builder::prefix, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "prefix"); + op.add(Builder::queryString, JsonData._DESERIALIZER, "query_string"); + op.add( + Builder::range, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "range"); + op.add(Builder::rankFeature, JsonData._DESERIALIZER, "rank_feature"); + op.add( + Builder::regexp, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "regexp"); + op.add(Builder::script, JsonData._DESERIALIZER, "script"); + op.add(Builder::scriptScore, JsonData._DESERIALIZER, "script_score"); + op.add(Builder::shape, JsonData._DESERIALIZER, "shape"); + op.add(Builder::simpleQueryString, JsonData._DESERIALIZER, "simple_query_string"); + op.add(Builder::spanContaining, JsonData._DESERIALIZER, "span_containing"); + op.add(Builder::spanFirst, JsonData._DESERIALIZER, "span_first"); + op.add(Builder::spanMulti, JsonData._DESERIALIZER, "span_multi"); + op.add(Builder::spanNear, JsonData._DESERIALIZER, "span_near"); + op.add(Builder::spanNot, JsonData._DESERIALIZER, "span_not"); + op.add(Builder::spanOr, JsonData._DESERIALIZER, "span_or"); + op.add( + Builder::spanTerm, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "span_term"); + op.add(Builder::spanWithin, JsonData._DESERIALIZER, "span_within"); + op.add( + Builder::term, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "term"); + op.add(Builder::terms, JsonData._DESERIALIZER, "terms"); + op.add( + Builder::termsSet, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "terms_set"); + op.add( + Builder::wildcard, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "wildcard"); + op.add(Builder::wrapper, JsonData._DESERIALIZER, "wrapper"); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedStructure.java b/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedStructure.java new file mode 100644 index 0000000000..ec238ea9d4 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedStructure.java @@ -0,0 +1,277 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class UserDefinedStructure implements JsonpSerializable { + private final String alias; + private final List aliases; + private final JsonData filter; + private final String index; + private final String indexRouting; + private final List indices; + private final boolean isHidden; + private final boolean isWriteIndex; + private final String mustExist; + private final String routing; + private final String searchRouting; + + public UserDefinedStructure(Builder builder) { + this.alias = builder.alias; + this.aliases = ApiTypeHelper.unmodifiable(builder.aliases); + this.filter = builder.filter; + this.index = builder.index; + this.indexRouting = builder.indexRouting; + this.indices = ApiTypeHelper.unmodifiable(builder.indices); + this.isHidden = builder.isHidden; + this.isWriteIndex = builder.isWriteIndex; + this.mustExist = builder.mustExist; + this.routing = builder.routing; + this.searchRouting = builder.searchRouting; + } + + public static UserDefinedStructure of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final String alias() { + return this.alias; + } + + public final List aliases() { + return this.aliases; + } + + public final JsonData filter() { + return this.filter; + } + + public final String index() { + return this.index; + } + + public final String indexRouting() { + return this.indexRouting; + } + + public final List indices() { + return this.indices; + } + + public final boolean isHidden() { + return this.isHidden; + } + + public final boolean isWriteIndex() { + return this.isWriteIndex; + } + + public final String mustExist() { + return this.mustExist; + } + + public final String routing() { + return this.routing; + } + + public final String searchRouting() { + return this.searchRouting; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.alias != null) { + generator.writeKey("alias"); + generator.write(this.alias); + } + + if (ApiTypeHelper.isDefined(this.aliases)) { + generator.writeKey("aliases"); + generator.writeStartArray(); + for (String item0 : this.aliases) { + generator.write(item0); + } + generator.writeEnd(); + } + + if (this.filter != null) { + generator.writeKey("filter"); + this.filter.serialize(generator, mapper); + } + + if (this.index != null) { + generator.writeKey("index"); + generator.write(this.index); + } + + if (this.indexRouting != null) { + generator.writeKey("index_routing"); + generator.write(this.indexRouting); + } + + if (ApiTypeHelper.isDefined(this.indices)) { + generator.writeKey("indices"); + generator.writeStartArray(); + for (String item0 : this.indices) { + generator.write(item0); + } + generator.writeEnd(); + } + + if (this.isHidden != null) { + generator.writeKey("is_hidden"); + generator.write(this.isHidden); + } + + if (this.isWriteIndex != null) { + generator.writeKey("is_write_index"); + generator.write(this.isWriteIndex); + } + + if (this.mustExist != null) { + generator.writeKey("must_exist"); + generator.write(this.mustExist); + } + + if (this.routing != null) { + generator.writeKey("routing"); + generator.write(this.routing); + } + + if (this.searchRouting != null) { + generator.writeKey("search_routing"); + generator.write(this.searchRouting); + } + } + + /** Builder for {@link UserDefinedStructure}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private String alias; + private List aliases; + private JsonData filter; + private String index; + private String indexRouting; + private List indices; + private boolean isHidden; + private boolean isWriteIndex; + private String mustExist; + private String routing; + private String searchRouting; + + public final Builder alias(String value) { + this.alias = value; + return this; + } + + public final Builder aliases(List list) { + this.aliases = _listAddAll(this.aliases, list); + return this; + } + + public final Builder aliases(String value, String... values) { + this.aliases = _listAdd(this.aliases, value, values); + return this; + } + + public final Builder filter(JsonData value) { + this.filter = value; + return this; + } + + public final Builder index(String value) { + this.index = value; + return this; + } + + public final Builder indexRouting(String value) { + this.indexRouting = value; + return this; + } + + public final Builder indices(List list) { + this.indices = _listAddAll(this.indices, list); + return this; + } + + public final Builder indices(String value, String... values) { + this.indices = _listAdd(this.indices, value, values); + return this; + } + + public final Builder isHidden(boolean value) { + this.isHidden = value; + return this; + } + + public final Builder isWriteIndex(boolean value) { + this.isWriteIndex = value; + return this; + } + + public final Builder mustExist(String value) { + this.mustExist = value; + return this; + } + + public final Builder routing(String value) { + this.routing = value; + return this; + } + + public final Builder searchRouting(String value) { + this.searchRouting = value; + return this; + } + + /** + * Builds a {@link UserDefinedStructure}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public UserDefinedStructure build() { + _checkSingleUse(); + + return new UserDefinedStructure(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, UserDefinedStructure::setupUserDefinedStructureDeserializer); + + protected static void setupUserDefinedStructureDeserializer( + ObjectDeserializer op) { + op.add(Builder::alias, JsonpDeserializer.stringDeserializer(), "alias"); + op.add( + Builder::aliases, + JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), + "aliases"); + op.add(Builder::filter, JsonData._DESERIALIZER, "filter"); + op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "index"); + op.add(Builder::indexRouting, JsonpDeserializer.stringDeserializer(), "index_routing"); + op.add( + Builder::indices, + JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), + "indices"); + op.add(Builder::isHidden, JsonpDeserializer.booleanDeserializer(), "is_hidden"); + op.add(Builder::isWriteIndex, JsonpDeserializer.booleanDeserializer(), "is_write_index"); + op.add(Builder::mustExist, JsonpDeserializer.stringDeserializer(), "must_exist"); + op.add(Builder::routing, JsonpDeserializer.stringDeserializer(), "routing"); + op.add(Builder::searchRouting, JsonpDeserializer.stringDeserializer(), "search_routing"); + } +} diff --git a/java-codegen/OpenSearch.openapi.json b/java-codegen/OpenSearch.openapi.json new file mode 100644 index 0000000000..975639dd2b --- /dev/null +++ b/java-codegen/OpenSearch.openapi.json @@ -0,0 +1,2844 @@ +{ + "openapi": "3.0.2", + "info": { + "title": "OpenSearch", + "version": "2021-11-23" + }, + "paths": { + "/": { + "get": { + "description": "Returns whether the cluster is running.", + "operationId": "GetClusterInfo", + "responses": { + "200": { + "description": "GetClusterInfo 200 response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetClusterInfoResponseContent" + } + } + } + } + } + } + }, + "/_aliases": { + "post": { + "description": "Adds or removes index aliases.", + "operationId": "PostAliases", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PostAliasesRequestContent" + }, + "examples": { + "PostAliases_example1": { + "summary": "Examples for Post Aliases Operation.", + "description": "", + "value": {} + } + } + } + } + }, + "parameters": [ + { + "name": "master_timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", + "deprecated": true + } + }, + { + "name": "cluster_manager_timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + } + }, + { + "name": "timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + } + } + ], + "responses": { + "200": { + "description": "PostAliases 200 response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PostAliasesResponseContent" + }, + "examples": { + "PostAliases_example1": { + "summary": "Examples for Post Aliases Operation.", + "description": "", + "value": { + "acknowledged": true + } + } + } + } + } + } + } + } + }, + "/_cat/indices": { + "get": { + "description": "Returns information about indices: number of primaries and replicas, document counts, disk size, etc.", + "operationId": "GetCatIndices", + "parameters": [ + { + "name": "master_timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", + "deprecated": true + } + }, + { + "name": "cluster_manager_timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + } + }, + { + "name": "bytes", + "in": "query", + "schema": { + "type": "integer" + } + }, + { + "name": "expand_wildcards", + "in": "query", + "schema": { + "$ref": "#/components/schemas/ExpandWildcards" + } + }, + { + "name": "health", + "in": "query", + "schema": { + "$ref": "#/components/schemas/HealthStatus" + } + }, + { + "name": "include_unloaded_segments", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "pri", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "time", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + } + }, + { + "name": "format", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "GetCatIndices 200 response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetCatIndicesOutputPayload" + } + } + } + } + } + } + }, + "/_cat/indices/{index}": { + "get": { + "description": "Returns information about indices: number of primaries and replicas, document counts, disk size, etc.", + "operationId": "GetCatIndicesWithIndex", + "parameters": [ + { + "name": "index", + "in": "path", + "schema": { + "type": "string", + "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" + }, + "required": true, + "examples": { + "GetCatIndicesWithIndex_example1": { + "summary": "Examples for Cat indices with Index Operation.", + "description": "", + "value": "books" + } + } + }, + { + "name": "master_timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", + "deprecated": true + } + }, + { + "name": "cluster_manager_timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + } + }, + { + "name": "bytes", + "in": "query", + "schema": { + "type": "integer" + } + }, + { + "name": "expand_wildcards", + "in": "query", + "schema": { + "$ref": "#/components/schemas/ExpandWildcards" + } + }, + { + "name": "health", + "in": "query", + "schema": { + "$ref": "#/components/schemas/HealthStatus" + } + }, + { + "name": "include_unloaded_segments", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "pri", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "time", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + } + }, + { + "name": "format", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "GetCatIndicesWithIndex 200 response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetCatIndicesWithIndexOutputPayload" + } + } + } + } + } + } + }, + "/_cat/nodes": { + "get": { + "description": "Returns basic statistics about performance of cluster nodes.", + "operationId": "GetCatNodes", + "parameters": [ + { + "name": "master_timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", + "deprecated": true + } + }, + { + "name": "cluster_manager_timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + } + }, + { + "name": "bytes", + "in": "query", + "schema": { + "type": "integer" + } + }, + { + "name": "full_id", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "local", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "time", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + } + }, + { + "name": "include_unloaded_segments", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "format", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "GetCatNodes 200 response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetCatNodesOutputPayload" + } + } + } + } + } + } + }, + "/_cluster/settings": { + "get": { + "description": "Returns cluster settings.", + "operationId": "GetClusterSettings", + "parameters": [ + { + "name": "master_timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", + "deprecated": true + } + }, + { + "name": "cluster_manager_timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + } + }, + { + "name": "flat_settings", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "include_defaults", + "in": "query", + "schema": { + "type": "boolean" + }, + "examples": { + "GetClusterSettings_example1": { + "summary": "Examples for Get cluster settings Operation.", + "description": "", + "value": true + } + } + } + ], + "responses": { + "200": { + "description": "GetClusterSettings 200 response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetClusterSettingsResponseContent" + }, + "examples": { + "GetClusterSettings_example1": { + "summary": "Examples for Get cluster settings Operation.", + "description": "", + "value": {} + } + } + } + } + } + } + }, + "put": { + "description": "Updates the cluster settings.", + "operationId": "PutUpdateClusterSettings", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PutUpdateClusterSettingsRequestContent" + } + } + } + }, + "parameters": [ + { + "name": "master_timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", + "deprecated": true + } + }, + { + "name": "cluster_manager_timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + } + }, + { + "name": "flat_settings", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + } + } + ], + "responses": { + "200": { + "description": "PutUpdateClusterSettings 200 response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PutUpdateClusterSettingsResponseContent" + } + } + } + } + } + } + }, + "/_remotestore/_restore": { + "post": { + "description": "Restore one or more indices from a remote backup.", + "operationId": "PostRemoteStoreRestore", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PostRemoteStoreRestoreRequestContent" + }, + "examples": { + "PostRemoteStoreRestore_example1": { + "summary": "Examples for Post Remote Storage Restore Operation.", + "description": "", + "value": { + "indices": [ + "books" + ] + } + } + } + } + }, + "required": true + }, + "parameters": [ + { + "name": "cluster_manager_timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + } + }, + { + "name": "wait_for_completion", + "in": "query", + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "description": "PostRemoteStoreRestore 200 response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PostRemoteStoreRestoreResponseContent" + }, + "examples": { + "PostRemoteStoreRestore_example1": { + "summary": "Examples for Post Remote Storage Restore Operation.", + "description": "", + "value": { + "remote_store": { + "indices": [ + "books" + ], + "shards": { + "total": 1, + "failed": 0, + "successful": 1 + } + } + } + } + } + } + } + } + } + } + }, + "/_search": { + "post": { + "description": "Returns results matching a query.", + "operationId": "PostSearch", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PostSearchRequestContent" + }, + "examples": { + "PostSearch_example1": { + "summary": "Examples for Post Search Operation.", + "description": "", + "value": { + "query": { + "match_all": {} + }, + "fields": [ + "*" + ] + } + } + } + } + } + }, + "parameters": [ + { + "name": "allow_no_indices", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "allow_partial_search_results", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "analyzer", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "analyze_wildcard", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "batched_reduce_size", + "in": "query", + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "ccs_minimize_roundtrips", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "default_operator", + "in": "query", + "schema": { + "$ref": "#/components/schemas/DefaultOperator" + } + }, + { + "name": "df", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "docvalue_fields", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "expand_wildcards", + "in": "query", + "schema": { + "$ref": "#/components/schemas/ExpandWildcards" + } + }, + { + "name": "explain", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "from", + "in": "query", + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "ignore_throttled", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "ignore_unavailable", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "lenient", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "max_concurrent_shard_requests", + "in": "query", + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "name": "pre_filter_shard_size", + "in": "query", + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "name": "preference", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "q", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "request_cache", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "rest_total_hits_as_int", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "routing", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "scroll", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + }, + "examples": { + "PostSearch_example1": { + "summary": "Examples for Post Search Operation.", + "description": "", + "value": "1d" + } + } + }, + { + "name": "search_type", + "in": "query", + "schema": { + "$ref": "#/components/schemas/SearchType" + } + }, + { + "name": "seq_no_primary_term", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "size", + "in": "query", + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "sort", + "in": "query", + "style": "form", + "schema": { + "type": "array", + "items": { + "type": "string" + } + }, + "explode": true + }, + { + "name": "source", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "source_excludes", + "in": "query", + "style": "form", + "schema": { + "type": "array", + "items": { + "type": "string" + } + }, + "explode": true + }, + { + "name": "source_includes", + "in": "query", + "style": "form", + "schema": { + "type": "array", + "items": { + "type": "string" + } + }, + "explode": true + }, + { + "name": "stats", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "stored_fields", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "suggest_field", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "suggest_mode", + "in": "query", + "schema": { + "$ref": "#/components/schemas/SuggestMode" + } + }, + { + "name": "suggest_size", + "in": "query", + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "name": "suggest_text", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "terminate_after", + "in": "query", + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + } + }, + { + "name": "track_scores", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "track_total_hits", + "in": "query", + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "typed_keys", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "version", + "in": "query", + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "description": "PostSearch 200 response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PostSearchResponseContent" + }, + "examples": { + "PostSearch_example1": { + "summary": "Examples for Post Search Operation.", + "description": "", + "value": { + "timed_out": false, + "_shards": { + "total": 1, + "successful": 1, + "skipped": 0, + "failed": 0 + }, + "hits": { + "total": { + "value": 0, + "relation": "eq" + }, + "hits": [] + } + } + } + } + } + } + } + } + } + }, + "/{index}": { + "delete": { + "description": "Removes a document from the index.", + "operationId": "DeleteIndex", + "parameters": [ + { + "name": "index", + "in": "path", + "schema": { + "type": "string", + "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" + }, + "required": true, + "examples": { + "DeleteIndex_example1": { + "summary": "Examples for Delete Index Operation.", + "description": "", + "value": "books" + } + } + }, + { + "name": "master_timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", + "deprecated": true + } + }, + { + "name": "cluster_manager_timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + } + }, + { + "name": "allow_no_indices", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "expand_wildcards", + "in": "query", + "schema": { + "$ref": "#/components/schemas/ExpandWildcards" + } + }, + { + "name": "ignore_unavailable", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + } + } + ], + "responses": { + "200": { + "description": "DeleteIndex 200 response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DeleteIndexResponseContent" + }, + "examples": { + "DeleteIndex_example1": { + "summary": "Examples for Delete Index Operation.", + "description": "", + "value": { + "acknowledged": true + } + } + } + } + } + } + } + }, + "put": { + "description": "Creates index mappings.", + "operationId": "PutCreateIndex", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PutCreateIndexRequestContent" + }, + "examples": { + "PutCreateIndex_example1": { + "summary": "Examples for Create Index Operation.", + "description": "", + "value": {} + } + } + } + } + }, + "parameters": [ + { + "name": "index", + "in": "path", + "schema": { + "type": "string", + "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" + }, + "required": true, + "examples": { + "PutCreateIndex_example1": { + "summary": "Examples for Create Index Operation.", + "description": "", + "value": "books" + } + } + }, + { + "name": "master_timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", + "deprecated": true + } + }, + { + "name": "cluster_manager_timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + } + }, + { + "name": "include_type_name", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "wait_for_active_shards", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + } + } + ], + "responses": { + "200": { + "description": "PutCreateIndex 200 response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PutCreateIndexResponseContent" + }, + "examples": { + "PutCreateIndex_example1": { + "summary": "Examples for Create Index Operation.", + "description": "", + "value": { + "index": "books", + "shards_acknowledged": true, + "acknowledged": true + } + } + } + } + } + } + } + } + }, + "/{index}/_doc/{id}": { + "get": { + "description": "Returns a document", + "operationId": "GetDocumentDoc", + "parameters": [ + { + "name": "index", + "in": "path", + "schema": { + "type": "string", + "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" + }, + "required": true, + "examples": { + "GetDocumentDoc_example1": { + "summary": "Examples for Get document doc Operation.", + "description": "", + "value": "books" + } + } + }, + { + "name": "id", + "in": "path", + "schema": { + "type": "string" + }, + "required": true, + "examples": { + "GetDocumentDoc_example1": { + "summary": "Examples for Get document doc Operation.", + "description": "", + "value": "1" + } + } + }, + { + "name": "preference", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "realtime", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "refresh", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "routing", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "stored_fields", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "_source", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "_source_excludes", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "_source_includes", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "query", + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "version_type", + "in": "query", + "schema": { + "$ref": "#/components/schemas/VersionType" + } + } + ], + "responses": { + "200": { + "description": "GetDocumentDoc 200 response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetDocumentDocResponseContent" + }, + "examples": { + "GetDocumentDoc_example1": { + "summary": "Examples for Get document doc Operation.", + "description": "", + "value": { + "_index": "books", + "_id": "1", + "found": true + } + } + } + } + } + } + } + } + }, + "/{index}/_mapping": { + "put": { + "description": "The put mapping API operation lets you add new mappings and fields to an index.", + "operationId": "PutIndexMappingWithIndex", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PutIndexMappingWithIndexRequestContent" + }, + "examples": { + "PutIndexMappingWithIndex_example1": { + "summary": "Examples for Put Index Mapping with index Operation.", + "description": "", + "value": {} + } + } + } + } + }, + "parameters": [ + { + "name": "index", + "in": "path", + "schema": { + "type": "string", + "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" + }, + "required": true, + "examples": { + "PutIndexMappingWithIndex_example1": { + "summary": "Examples for Put Index Mapping with index Operation.", + "description": "", + "value": "books" + } + } + }, + { + "name": "master_timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", + "deprecated": true + } + }, + { + "name": "cluster_manager_timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + } + }, + { + "name": "allow_no_indices", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "expand_wildcards", + "in": "query", + "schema": { + "$ref": "#/components/schemas/ExpandWildcards" + } + }, + { + "name": "ignore_unavailable", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "include_type_name", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + } + }, + { + "name": "write_index_only", + "in": "query", + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "description": "PutIndexMappingWithIndex 200 response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PutIndexMappingWithIndexResponseContent" + }, + "examples": { + "PutIndexMappingWithIndex_example1": { + "summary": "Examples for Put Index Mapping with index Operation.", + "description": "", + "value": { + "acknowledged": true + } + } + } + } + } + } + } + } + }, + "/{index}/_search": { + "post": { + "description": "Returns results matching a query.", + "operationId": "PostSearchWithIndex", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PostSearchWithIndexRequestContent" + }, + "examples": { + "PostSearchWithIndex_example1": { + "summary": "Examples for Post Search With Index Operation.", + "description": "", + "value": { + "query": { + "match_all": {} + }, + "fields": [ + "*" + ] + } + } + } + } + } + }, + "parameters": [ + { + "name": "index", + "in": "path", + "schema": { + "type": "string", + "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" + }, + "required": true, + "examples": { + "PostSearchWithIndex_example1": { + "summary": "Examples for Post Search With Index Operation.", + "description": "", + "value": "books" + } + } + }, + { + "name": "allow_no_indices", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "allow_partial_search_results", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "analyzer", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "analyze_wildcard", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "batched_reduce_size", + "in": "query", + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "ccs_minimize_roundtrips", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "default_operator", + "in": "query", + "schema": { + "$ref": "#/components/schemas/DefaultOperator" + } + }, + { + "name": "df", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "docvalue_fields", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "expand_wildcards", + "in": "query", + "schema": { + "$ref": "#/components/schemas/ExpandWildcards" + } + }, + { + "name": "explain", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "from", + "in": "query", + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "ignore_throttled", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "ignore_unavailable", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "lenient", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "max_concurrent_shard_requests", + "in": "query", + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "name": "pre_filter_shard_size", + "in": "query", + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "name": "preference", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "q", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "request_cache", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "rest_total_hits_as_int", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "routing", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "scroll", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + }, + "examples": { + "PostSearchWithIndex_example1": { + "summary": "Examples for Post Search With Index Operation.", + "description": "", + "value": "1d" + } + } + }, + { + "name": "search_type", + "in": "query", + "schema": { + "$ref": "#/components/schemas/SearchType" + } + }, + { + "name": "seq_no_primary_term", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "size", + "in": "query", + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "sort", + "in": "query", + "style": "form", + "schema": { + "type": "array", + "items": { + "type": "string" + } + }, + "explode": true + }, + { + "name": "source", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "source_excludes", + "in": "query", + "style": "form", + "schema": { + "type": "array", + "items": { + "type": "string" + } + }, + "explode": true + }, + { + "name": "source_includes", + "in": "query", + "style": "form", + "schema": { + "type": "array", + "items": { + "type": "string" + } + }, + "explode": true + }, + { + "name": "stats", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "stored_fields", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "suggest_field", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "suggest_mode", + "in": "query", + "schema": { + "$ref": "#/components/schemas/SuggestMode" + } + }, + { + "name": "suggest_size", + "in": "query", + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "name": "suggest_text", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "terminate_after", + "in": "query", + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + } + }, + { + "name": "track_scores", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "track_total_hits", + "in": "query", + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "typed_keys", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "version", + "in": "query", + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "description": "PostSearchWithIndex 200 response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PostSearchWithIndexResponseContent" + }, + "examples": { + "PostSearchWithIndex_example1": { + "summary": "Examples for Post Search With Index Operation.", + "description": "", + "value": { + "timed_out": false, + "_shards": { + "total": 1, + "successful": 1, + "skipped": 0, + "failed": 0 + }, + "hits": { + "total": { + "value": 0, + "relation": "eq" + }, + "hits": [] + } + } + } + } + } + } + } + } + } + }, + "/{index}/_settings": { + "get": { + "description": "The get settings API operation returns all the settings in your index.", + "operationId": "GetSettingsIndex", + "parameters": [ + { + "name": "index", + "in": "path", + "schema": { + "type": "string", + "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" + }, + "required": true, + "examples": { + "GetSettingsIndex_example1": { + "summary": "Examples for Get settings Index Operation.", + "description": "", + "value": "books" + } + } + }, + { + "name": "master_timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", + "deprecated": true + } + }, + { + "name": "cluster_manager_timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + } + }, + { + "name": "allow_no_indices", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "expand_wildcards", + "in": "query", + "schema": { + "$ref": "#/components/schemas/ExpandWildcards" + } + }, + { + "name": "flat_settings", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "include_defaults", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "ignore_unavailable", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "local", + "in": "query", + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "description": "GetSettingsIndex 200 response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetSettingsIndexOutputPayload" + } + } + } + } + } + } + }, + "/{index}/_settings/{setting}": { + "get": { + "description": "The get settings API operation returns all the settings in your index.", + "operationId": "GetSettingsIndexSetting", + "parameters": [ + { + "name": "index", + "in": "path", + "schema": { + "type": "string", + "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" + }, + "required": true, + "examples": { + "GetSettingsIndexSetting_example1": { + "summary": "Examples for Get settings Index-setting Operation.", + "description": "", + "value": "books" + } + } + }, + { + "name": "setting", + "in": "path", + "schema": { + "type": "string" + }, + "required": true, + "examples": { + "GetSettingsIndexSetting_example1": { + "summary": "Examples for Get settings Index-setting Operation.", + "description": "", + "value": "index" + } + } + }, + { + "name": "master_timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", + "deprecated": true + } + }, + { + "name": "cluster_manager_timeout", + "in": "query", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + } + }, + { + "name": "allow_no_indices", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "expand_wildcards", + "in": "query", + "schema": { + "$ref": "#/components/schemas/ExpandWildcards" + } + }, + { + "name": "flat_settings", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "include_defaults", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "ignore_unavailable", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "local", + "in": "query", + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "description": "GetSettingsIndexSetting 200 response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetSettingsIndexSettingOutputPayload" + } + } + } + } + } + } + }, + "/{index}/_source/{id}": { + "get": { + "description": "Returns a document.", + "operationId": "GetDocumentSource", + "parameters": [ + { + "name": "index", + "in": "path", + "schema": { + "type": "string", + "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" + }, + "required": true, + "examples": { + "GetDocumentSource_example1": { + "summary": "Examples for Get document source Operation.", + "description": "", + "value": "books" + } + } + }, + { + "name": "id", + "in": "path", + "schema": { + "type": "string" + }, + "required": true, + "examples": { + "GetDocumentSource_example1": { + "summary": "Examples for Get document source Operation.", + "description": "", + "value": "1" + } + } + }, + { + "name": "preference", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "realtime", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "refresh", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "routing", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "stored_fields", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "_source", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "_source_excludes", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "_source_includes", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "query", + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "version_type", + "in": "query", + "schema": { + "$ref": "#/components/schemas/VersionType" + } + } + ], + "responses": { + "200": { + "description": "GetDocumentSource 200 response" + } + } + } + } + }, + "components": { + "schemas": { + "ActionObjectStructure": { + "type": "object", + "properties": { + "add": { + "$ref": "#/components/schemas/UserDefinedStructure" + }, + "remove": { + "$ref": "#/components/schemas/UserDefinedStructure" + }, + "remove_index": { + "$ref": "#/components/schemas/UserDefinedStructure" + } + } + }, + "DefaultOperator": { + "type": "string", + "enum": [ + "AND", + "OR" + ] + }, + "DeleteIndexResponseContent": { + "type": "object", + "properties": { + "acknowledged": { + "type": "boolean" + } + } + }, + "ExpandWildcards": { + "type": "string", + "enum": [ + "all", + "open", + "closed", + "hidden", + "none" + ] + }, + "GetCatIndicesOutputPayload": {}, + "GetCatIndicesWithIndexOutputPayload": {}, + "GetCatNodesOutputPayload": {}, + "GetClusterInfoResponseContent": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "cluster_name": { + "type": "string" + }, + "cluster_uuid": { + "type": "string" + }, + "version": { + "$ref": "#/components/schemas/Version" + }, + "tagline": { + "type": "string" + } + } + }, + "GetClusterSettingsResponseContent": { + "type": "object", + "properties": { + "persistent": { + "$ref": "#/components/schemas/UserDefinedValueMap" + }, + "transient": { + "$ref": "#/components/schemas/UserDefinedValueMap" + }, + "defaults": { + "$ref": "#/components/schemas/UserDefinedValueMap" + } + } + }, + "GetDocumentDocResponseContent": { + "type": "object", + "properties": { + "_index": { + "type": "string", + "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" + }, + "_type": { + "type": "string" + }, + "_id": { + "type": "string" + }, + "version": { + "type": "integer", + "format": "int32" + }, + "seq_no": { + "type": "integer", + "format": "int64" + }, + "primary_term": { + "type": "integer", + "format": "int64" + }, + "found": { + "type": "boolean" + }, + "_routing": { + "type": "string" + }, + "_source": { + "$ref": "#/components/schemas/UserDefinedValueMap" + }, + "_fields": { + "$ref": "#/components/schemas/UserDefinedValueMap" + } + }, + "required": [ + "_id", + "_index", + "found" + ] + }, + "GetSettingsIndexOutputPayload": {}, + "GetSettingsIndexSettingOutputPayload": {}, + "HealthStatus": { + "type": "string", + "enum": [ + "green", + "yellow", + "red" + ] + }, + "Hits": { + "type": "object", + "properties": { + "_index": { + "type": "string" + }, + "_type": { + "type": "string" + }, + "_id": { + "type": "string" + }, + "_score": { + "type": "number", + "format": "float" + }, + "_source": {}, + "fields": {} + } + }, + "HitsMetadata": { + "type": "object", + "properties": { + "total": { + "$ref": "#/components/schemas/Total" + }, + "max_score": { + "type": "number", + "format": "double" + }, + "hits": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Hits" + } + } + } + }, + "PostAliasesRequestContent": { + "type": "object", + "properties": { + "actions": { + "$ref": "#/components/schemas/ActionObjectStructure" + } + } + }, + "PostAliasesResponseContent": { + "type": "object", + "properties": { + "acknowledged": { + "type": "boolean" + } + }, + "required": [ + "acknowledged" + ] + }, + "PostRemoteStoreRestoreRequestContent": { + "type": "object", + "properties": { + "indices": { + "type": "array", + "items": { + "type": "string", + "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" + } + } + }, + "required": [ + "indices" + ] + }, + "PostRemoteStoreRestoreResponseContent": { + "type": "object", + "properties": { + "accepted": { + "type": "boolean" + }, + "remote_store": { + "$ref": "#/components/schemas/RemoteStoreRestoreInfo" + } + } + }, + "PostSearchRequestContent": { + "type": "object", + "properties": { + "docvalue_fields": { + "type": "string" + }, + "explain": { + "type": "boolean" + }, + "from": { + "type": "integer", + "format": "int32" + }, + "seq_no_primary_term": { + "type": "boolean" + }, + "size": { + "type": "integer", + "format": "int32" + }, + "source": { + "type": "string" + }, + "stats": { + "type": "string" + }, + "terminate_after": { + "type": "integer", + "format": "int32" + }, + "timeout": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + }, + "version": { + "type": "boolean" + }, + "fields": { + "type": "array", + "items": { + "type": "string" + } + }, + "min_score": { + "type": "integer", + "format": "int32" + }, + "indices_boost": { + "type": "array", + "items": {} + }, + "query": { + "$ref": "#/components/schemas/UserDefinedObjectStructure" + } + } + }, + "PostSearchResponseContent": { + "type": "object", + "properties": { + "_scroll_id": { + "type": "string" + }, + "took": { + "type": "integer", + "format": "int64" + }, + "timed_out": { + "type": "boolean" + }, + "_shards": { + "$ref": "#/components/schemas/ShardStatistics" + }, + "hits": { + "$ref": "#/components/schemas/HitsMetadata" + } + } + }, + "PostSearchWithIndexRequestContent": { + "type": "object", + "properties": { + "docvalue_fields": { + "type": "string" + }, + "explain": { + "type": "boolean" + }, + "from": { + "type": "integer", + "format": "int32" + }, + "seq_no_primary_term": { + "type": "boolean" + }, + "size": { + "type": "integer", + "format": "int32" + }, + "source": { + "type": "string" + }, + "stats": { + "type": "string" + }, + "terminate_after": { + "type": "integer", + "format": "int32" + }, + "timeout": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" + }, + "version": { + "type": "boolean" + }, + "fields": { + "type": "array", + "items": { + "type": "string" + } + }, + "min_score": { + "type": "integer", + "format": "int32" + }, + "indices_boost": { + "type": "array", + "items": {} + }, + "query": { + "$ref": "#/components/schemas/UserDefinedObjectStructure" + } + } + }, + "PostSearchWithIndexResponseContent": { + "type": "object", + "properties": { + "_scroll_id": { + "type": "string" + }, + "took": { + "type": "integer", + "format": "int64" + }, + "timed_out": { + "type": "boolean" + }, + "_shards": { + "$ref": "#/components/schemas/ShardStatistics" + }, + "hits": { + "$ref": "#/components/schemas/HitsMetadata" + } + } + }, + "PutCreateIndexRequestContent": { + "type": "object", + "properties": { + "aliases": { + "$ref": "#/components/schemas/UserDefinedValueMap" + }, + "mapping": { + "$ref": "#/components/schemas/UserDefinedValueMap" + }, + "settings": { + "$ref": "#/components/schemas/UserDefinedValueMap" + } + } + }, + "PutCreateIndexResponseContent": { + "type": "object", + "properties": { + "index": { + "type": "string", + "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" + }, + "shards_acknowledged": { + "type": "boolean" + }, + "acknowledged": { + "type": "boolean" + } + }, + "required": [ + "acknowledged", + "index", + "shards_acknowledged" + ] + }, + "PutIndexMappingWithIndexRequestContent": { + "type": "object", + "properties": { + "properties": {} + } + }, + "PutIndexMappingWithIndexResponseContent": { + "type": "object", + "properties": { + "acknowledged": { + "type": "boolean" + } + } + }, + "PutUpdateClusterSettingsRequestContent": { + "type": "object", + "properties": { + "persistent": { + "$ref": "#/components/schemas/UserDefinedValueMap" + }, + "transient": { + "$ref": "#/components/schemas/UserDefinedValueMap" + } + } + }, + "PutUpdateClusterSettingsResponseContent": { + "type": "object", + "properties": { + "acknowledged": { + "type": "boolean" + }, + "persistent": { + "$ref": "#/components/schemas/UserDefinedValueMap" + }, + "transient": { + "$ref": "#/components/schemas/UserDefinedValueMap" + } + } + }, + "Relation": { + "type": "string", + "enum": [ + "eq", + "gte" + ] + }, + "RemoteStoreRestoreInfo": { + "type": "object", + "properties": { + "snapshot": { + "type": "string" + }, + "indices": { + "type": "array", + "items": { + "type": "string", + "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" + } + }, + "shards": { + "$ref": "#/components/schemas/RemoteStoreRestoreShardsInfo" + } + } + }, + "RemoteStoreRestoreShardsInfo": { + "type": "object", + "properties": { + "total": { + "type": "integer", + "format": "int32" + }, + "failed": { + "type": "integer", + "format": "int32" + }, + "successful": { + "type": "integer", + "format": "int32" + } + } + }, + "SearchType": { + "type": "string", + "enum": [ + "0", + "1" + ] + }, + "ShardStatistics": { + "type": "object", + "properties": { + "total": { + "type": "integer", + "format": "int32" + }, + "successful": { + "type": "integer", + "format": "int32" + }, + "skipped": { + "type": "integer", + "format": "int32" + }, + "failed": { + "type": "integer", + "format": "int32" + } + } + }, + "SuggestMode": { + "type": "string", + "enum": [ + "0", + "1", + "2" + ] + }, + "Total": { + "type": "object", + "properties": { + "value": { + "type": "integer", + "format": "int32" + }, + "relation": { + "$ref": "#/components/schemas/Relation" + } + } + }, + "UserDefinedObjectStructure": { + "type": "object", + "properties": { + "bool": {}, + "boosting": {}, + "combined_fields": {}, + "constant_score": {}, + "dis_max": {}, + "distance_feature": {}, + "exists": {}, + "function_score": {}, + "fuzzy": { + "$ref": "#/components/schemas/UserDefinedValueMap" + }, + "geo_bounding_box": {}, + "geo_distance": {}, + "geo_polygon": {}, + "geo_shape": {}, + "has_child": {}, + "has_parent": {}, + "ids": {}, + "intervals": { + "$ref": "#/components/schemas/UserDefinedValueMap" + }, + "knn": {}, + "match": { + "$ref": "#/components/schemas/UserDefinedValueMap" + }, + "match_all": {}, + "match_bool_prefix": { + "$ref": "#/components/schemas/UserDefinedValueMap" + }, + "match_none": {}, + "match_phrase": { + "$ref": "#/components/schemas/UserDefinedValueMap" + }, + "match_phrase_prefix": { + "$ref": "#/components/schemas/UserDefinedValueMap" + }, + "more_like_this": {}, + "multi_match": {}, + "nested": {}, + "parent_id": {}, + "percolate": {}, + "pinned": {}, + "prefix": { + "$ref": "#/components/schemas/UserDefinedValueMap" + }, + "query_string": {}, + "range": { + "$ref": "#/components/schemas/UserDefinedValueMap" + }, + "rank_feature": {}, + "regexp": { + "$ref": "#/components/schemas/UserDefinedValueMap" + }, + "script": {}, + "script_score": {}, + "shape": {}, + "simple_query_string": {}, + "span_containing": {}, + "field_masking_span": {}, + "span_first": {}, + "span_multi": {}, + "span_near": {}, + "span_not": {}, + "span_or": {}, + "span_term": { + "$ref": "#/components/schemas/UserDefinedValueMap" + }, + "span_within": {}, + "term": { + "$ref": "#/components/schemas/UserDefinedValueMap" + }, + "terms": {}, + "terms_set": { + "$ref": "#/components/schemas/UserDefinedValueMap" + }, + "wildcard": { + "$ref": "#/components/schemas/UserDefinedValueMap" + }, + "wrapper": {} + } + }, + "UserDefinedStructure": { + "type": "object", + "properties": { + "alias": { + "type": "string" + }, + "aliases": { + "type": "array", + "items": { + "type": "string" + } + }, + "filter": {}, + "index": { + "type": "string" + }, + "indices": { + "type": "array", + "items": { + "type": "string" + } + }, + "index_routing": { + "type": "string" + }, + "is_hidden": { + "type": "boolean" + }, + "is_write_index": { + "type": "boolean" + }, + "must_exist": { + "type": "string" + }, + "routing": { + "type": "string" + }, + "search_routing": { + "type": "string" + } + } + }, + "UserDefinedValueMap": { + "type": "object", + "additionalProperties": {} + }, + "Version": { + "type": "object", + "properties": { + "distribution": { + "type": "string" + }, + "number": { + "type": "string" + }, + "build_type": { + "type": "string" + }, + "build_hash": { + "type": "string" + }, + "build_date": { + "type": "string" + }, + "build_snapshot": { + "type": "boolean" + }, + "lucene_version": { + "type": "string" + }, + "minimum_wire_compatibility_version": { + "type": "string" + }, + "minimum_index_compatibility_version": { + "type": "string" + } + } + }, + "VersionType": { + "type": "string", + "enum": [ + "internal", + "external", + "external_gte" + ] + } + }, + "securitySchemes": { + "smithy.api.httpBasicAuth": { + "type": "http", + "description": "HTTP Basic authentication", + "scheme": "Basic" + } + } + }, + "security": [ + { + "smithy.api.httpBasicAuth": [] + } + ] +} diff --git a/java-codegen/build.gradle.kts b/java-codegen/build.gradle.kts index fdc0380c24..1b46b81894 100644 --- a/java-codegen/build.gradle.kts +++ b/java-codegen/build.gradle.kts @@ -28,8 +28,7 @@ buildscript { } plugins { - java - `java-library` + application checkstyle `maven-publish` id("com.github.jk1.dependency-license-report") version "1.19" @@ -48,6 +47,24 @@ java { withSourcesJar() } +application { + mainClass.set("org.opensearch.client.codegen.Main") + applicationDefaultJvmArgs = listOf( + "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED" + ) +} + +tasks.named("run") { + args = listOf( + "${projectDir}/OpenSearch.openapi.json", + "${project(":java-client").projectDir}/src/generated/java/" + ) +} + tasks.withType { expand( "version" to version, @@ -104,7 +121,7 @@ dependencies { // Apache 2.0 // https://search.maven.org/artifact/com.google.code.findbugs/jsr305 - api("com.google.code.findbugs:jsr305:3.0.2") + implementation("com.google.code.findbugs:jsr305:3.0.2") // Eclipse 1.0 testImplementation("junit", "junit" , "4.13.2") { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java b/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java index 181b193854..7db22bbbdb 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java @@ -4,32 +4,35 @@ import org.openapi4j.core.exception.ResolutionException; import org.openapi4j.core.model.OAIContext; import org.openapi4j.core.model.reference.Reference; +import org.openapi4j.core.model.v3.OAI3SchemaKeywords; import org.openapi4j.core.validation.ValidationException; import org.openapi4j.parser.OpenApi3Parser; import org.openapi4j.parser.model.AbsRefOpenApiSchema; import org.openapi4j.parser.model.v3.*; import org.opensearch.client.codegen.exceptions.ApiSpecificationParseException; import org.opensearch.client.codegen.model.Field; +import org.opensearch.client.codegen.model.ObjectShape; import org.opensearch.client.codegen.model.OperationRequest; import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Stream; public class ApiSpecification { private final OpenApi3 api; private final OAIContext context; + private final Set visitedReferencedSchemas; private final List operationRequests; + private final List objectShapes; private final TypeMapper typeMapper; private ApiSpecification(OpenApi3 api) throws ApiSpecificationParseException { this.api = api; context = api.getContext(); + visitedReferencedSchemas = new HashSet<>(); operationRequests = new ArrayList<>(); - typeMapper = new TypeMapper(this.api); + objectShapes = new ArrayList<>(); + typeMapper = new TypeMapper(this.api, this::visitReferencedSchema); visit(this.api); } @@ -46,6 +49,8 @@ public List getOperationRequests() { return Collections.unmodifiableList(operationRequests); } + public List getObjectShapes() { return Collections.unmodifiableList(objectShapes); } + private void visit(OpenApi3 api) throws ApiSpecificationParseException { for (Map.Entry entry : api.getPaths().entrySet()) { String httpPath = entry.getKey(); @@ -86,6 +91,25 @@ private void visit(String httpPath, Path path, String httpMethod, Operation oper operationRequests.add(operationRequest); } + private void visitReferencedSchema(String ref, Schema schema) { + if (!visitedReferencedSchemas.add(ref)) return; + + String[] refParts = ref.split("/"); + String name = refParts[refParts.length - 1]; + + if (OAI3SchemaKeywords.TYPE_OBJECT.equals(schema.getType())) { + ObjectShape shape = new ObjectShape(); + + shape.name = name; + + for (Map.Entry entry : schema.getProperties().entrySet()) { + shape.addField(new Field(entry.getKey(), typeMapper.mapType(entry.getValue()))); + } + + objectShapes.add(shape); + } + } + private RequestBody resolve(RequestBody body) throws ApiSpecificationParseException { return resolve(body, RequestBody.class); } @@ -96,11 +120,11 @@ private Schema resolve(Schema schema) throws ApiSpecificationParseException { private > S resolve(S schema, Class clazz) throws ApiSpecificationParseException { while (schema != null && schema.isRef()) { - Reference ref = schema.getReference(api.getContext()); + Reference ref = schema.getReference(context); try { schema = ref.getMappedContent(clazz); } catch (DecodeException e) { - throw new ApiSpecificationParseException("Failed to decode reference as " + schema.getClass() + ": " + ref, e); + throw new ApiSpecificationParseException("Failed to decode reference as " + clazz + ": " + ref, e); } } return schema; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java b/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java index 668284ac2e..322cf6cdb0 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java @@ -2,19 +2,48 @@ import org.opensearch.client.codegen.exceptions.ApiSpecificationParseException; import org.opensearch.client.codegen.exceptions.RenderException; +import org.opensearch.client.codegen.model.ObjectShape; +import org.opensearch.client.codegen.model.OperationRequest; import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Comparator; +import java.util.stream.Stream; public class Generator { private final ApiSpecification apiSpecification; private final Renderer renderer; + private final File outputDir; + private final File packageDir; - public Generator(File schemaFile) throws ApiSpecificationParseException { + public Generator(File schemaFile, File outputDir) throws ApiSpecificationParseException { apiSpecification = ApiSpecification.parse(schemaFile); renderer = new Renderer(); + this.outputDir = outputDir; + packageDir = new File(outputDir, "org/opensearch/client/opensearch/"); } public void generate() throws RenderException { - renderer.render(apiSpecification.getOperationRequests().get(12)); + try (Stream walker = Files.walk(outputDir.toPath())) { + walker.sorted(Comparator.reverseOrder()) + .map(Path::toFile) + .forEach(File::delete); + } catch (IOException e) { + throw new RenderException("Unable to cleanup output directory: " + outputDir, e); + } + + packageDir.mkdirs(); + + for (OperationRequest operationRequest : apiSpecification.getOperationRequests()) { + File file = new File(packageDir, operationRequest.className() + ".java"); + renderer.render(operationRequest, file); + } + + for (ObjectShape objectShape : apiSpecification.getObjectShapes()) { + File file = new File(packageDir, objectShape.className() + ".java"); + renderer.render(objectShape, file); + } } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/Main.java b/java-codegen/src/main/java/org/opensearch/client/codegen/Main.java index 66bf6351e0..9510d2ca4f 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/Main.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/Main.java @@ -4,8 +4,18 @@ public class Main { public static void main(String[] args) { + if (args.length < 2) { + System.err.println("Usage: Main.class {specFile} {outputDir}"); + System.exit(1); + return; + } + try { - Generator generator = new Generator(new File(args[0])); + File specFile = new File(args[0]); + File outputDir = new File(args[1]); + System.out.println("Spec File: " + specFile); + System.out.println("Output Dir: " + outputDir); + Generator generator = new Generator(specFile, outputDir); generator.generate(); } catch (Throwable e) { e.printStackTrace(System.err); diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java b/java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java index f9082a46a2..bd641a27cf 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java @@ -9,10 +9,7 @@ import org.apache.commons.text.StringEscapeUtils; import org.opensearch.client.codegen.exceptions.RenderException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.StringWriter; -import java.io.Writer; +import java.io.*; import java.util.HashMap; import java.util.Map; import java.util.MissingResourceException; @@ -40,7 +37,7 @@ public Renderer() { .build()); } - public void render(T object) throws RenderException { + public String render(T object) throws RenderException { try { Template template = compiler.loadTemplate(object.getClass().getSimpleName()); Writer writer = new StringWriter(); @@ -48,11 +45,20 @@ public void render(T object) throws RenderException { template.execute(object, lambdas, writer); String output = writer.toString(); - output = true ? formatter.formatSource(output) : output; + output = formatter.formatSource(output); - System.out.println(output); + return output; } catch (MustacheException | FormatterException e) { throw new RenderException("Failed to render: " + object, e); } } + + public void render(T object, File outputFile) throws RenderException { + String output = render(object); + try (Writer writer = new FileWriter(outputFile)) { + writer.write(output); + } catch (IOException e) { + throw new RenderException("Unable to write rendered output to: " + outputFile, e); + } + } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java b/java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java index d950c7ca7c..f205503678 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java @@ -8,13 +8,16 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.function.BiConsumer; public class TypeMapper { private final OpenApi3 api; private final Map cache = new ConcurrentHashMap<>(); + private final BiConsumer referencedSchemaVisitor; - public TypeMapper(OpenApi3 api) { + public TypeMapper(OpenApi3 api, BiConsumer referencedSchemaVisitor) { this.api = api; + this.referencedSchemaVisitor = referencedSchemaVisitor; } public Type mapType(Schema schema) { @@ -22,7 +25,11 @@ public Type mapType(Schema schema) { } public Type mapType(Schema schema, boolean boxed) { - Type type = cache.computeIfAbsent(schema, this::mapTypeInner); + Type type = cache.get(schema); + if (type == null) { + type = mapTypeInner(schema); + cache.put(schema, type); + } return boxed ? type.boxed() : type; } @@ -38,7 +45,11 @@ private Type mapTypeInner(Schema schema) { return new Type(target, "Map", "String", "JsonData"); } - String[] refParts = schema.getRef().split("/"); + String ref = schema.getRef(); + + referencedSchemaVisitor.accept(ref, target); + + String[] refParts = ref.split("/"); return new Type(target, refParts[refParts.length - 1]); } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java new file mode 100644 index 0000000000..328d8d92ac --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java @@ -0,0 +1,22 @@ +package org.opensearch.client.codegen.model; + +import java.util.Collection; +import java.util.Map; +import java.util.TreeMap; + +public class ObjectShape { + public String name; + private final Map fields = new TreeMap<>(); + + public void addField(Field field) { + fields.put(field.wireName, field); + } + + public String className() { + return name; + } + + public Collection fields() { + return fields.values(); + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/OperationRequest.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/OperationRequest.java index f668c68701..241f2505f2 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/OperationRequest.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/OperationRequest.java @@ -1,17 +1,15 @@ package org.opensearch.client.codegen.model; import java.util.*; -import java.util.stream.Collectors; -import java.util.stream.Stream; public class OperationRequest { public String operationId; public String description; public String httpMethod; public String httpPath; - private Map bodyFields = new TreeMap<>(); - private Map queryParams = new TreeMap<>(); - private Map fields = new TreeMap<>(); + private final Map bodyFields = new TreeMap<>(); + private final Map queryParams = new TreeMap<>(); + private final Map fields = new TreeMap<>(); public String className() { return operationId + "Request"; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java index 1e7efb8158..49fa12cc34 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java @@ -106,7 +106,7 @@ public Type listValueType() { public boolean isPrimitive() { return PRIMITIVES.contains(name); } - public boolean isBuiltIn() { return isListOrMap() || isPrimitive(); } + public boolean isBuiltIn() { return isListOrMap() || isPrimitive() || "JsonData".equals(name); } public Type builderType() { if (isBuiltIn()) return null; diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache new file mode 100644 index 0000000000..0ba3f7f276 --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache @@ -0,0 +1,129 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class {{className}} implements JsonpSerializable { + {{#fields}} + private final {{{type}}} {{name}}; + {{/fields}} + + public {{className}}(Builder builder) { + {{#fields}} + {{#type.isListOrMap}} + this.{{name}} = ApiTypeHelper.unmodifiable(builder.{{name}}); + {{/type.isListOrMap}} + {{^type.isListOrMap}} + this.{{name}} = builder.{{name}}; + {{/type.isListOrMap}} + {{/fields}} + } + + public static {{className}} of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + {{#fields}} + public final {{{type}}} {{name}}() { + return this.{{name}}; + } + + {{/fields}} + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + {{#fields}} + if ({{#type.isDefined}}this.{{name}}{{/type.isDefined}}) { + generator.writeKey({{#dq}}{{wireName}}{{/dq}}); + {{#type.serializer}}this.{{name}}{{/type.serializer}} + } + + {{/fields}} + } + + /** + * Builder for {@link {{className}}}. + */ + public static class Builder extends ObjectBuilderBase implements ObjectBuilder<{{className}}> { + {{#fields}} + private {{{type}}} {{name}}; + {{/fields}} + + {{#fields}} + {{#type.isMap}} + public final Builder {{name}}({{{type}}} map) { + this.{{name}} = _mapPutAll(this.{{name}}, map); + return this; + } + + public final Builder {{name}}({{{type.mapKeyType}}} key, {{{type.mapValueType}}} value) { + this.{{name}} = _mapPut(this.{{name}}, key, value); + return this; + } + {{/type.isMap}} + {{#type.isList}} + public final Builder {{name}}({{{type}}} list) { + this.{{name}} = _listAddAll(this.{{name}}, list); + return this; + } + + public final Builder {{name}}({{{type.listValueType}}} value, {{{type.listValueType}}}... values) { + this.{{name}} = _listAdd(this.{{name}}, value, values); + return this; + } + {{^type.listValueType.isBuiltIn}} + + public final Builder {{name}}({{{type.listValueType.builderFuncType}}} fn) { + return {{name}}(fn.apply(new {{{type.listValueType.builderType}}}()).build()); + } + {{/type.listValueType.isBuiltIn}} + {{/type.isList}} + {{^type.isListOrMap}} + public final Builder {{name}}({{{type}}} value) { + this.{{name}} = value; + return this; + } + {{^type.isBuiltIn}} + + public final Builder {{name}}({{{type.builderFuncType}}} fn) { + return {{name}}(fn.apply(new {{{type.builderType}}}()).build()); + } + {{/type.isBuiltIn}} + {{/type.isListOrMap}} + + {{/fields}} + /** + * Builds a {@link {{className}}}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public {{className}} build() { + _checkSingleUse(); + + return new {{className}}(this); + } + } + + public static final JsonpDeserializer<{{className}}> _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, {{className}}::setup{{className}}Deserializer); + + protected static void setup{{className}}Deserializer( + ObjectDeserializer<{{className}}.Builder> op) { + {{#fields}} + op.add(Builder::{{name}}, {{{type.deserializer}}}, {{#dq}}{{wireName}}{{/dq}}); + {{/fields}} + } +} \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache index 789fda14ff..c00f391b34 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache @@ -1,4 +1,4 @@ -package org.opensearch.client; +package org.opensearch.client.opensearch; import org.opensearch.client.opensearch._types.*; {{#hasRequestBody}}import org.opensearch.client.json.*;{{/hasRequestBody}} @@ -41,13 +41,13 @@ public class {{className}} extends RequestBase{{#hasRequestBody}} implements Jso {{/fields}} {{#hasRequestBody}} - public void serialize(JsonGenerator generator, JsonMapper mapper) { + public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); generator.writeEnd(); } - protected void serializeInternal(JsonGenerator generator, JsonMapper mapper) { + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { {{#bodyFields}} if ({{#type.isDefined}}this.{{name}}{{/type.isDefined}}) { generator.writeKey({{#dq}}{{wireName}}{{/dq}}); @@ -100,12 +100,12 @@ public class {{className}} extends RequestBase{{#hasRequestBody}} implements Jso this.{{name}} = value; return this; } - {{^type.isPrimitive}} + {{^type.isBuiltIn}} public final Builder {{name}}({{{type.builderFuncType}}} fn) { return {{name}}(fn.apply(new {{{type.builderType}}}()).build()); } - {{/type.isPrimitive}} + {{/type.isBuiltIn}} {{/type.isListOrMap}} {{/fields}} From 639921b4fa13bcc7568a5721275737b5f79cc896 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Tue, 14 Feb 2023 16:28:59 +1300 Subject: [PATCH 03/50] Output response shapes and enum shapes Signed-off-by: Thomas Farr --- .../opensearch/ActionObjectStructure.java | 6 +- .../client/opensearch/DefaultOperator.java | 30 ++ .../client/opensearch/DeleteIndexRequest.java | 24 +- .../opensearch/DeleteIndexResponse.java | 72 +++++ .../client/opensearch/ExpandWildcards.java | 33 +++ .../opensearch/GetCatIndicesRequest.java | 36 +-- .../opensearch/GetCatIndicesResponse.java | 53 ++++ .../GetCatIndicesWithIndexRequest.java | 36 +-- .../GetCatIndicesWithIndexResponse.java | 55 ++++ .../client/opensearch/GetCatNodesRequest.java | 40 +-- .../opensearch/GetCatNodesResponse.java | 52 ++++ .../opensearch/GetClusterInfoResponse.java | 149 ++++++++++ .../opensearch/GetClusterSettingsRequest.java | 20 +- .../GetClusterSettingsResponse.java | 149 ++++++++++ .../opensearch/GetDocumentDocRequest.java | 44 +-- .../opensearch/GetDocumentDocResponse.java | 264 ++++++++++++++++++ .../opensearch/GetDocumentSourceRequest.java | 44 +-- .../opensearch/GetDocumentSourceResponse.java | 54 ++++ .../opensearch/GetSettingsIndexRequest.java | 40 +-- .../opensearch/GetSettingsIndexResponse.java | 54 ++++ .../GetSettingsIndexSettingRequest.java | 40 +-- .../GetSettingsIndexSettingResponse.java | 55 ++++ .../client/opensearch/HealthStatus.java | 31 ++ .../opensearch/client/opensearch/Hits.java | 159 +++++++++++ .../client/opensearch/HitsMetadata.java | 124 ++++++++ .../client/opensearch/PostAliasesRequest.java | 8 +- .../opensearch/PostAliasesResponse.java | 73 +++++ .../PostRemoteStoreRestoreRequest.java | 11 +- .../PostRemoteStoreRestoreResponse.java | 99 +++++++ .../client/opensearch/PostSearchRequest.java | 236 ++++++++-------- .../client/opensearch/PostSearchResponse.java | 153 ++++++++++ .../PostSearchWithIndexRequest.java | 236 ++++++++-------- .../PostSearchWithIndexResponse.java | 155 ++++++++++ .../opensearch/PutCreateIndexRequest.java | 22 +- .../opensearch/PutCreateIndexResponse.java | 115 ++++++++ .../PutIndexMappingWithIndexRequest.java | 42 +-- .../PutIndexMappingWithIndexResponse.java | 75 +++++ .../PutUpdateClusterSettingsRequest.java | 18 +- .../PutUpdateClusterSettingsResponse.java | 137 +++++++++ .../client/opensearch/Relation.java | 30 ++ .../opensearch/RemoteStoreRestoreInfo.java | 129 +++++++++ .../RemoteStoreRestoreShardsInfo.java | 110 ++++++++ .../client/opensearch/SearchType.java | 30 ++ .../client/opensearch/ShardStatistics.java | 126 +++++++++ .../client/opensearch/SuggestMode.java | 31 ++ .../opensearch/client/opensearch/Total.java | 91 ++++++ .../UserDefinedObjectStructure.java | 106 +++---- .../opensearch/UserDefinedStructure.java | 34 +-- .../opensearch/client/opensearch/Version.java | 219 +++++++++++++++ .../client/opensearch/VersionType.java | 31 ++ java-codegen/OpenSearch.openapi.json | 10 +- .../client/codegen/ApiSpecification.java | 57 +++- .../opensearch/client/codegen/Generator.java | 6 + .../opensearch/client/codegen/Renderer.java | 9 +- .../opensearch/client/codegen/TypeMapper.java | 12 +- .../client/codegen/model/EnumShape.java | 31 ++ .../client/codegen/model/Field.java | 6 +- .../codegen/templates/EnumShape.mustache | 26 ++ .../codegen/templates/ObjectShape.mustache | 1 + .../templates/OperationRequest.mustache | 1 + 60 files changed, 3597 insertions(+), 543 deletions(-) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/DefaultOperator.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexResponse.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/ExpandWildcards.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesResponse.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexResponse.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesResponse.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoResponse.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsResponse.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocResponse.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceResponse.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexResponse.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingResponse.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/HealthStatus.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/Hits.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/HitsMetadata.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesResponse.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreResponse.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchResponse.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexResponse.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexResponse.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexResponse.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsResponse.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/Relation.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreInfo.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreShardsInfo.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/SearchType.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/ShardStatistics.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/SuggestMode.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/Total.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/Version.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/VersionType.java create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ActionObjectStructure.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ActionObjectStructure.java index d4d7603ea4..f5d583943a 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ActionObjectStructure.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ActionObjectStructure.java @@ -12,9 +12,9 @@ @JsonpDeserializable public class ActionObjectStructure implements JsonpSerializable { - private final UserDefinedStructure add; - private final UserDefinedStructure remove; - private final UserDefinedStructure removeIndex; + @Nullable private final UserDefinedStructure add; + @Nullable private final UserDefinedStructure remove; + @Nullable private final UserDefinedStructure removeIndex; public ActionObjectStructure(Builder builder) { this.add = builder.add; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/DefaultOperator.java b/java-client/src/generated/java/org/opensearch/client/opensearch/DefaultOperator.java new file mode 100644 index 0000000000..33e8791920 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/DefaultOperator.java @@ -0,0 +1,30 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.json.JsonEnum; +import org.opensearch.client.json.JsonpDeserializable; + +@JsonpDeserializable +public enum DefaultOperator implements JsonEnum { + And("AND"), + Or("OR"), + ; + + private final String jsonValue; + private final String[] aliases; + + DefaultOperator(String jsonValue, String... aliases) { + this.jsonValue = jsonValue; + this.aliases = aliases; + } + + public String jsonValue() { + return this.jsonValue; + } + + public String[] aliases() { + return this.aliases; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = + new JsonEnum.Deserializer<>(DefaultOperator.values()); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java index 8697ecf91f..7c6758b16c 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java @@ -12,12 +12,12 @@ /** Removes a document from the index. */ public class DeleteIndexRequest extends RequestBase { - private final boolean allowNoIndices; - private final String clusterManagerTimeout; - private final ExpandWildcards expandWildcards; - private final boolean ignoreUnavailable; - private final String masterTimeout; - private final String timeout; + @Nullable private final Boolean allowNoIndices; + @Nullable private final String clusterManagerTimeout; + @Nullable private final ExpandWildcards expandWildcards; + @Nullable private final Boolean ignoreUnavailable; + @Nullable private final String masterTimeout; + @Nullable private final String timeout; public DeleteIndexRequest(Builder builder) { this.allowNoIndices = builder.allowNoIndices; @@ -32,7 +32,7 @@ public static DeleteIndexRequest of(Function { - private boolean allowNoIndices; + private Boolean allowNoIndices; private String clusterManagerTimeout; private ExpandWildcards expandWildcards; - private boolean ignoreUnavailable; + private Boolean ignoreUnavailable; private String masterTimeout; private String timeout; - public final Builder allowNoIndices(boolean value) { + public final Builder allowNoIndices(Boolean value) { this.allowNoIndices = value; return this; } @@ -86,7 +86,7 @@ public final Builder expandWildcards( return expandWildcards(fn.apply(new ExpandWildcards.Builder()).build()); } - public final Builder ignoreUnavailable(boolean value) { + public final Builder ignoreUnavailable(Boolean value) { this.ignoreUnavailable = value; return this; } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexResponse.java new file mode 100644 index 0000000000..4da9057bd3 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexResponse.java @@ -0,0 +1,72 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class DeleteIndexResponse implements JsonpSerializable { + @Nullable private final Boolean acknowledged; + + public DeleteIndexResponse(Builder builder) { + this.acknowledged = builder.acknowledged; + } + + public static DeleteIndexResponse of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final Boolean acknowledged() { + return this.acknowledged; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.acknowledged != null) { + generator.writeKey("acknowledged"); + generator.write(this.acknowledged); + } + } + + /** Builder for {@link DeleteIndexResponse}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private Boolean acknowledged; + + public final Builder acknowledged(Boolean value) { + this.acknowledged = value; + return this; + } + + /** + * Builds a {@link DeleteIndexResponse}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public DeleteIndexResponse build() { + _checkSingleUse(); + + return new DeleteIndexResponse(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, DeleteIndexResponse::setupDeleteIndexResponseDeserializer); + + protected static void setupDeleteIndexResponseDeserializer( + ObjectDeserializer op) { + op.add(Builder::acknowledged, JsonpDeserializer.booleanDeserializer(), "acknowledged"); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ExpandWildcards.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ExpandWildcards.java new file mode 100644 index 0000000000..355c48c0c9 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ExpandWildcards.java @@ -0,0 +1,33 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.json.JsonEnum; +import org.opensearch.client.json.JsonpDeserializable; + +@JsonpDeserializable +public enum ExpandWildcards implements JsonEnum { + All("all"), + Open("open"), + Closed("closed"), + Hidden("hidden"), + None("none"), + ; + + private final String jsonValue; + private final String[] aliases; + + ExpandWildcards(String jsonValue, String... aliases) { + this.jsonValue = jsonValue; + this.aliases = aliases; + } + + public String jsonValue() { + return this.jsonValue; + } + + public String[] aliases() { + return this.aliases; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = + new JsonEnum.Deserializer<>(ExpandWildcards.values()); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesRequest.java index 1990a51ce4..aaf55ba50b 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesRequest.java @@ -15,15 +15,15 @@ * etc. */ public class GetCatIndicesRequest extends RequestBase { - private final int bytes; - private final String clusterManagerTimeout; - private final ExpandWildcards expandWildcards; - private final String format; - private final HealthStatus health; - private final boolean includeUnloadedSegments; - private final String masterTimeout; - private final boolean pri; - private final String time; + @Nullable private final Integer bytes; + @Nullable private final String clusterManagerTimeout; + @Nullable private final ExpandWildcards expandWildcards; + @Nullable private final String format; + @Nullable private final HealthStatus health; + @Nullable private final Boolean includeUnloadedSegments; + @Nullable private final String masterTimeout; + @Nullable private final Boolean pri; + @Nullable private final String time; public GetCatIndicesRequest(Builder builder) { this.bytes = builder.bytes; @@ -42,7 +42,7 @@ public static GetCatIndicesRequest of( return fn.apply(new Builder()).build(); } - public final int bytes() { + public final Integer bytes() { return this.bytes; } @@ -62,7 +62,7 @@ public final HealthStatus health() { return this.health; } - public final boolean includeUnloadedSegments() { + public final Boolean includeUnloadedSegments() { return this.includeUnloadedSegments; } @@ -70,7 +70,7 @@ public final String masterTimeout() { return this.masterTimeout; } - public final boolean pri() { + public final Boolean pri() { return this.pri; } @@ -81,17 +81,17 @@ public final String time() { /** Builder for {@link GetCatIndicesRequest}. */ public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private int bytes; + private Integer bytes; private String clusterManagerTimeout; private ExpandWildcards expandWildcards; private String format; private HealthStatus health; - private boolean includeUnloadedSegments; + private Boolean includeUnloadedSegments; private String masterTimeout; - private boolean pri; + private Boolean pri; private String time; - public final Builder bytes(int value) { + public final Builder bytes(Integer value) { this.bytes = value; return this; } @@ -126,7 +126,7 @@ public final Builder health( return health(fn.apply(new HealthStatus.Builder()).build()); } - public final Builder includeUnloadedSegments(boolean value) { + public final Builder includeUnloadedSegments(Boolean value) { this.includeUnloadedSegments = value; return this; } @@ -136,7 +136,7 @@ public final Builder masterTimeout(String value) { return this; } - public final Builder pri(boolean value) { + public final Builder pri(Boolean value) { this.pri = value; return this; } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesResponse.java new file mode 100644 index 0000000000..debfd6b6ea --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesResponse.java @@ -0,0 +1,53 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class GetCatIndicesResponse implements JsonpSerializable { + + public GetCatIndicesResponse(Builder builder) {} + + public static GetCatIndicesResponse of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {} + + /** Builder for {@link GetCatIndicesResponse}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + + /** + * Builds a {@link GetCatIndicesResponse}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public GetCatIndicesResponse build() { + _checkSingleUse(); + + return new GetCatIndicesResponse(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, GetCatIndicesResponse::setupGetCatIndicesResponseDeserializer); + + protected static void setupGetCatIndicesResponseDeserializer( + ObjectDeserializer op) {} +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java index 8386e1b321..b9bc3b0e5f 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java @@ -15,15 +15,15 @@ * etc. */ public class GetCatIndicesWithIndexRequest extends RequestBase { - private final int bytes; - private final String clusterManagerTimeout; - private final ExpandWildcards expandWildcards; - private final String format; - private final HealthStatus health; - private final boolean includeUnloadedSegments; - private final String masterTimeout; - private final boolean pri; - private final String time; + @Nullable private final Integer bytes; + @Nullable private final String clusterManagerTimeout; + @Nullable private final ExpandWildcards expandWildcards; + @Nullable private final String format; + @Nullable private final HealthStatus health; + @Nullable private final Boolean includeUnloadedSegments; + @Nullable private final String masterTimeout; + @Nullable private final Boolean pri; + @Nullable private final String time; public GetCatIndicesWithIndexRequest(Builder builder) { this.bytes = builder.bytes; @@ -42,7 +42,7 @@ public static GetCatIndicesWithIndexRequest of( return fn.apply(new Builder()).build(); } - public final int bytes() { + public final Integer bytes() { return this.bytes; } @@ -62,7 +62,7 @@ public final HealthStatus health() { return this.health; } - public final boolean includeUnloadedSegments() { + public final Boolean includeUnloadedSegments() { return this.includeUnloadedSegments; } @@ -70,7 +70,7 @@ public final String masterTimeout() { return this.masterTimeout; } - public final boolean pri() { + public final Boolean pri() { return this.pri; } @@ -81,17 +81,17 @@ public final String time() { /** Builder for {@link GetCatIndicesWithIndexRequest}. */ public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private int bytes; + private Integer bytes; private String clusterManagerTimeout; private ExpandWildcards expandWildcards; private String format; private HealthStatus health; - private boolean includeUnloadedSegments; + private Boolean includeUnloadedSegments; private String masterTimeout; - private boolean pri; + private Boolean pri; private String time; - public final Builder bytes(int value) { + public final Builder bytes(Integer value) { this.bytes = value; return this; } @@ -126,7 +126,7 @@ public final Builder health( return health(fn.apply(new HealthStatus.Builder()).build()); } - public final Builder includeUnloadedSegments(boolean value) { + public final Builder includeUnloadedSegments(Boolean value) { this.includeUnloadedSegments = value; return this; } @@ -136,7 +136,7 @@ public final Builder masterTimeout(String value) { return this; } - public final Builder pri(boolean value) { + public final Builder pri(Boolean value) { this.pri = value; return this; } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexResponse.java new file mode 100644 index 0000000000..c69d5cf019 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexResponse.java @@ -0,0 +1,55 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class GetCatIndicesWithIndexResponse implements JsonpSerializable { + + public GetCatIndicesWithIndexResponse(Builder builder) {} + + public static GetCatIndicesWithIndexResponse of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {} + + /** Builder for {@link GetCatIndicesWithIndexResponse}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + + /** + * Builds a {@link GetCatIndicesWithIndexResponse}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public GetCatIndicesWithIndexResponse build() { + _checkSingleUse(); + + return new GetCatIndicesWithIndexResponse(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, + GetCatIndicesWithIndexResponse + ::setupGetCatIndicesWithIndexResponseDeserializer); + + protected static void setupGetCatIndicesWithIndexResponseDeserializer( + ObjectDeserializer op) {} +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesRequest.java index 8342d8795a..28aad4b982 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesRequest.java @@ -12,14 +12,14 @@ /** Returns basic statistics about performance of cluster nodes. */ public class GetCatNodesRequest extends RequestBase { - private final int bytes; - private final String clusterManagerTimeout; - private final String format; - private final boolean fullId; - private final boolean includeUnloadedSegments; - private final boolean local; - private final String masterTimeout; - private final String time; + @Nullable private final Integer bytes; + @Nullable private final String clusterManagerTimeout; + @Nullable private final String format; + @Nullable private final Boolean fullId; + @Nullable private final Boolean includeUnloadedSegments; + @Nullable private final Boolean local; + @Nullable private final String masterTimeout; + @Nullable private final String time; public GetCatNodesRequest(Builder builder) { this.bytes = builder.bytes; @@ -36,7 +36,7 @@ public static GetCatNodesRequest of(Function { - private int bytes; + private Integer bytes; private String clusterManagerTimeout; private String format; - private boolean fullId; - private boolean includeUnloadedSegments; - private boolean local; + private Boolean fullId; + private Boolean includeUnloadedSegments; + private Boolean local; private String masterTimeout; private String time; - public final Builder bytes(int value) { + public final Builder bytes(Integer value) { this.bytes = value; return this; } @@ -95,17 +95,17 @@ public final Builder format(String value) { return this; } - public final Builder fullId(boolean value) { + public final Builder fullId(Boolean value) { this.fullId = value; return this; } - public final Builder includeUnloadedSegments(boolean value) { + public final Builder includeUnloadedSegments(Boolean value) { this.includeUnloadedSegments = value; return this; } - public final Builder local(boolean value) { + public final Builder local(Boolean value) { this.local = value; return this; } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesResponse.java new file mode 100644 index 0000000000..8178cca356 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesResponse.java @@ -0,0 +1,52 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class GetCatNodesResponse implements JsonpSerializable { + + public GetCatNodesResponse(Builder builder) {} + + public static GetCatNodesResponse of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {} + + /** Builder for {@link GetCatNodesResponse}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + + /** + * Builds a {@link GetCatNodesResponse}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public GetCatNodesResponse build() { + _checkSingleUse(); + + return new GetCatNodesResponse(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, GetCatNodesResponse::setupGetCatNodesResponseDeserializer); + + protected static void setupGetCatNodesResponseDeserializer( + ObjectDeserializer op) {} +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoResponse.java new file mode 100644 index 0000000000..14b3c8a747 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoResponse.java @@ -0,0 +1,149 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class GetClusterInfoResponse implements JsonpSerializable { + @Nullable private final String clusterName; + @Nullable private final String clusterUuid; + @Nullable private final String name; + @Nullable private final String tagline; + @Nullable private final Version version; + + public GetClusterInfoResponse(Builder builder) { + this.clusterName = builder.clusterName; + this.clusterUuid = builder.clusterUuid; + this.name = builder.name; + this.tagline = builder.tagline; + this.version = builder.version; + } + + public static GetClusterInfoResponse of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final String clusterName() { + return this.clusterName; + } + + public final String clusterUuid() { + return this.clusterUuid; + } + + public final String name() { + return this.name; + } + + public final String tagline() { + return this.tagline; + } + + public final Version version() { + return this.version; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.clusterName != null) { + generator.writeKey("cluster_name"); + generator.write(this.clusterName); + } + + if (this.clusterUuid != null) { + generator.writeKey("cluster_uuid"); + generator.write(this.clusterUuid); + } + + if (this.name != null) { + generator.writeKey("name"); + generator.write(this.name); + } + + if (this.tagline != null) { + generator.writeKey("tagline"); + generator.write(this.tagline); + } + + if (this.version != null) { + generator.writeKey("version"); + this.version.serialize(generator, mapper); + } + } + + /** Builder for {@link GetClusterInfoResponse}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private String clusterName; + private String clusterUuid; + private String name; + private String tagline; + private Version version; + + public final Builder clusterName(String value) { + this.clusterName = value; + return this; + } + + public final Builder clusterUuid(String value) { + this.clusterUuid = value; + return this; + } + + public final Builder name(String value) { + this.name = value; + return this; + } + + public final Builder tagline(String value) { + this.tagline = value; + return this; + } + + public final Builder version(Version value) { + this.version = value; + return this; + } + + public final Builder version(Function> fn) { + return version(fn.apply(new Version.Builder()).build()); + } + + /** + * Builds a {@link GetClusterInfoResponse}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public GetClusterInfoResponse build() { + _checkSingleUse(); + + return new GetClusterInfoResponse(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, GetClusterInfoResponse::setupGetClusterInfoResponseDeserializer); + + protected static void setupGetClusterInfoResponseDeserializer( + ObjectDeserializer op) { + op.add(Builder::clusterName, JsonpDeserializer.stringDeserializer(), "cluster_name"); + op.add(Builder::clusterUuid, JsonpDeserializer.stringDeserializer(), "cluster_uuid"); + op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); + op.add(Builder::tagline, JsonpDeserializer.stringDeserializer(), "tagline"); + op.add(Builder::version, Version._DESERIALIZER, "version"); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsRequest.java index d694742eec..477812368b 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsRequest.java @@ -12,10 +12,10 @@ /** Returns cluster settings. */ public class GetClusterSettingsRequest extends RequestBase { - private final String clusterManagerTimeout; - private final boolean flatSettings; - private final boolean includeDefaults; - private final String masterTimeout; + @Nullable private final String clusterManagerTimeout; + @Nullable private final Boolean flatSettings; + @Nullable private final Boolean includeDefaults; + @Nullable private final String masterTimeout; public GetClusterSettingsRequest(Builder builder) { this.clusterManagerTimeout = builder.clusterManagerTimeout; @@ -33,11 +33,11 @@ public final String clusterManagerTimeout() { return this.clusterManagerTimeout; } - public final boolean flatSettings() { + public final Boolean flatSettings() { return this.flatSettings; } - public final boolean includeDefaults() { + public final Boolean includeDefaults() { return this.includeDefaults; } @@ -49,8 +49,8 @@ public final String masterTimeout() { public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private String clusterManagerTimeout; - private boolean flatSettings; - private boolean includeDefaults; + private Boolean flatSettings; + private Boolean includeDefaults; private String masterTimeout; public final Builder clusterManagerTimeout(String value) { @@ -58,12 +58,12 @@ public final Builder clusterManagerTimeout(String value) { return this; } - public final Builder flatSettings(boolean value) { + public final Builder flatSettings(Boolean value) { this.flatSettings = value; return this; } - public final Builder includeDefaults(boolean value) { + public final Builder includeDefaults(Boolean value) { this.includeDefaults = value; return this; } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsResponse.java new file mode 100644 index 0000000000..d262e2afc3 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsResponse.java @@ -0,0 +1,149 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class GetClusterSettingsResponse implements JsonpSerializable { + @Nullable private final Map defaults; + @Nullable private final Map persistent; + @Nullable private final Map transient_; + + public GetClusterSettingsResponse(Builder builder) { + this.defaults = ApiTypeHelper.unmodifiable(builder.defaults); + this.persistent = ApiTypeHelper.unmodifiable(builder.persistent); + this.transient_ = ApiTypeHelper.unmodifiable(builder.transient_); + } + + public static GetClusterSettingsResponse of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final Map defaults() { + return this.defaults; + } + + public final Map persistent() { + return this.persistent; + } + + public final Map transient_() { + return this.transient_; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (ApiTypeHelper.isDefined(this.defaults)) { + generator.writeKey("defaults"); + generator.writeStartObject(); + for (Map.Entry item0 : this.defaults.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (ApiTypeHelper.isDefined(this.persistent)) { + generator.writeKey("persistent"); + generator.writeStartObject(); + for (Map.Entry item0 : this.persistent.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (ApiTypeHelper.isDefined(this.transient_)) { + generator.writeKey("transient"); + generator.writeStartObject(); + for (Map.Entry item0 : this.transient_.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + } + + /** Builder for {@link GetClusterSettingsResponse}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private Map defaults; + private Map persistent; + private Map transient_; + + public final Builder defaults(Map map) { + this.defaults = _mapPutAll(this.defaults, map); + return this; + } + + public final Builder defaults(String key, JsonData value) { + this.defaults = _mapPut(this.defaults, key, value); + return this; + } + + public final Builder persistent(Map map) { + this.persistent = _mapPutAll(this.persistent, map); + return this; + } + + public final Builder persistent(String key, JsonData value) { + this.persistent = _mapPut(this.persistent, key, value); + return this; + } + + public final Builder transient_(Map map) { + this.transient_ = _mapPutAll(this.transient_, map); + return this; + } + + public final Builder transient_(String key, JsonData value) { + this.transient_ = _mapPut(this.transient_, key, value); + return this; + } + + /** + * Builds a {@link GetClusterSettingsResponse}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public GetClusterSettingsResponse build() { + _checkSingleUse(); + + return new GetClusterSettingsResponse(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, + GetClusterSettingsResponse::setupGetClusterSettingsResponseDeserializer); + + protected static void setupGetClusterSettingsResponseDeserializer( + ObjectDeserializer op) { + op.add( + Builder::defaults, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "defaults"); + op.add( + Builder::persistent, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "persistent"); + op.add( + Builder::transient_, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "transient"); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java index 13484d34fe..0af6d96f56 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java @@ -12,16 +12,16 @@ /** Returns a document */ public class GetDocumentDocRequest extends RequestBase { - private final String source; - private final String sourceExcludes; - private final String sourceIncludes; - private final String preference; - private final boolean realtime; - private final boolean refresh; - private final String routing; - private final boolean storedFields; - private final int version; - private final VersionType versionType; + @Nullable private final String source; + @Nullable private final String sourceExcludes; + @Nullable private final String sourceIncludes; + @Nullable private final String preference; + @Nullable private final Boolean realtime; + @Nullable private final Boolean refresh; + @Nullable private final String routing; + @Nullable private final Boolean storedFields; + @Nullable private final Integer version; + @Nullable private final VersionType versionType; public GetDocumentDocRequest(Builder builder) { this.source = builder.source; @@ -57,11 +57,11 @@ public final String preference() { return this.preference; } - public final boolean realtime() { + public final Boolean realtime() { return this.realtime; } - public final boolean refresh() { + public final Boolean refresh() { return this.refresh; } @@ -69,11 +69,11 @@ public final String routing() { return this.routing; } - public final boolean storedFields() { + public final Boolean storedFields() { return this.storedFields; } - public final int version() { + public final Integer version() { return this.version; } @@ -88,11 +88,11 @@ public static class Builder extends ObjectBuilderBase private String sourceExcludes; private String sourceIncludes; private String preference; - private boolean realtime; - private boolean refresh; + private Boolean realtime; + private Boolean refresh; private String routing; - private boolean storedFields; - private int version; + private Boolean storedFields; + private Integer version; private VersionType versionType; public final Builder source(String value) { @@ -115,12 +115,12 @@ public final Builder preference(String value) { return this; } - public final Builder realtime(boolean value) { + public final Builder realtime(Boolean value) { this.realtime = value; return this; } - public final Builder refresh(boolean value) { + public final Builder refresh(Boolean value) { this.refresh = value; return this; } @@ -130,12 +130,12 @@ public final Builder routing(String value) { return this; } - public final Builder storedFields(boolean value) { + public final Builder storedFields(Boolean value) { this.storedFields = value; return this; } - public final Builder version(int value) { + public final Builder version(Integer value) { this.version = value; return this; } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocResponse.java new file mode 100644 index 0000000000..6d5ffc073d --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocResponse.java @@ -0,0 +1,264 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class GetDocumentDocResponse implements JsonpSerializable { + @Nullable private final Map fields; + + private final String id; + + private final String index; + @Nullable private final String routing; + @Nullable private final Map source; + @Nullable private final String type; + + private final boolean found; + @Nullable private final Long primaryTerm; + @Nullable private final Long seqNo; + @Nullable private final Integer version; + + public GetDocumentDocResponse(Builder builder) { + this.fields = ApiTypeHelper.unmodifiable(builder.fields); + this.id = builder.id; + this.index = builder.index; + this.routing = builder.routing; + this.source = ApiTypeHelper.unmodifiable(builder.source); + this.type = builder.type; + this.found = builder.found; + this.primaryTerm = builder.primaryTerm; + this.seqNo = builder.seqNo; + this.version = builder.version; + } + + public static GetDocumentDocResponse of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final Map fields() { + return this.fields; + } + + public final String id() { + return this.id; + } + + public final String index() { + return this.index; + } + + public final String routing() { + return this.routing; + } + + public final Map source() { + return this.source; + } + + public final String type() { + return this.type; + } + + public final boolean found() { + return this.found; + } + + public final Long primaryTerm() { + return this.primaryTerm; + } + + public final Long seqNo() { + return this.seqNo; + } + + public final Integer version() { + return this.version; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (ApiTypeHelper.isDefined(this.fields)) { + generator.writeKey("_fields"); + generator.writeStartObject(); + for (Map.Entry item0 : this.fields.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (this.id != null) { + generator.writeKey("_id"); + generator.write(this.id); + } + + if (this.index != null) { + generator.writeKey("_index"); + generator.write(this.index); + } + + if (this.routing != null) { + generator.writeKey("_routing"); + generator.write(this.routing); + } + + if (ApiTypeHelper.isDefined(this.source)) { + generator.writeKey("_source"); + generator.writeStartObject(); + for (Map.Entry item0 : this.source.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (this.type != null) { + generator.writeKey("_type"); + generator.write(this.type); + } + + if (this.found != null) { + generator.writeKey("found"); + generator.write(this.found); + } + + if (this.primaryTerm != null) { + generator.writeKey("primary_term"); + generator.write(this.primaryTerm); + } + + if (this.seqNo != null) { + generator.writeKey("seq_no"); + generator.write(this.seqNo); + } + + if (this.version != null) { + generator.writeKey("version"); + generator.write(this.version); + } + } + + /** Builder for {@link GetDocumentDocResponse}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private Map fields; + private String id; + private String index; + private String routing; + private Map source; + private String type; + private boolean found; + private Long primaryTerm; + private Long seqNo; + private Integer version; + + public final Builder fields(Map map) { + this.fields = _mapPutAll(this.fields, map); + return this; + } + + public final Builder fields(String key, JsonData value) { + this.fields = _mapPut(this.fields, key, value); + return this; + } + + public final Builder id(String value) { + this.id = value; + return this; + } + + public final Builder index(String value) { + this.index = value; + return this; + } + + public final Builder routing(String value) { + this.routing = value; + return this; + } + + public final Builder source(Map map) { + this.source = _mapPutAll(this.source, map); + return this; + } + + public final Builder source(String key, JsonData value) { + this.source = _mapPut(this.source, key, value); + return this; + } + + public final Builder type(String value) { + this.type = value; + return this; + } + + public final Builder found(boolean value) { + this.found = value; + return this; + } + + public final Builder primaryTerm(Long value) { + this.primaryTerm = value; + return this; + } + + public final Builder seqNo(Long value) { + this.seqNo = value; + return this; + } + + public final Builder version(Integer value) { + this.version = value; + return this; + } + + /** + * Builds a {@link GetDocumentDocResponse}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public GetDocumentDocResponse build() { + _checkSingleUse(); + + return new GetDocumentDocResponse(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, GetDocumentDocResponse::setupGetDocumentDocResponseDeserializer); + + protected static void setupGetDocumentDocResponseDeserializer( + ObjectDeserializer op) { + op.add( + Builder::fields, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "_fields"); + op.add(Builder::id, JsonpDeserializer.stringDeserializer(), "_id"); + op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "_index"); + op.add(Builder::routing, JsonpDeserializer.stringDeserializer(), "_routing"); + op.add( + Builder::source, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "_source"); + op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "_type"); + op.add(Builder::found, JsonpDeserializer.booleanDeserializer(), "found"); + op.add(Builder::primaryTerm, JsonpDeserializer.longDeserializer(), "primary_term"); + op.add(Builder::seqNo, JsonpDeserializer.longDeserializer(), "seq_no"); + op.add(Builder::version, JsonpDeserializer.integerDeserializer(), "version"); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java index cadb33117f..eb3a8e3e2f 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java @@ -12,16 +12,16 @@ /** Returns a document. */ public class GetDocumentSourceRequest extends RequestBase { - private final String source; - private final String sourceExcludes; - private final String sourceIncludes; - private final String preference; - private final boolean realtime; - private final boolean refresh; - private final String routing; - private final boolean storedFields; - private final int version; - private final VersionType versionType; + @Nullable private final String source; + @Nullable private final String sourceExcludes; + @Nullable private final String sourceIncludes; + @Nullable private final String preference; + @Nullable private final Boolean realtime; + @Nullable private final Boolean refresh; + @Nullable private final String routing; + @Nullable private final Boolean storedFields; + @Nullable private final Integer version; + @Nullable private final VersionType versionType; public GetDocumentSourceRequest(Builder builder) { this.source = builder.source; @@ -57,11 +57,11 @@ public final String preference() { return this.preference; } - public final boolean realtime() { + public final Boolean realtime() { return this.realtime; } - public final boolean refresh() { + public final Boolean refresh() { return this.refresh; } @@ -69,11 +69,11 @@ public final String routing() { return this.routing; } - public final boolean storedFields() { + public final Boolean storedFields() { return this.storedFields; } - public final int version() { + public final Integer version() { return this.version; } @@ -88,11 +88,11 @@ public static class Builder extends ObjectBuilderBase private String sourceExcludes; private String sourceIncludes; private String preference; - private boolean realtime; - private boolean refresh; + private Boolean realtime; + private Boolean refresh; private String routing; - private boolean storedFields; - private int version; + private Boolean storedFields; + private Integer version; private VersionType versionType; public final Builder source(String value) { @@ -115,12 +115,12 @@ public final Builder preference(String value) { return this; } - public final Builder realtime(boolean value) { + public final Builder realtime(Boolean value) { this.realtime = value; return this; } - public final Builder refresh(boolean value) { + public final Builder refresh(Boolean value) { this.refresh = value; return this; } @@ -130,12 +130,12 @@ public final Builder routing(String value) { return this; } - public final Builder storedFields(boolean value) { + public final Builder storedFields(Boolean value) { this.storedFields = value; return this; } - public final Builder version(int value) { + public final Builder version(Integer value) { this.version = value; return this; } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceResponse.java new file mode 100644 index 0000000000..9dd5df8d19 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceResponse.java @@ -0,0 +1,54 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class GetDocumentSourceResponse implements JsonpSerializable { + + public GetDocumentSourceResponse(Builder builder) {} + + public static GetDocumentSourceResponse of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {} + + /** Builder for {@link GetDocumentSourceResponse}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + + /** + * Builds a {@link GetDocumentSourceResponse}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public GetDocumentSourceResponse build() { + _checkSingleUse(); + + return new GetDocumentSourceResponse(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, + GetDocumentSourceResponse::setupGetDocumentSourceResponseDeserializer); + + protected static void setupGetDocumentSourceResponseDeserializer( + ObjectDeserializer op) {} +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java index 8534b7250a..8b59fa9bac 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java @@ -12,14 +12,14 @@ /** The get settings API operation returns all the settings in your index. */ public class GetSettingsIndexRequest extends RequestBase { - private final boolean allowNoIndices; - private final String clusterManagerTimeout; - private final ExpandWildcards expandWildcards; - private final boolean flatSettings; - private final boolean ignoreUnavailable; - private final String includeDefaults; - private final boolean local; - private final String masterTimeout; + @Nullable private final Boolean allowNoIndices; + @Nullable private final String clusterManagerTimeout; + @Nullable private final ExpandWildcards expandWildcards; + @Nullable private final Boolean flatSettings; + @Nullable private final Boolean ignoreUnavailable; + @Nullable private final String includeDefaults; + @Nullable private final Boolean local; + @Nullable private final String masterTimeout; public GetSettingsIndexRequest(Builder builder) { this.allowNoIndices = builder.allowNoIndices; @@ -37,7 +37,7 @@ public static GetSettingsIndexRequest of( return fn.apply(new Builder()).build(); } - public final boolean allowNoIndices() { + public final Boolean allowNoIndices() { return this.allowNoIndices; } @@ -49,11 +49,11 @@ public final ExpandWildcards expandWildcards() { return this.expandWildcards; } - public final boolean flatSettings() { + public final Boolean flatSettings() { return this.flatSettings; } - public final boolean ignoreUnavailable() { + public final Boolean ignoreUnavailable() { return this.ignoreUnavailable; } @@ -61,7 +61,7 @@ public final String includeDefaults() { return this.includeDefaults; } - public final boolean local() { + public final Boolean local() { return this.local; } @@ -72,16 +72,16 @@ public final String masterTimeout() { /** Builder for {@link GetSettingsIndexRequest}. */ public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private boolean allowNoIndices; + private Boolean allowNoIndices; private String clusterManagerTimeout; private ExpandWildcards expandWildcards; - private boolean flatSettings; - private boolean ignoreUnavailable; + private Boolean flatSettings; + private Boolean ignoreUnavailable; private String includeDefaults; - private boolean local; + private Boolean local; private String masterTimeout; - public final Builder allowNoIndices(boolean value) { + public final Builder allowNoIndices(Boolean value) { this.allowNoIndices = value; return this; } @@ -101,12 +101,12 @@ public final Builder expandWildcards( return expandWildcards(fn.apply(new ExpandWildcards.Builder()).build()); } - public final Builder flatSettings(boolean value) { + public final Builder flatSettings(Boolean value) { this.flatSettings = value; return this; } - public final Builder ignoreUnavailable(boolean value) { + public final Builder ignoreUnavailable(Boolean value) { this.ignoreUnavailable = value; return this; } @@ -116,7 +116,7 @@ public final Builder includeDefaults(String value) { return this; } - public final Builder local(boolean value) { + public final Builder local(Boolean value) { this.local = value; return this; } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexResponse.java new file mode 100644 index 0000000000..fb69d71747 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexResponse.java @@ -0,0 +1,54 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class GetSettingsIndexResponse implements JsonpSerializable { + + public GetSettingsIndexResponse(Builder builder) {} + + public static GetSettingsIndexResponse of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {} + + /** Builder for {@link GetSettingsIndexResponse}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + + /** + * Builds a {@link GetSettingsIndexResponse}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public GetSettingsIndexResponse build() { + _checkSingleUse(); + + return new GetSettingsIndexResponse(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, + GetSettingsIndexResponse::setupGetSettingsIndexResponseDeserializer); + + protected static void setupGetSettingsIndexResponseDeserializer( + ObjectDeserializer op) {} +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java index 87d34dab93..0b7c295fea 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java @@ -12,14 +12,14 @@ /** The get settings API operation returns all the settings in your index. */ public class GetSettingsIndexSettingRequest extends RequestBase { - private final boolean allowNoIndices; - private final String clusterManagerTimeout; - private final ExpandWildcards expandWildcards; - private final boolean flatSettings; - private final boolean ignoreUnavailable; - private final String includeDefaults; - private final boolean local; - private final String masterTimeout; + @Nullable private final Boolean allowNoIndices; + @Nullable private final String clusterManagerTimeout; + @Nullable private final ExpandWildcards expandWildcards; + @Nullable private final Boolean flatSettings; + @Nullable private final Boolean ignoreUnavailable; + @Nullable private final String includeDefaults; + @Nullable private final Boolean local; + @Nullable private final String masterTimeout; public GetSettingsIndexSettingRequest(Builder builder) { this.allowNoIndices = builder.allowNoIndices; @@ -37,7 +37,7 @@ public static GetSettingsIndexSettingRequest of( return fn.apply(new Builder()).build(); } - public final boolean allowNoIndices() { + public final Boolean allowNoIndices() { return this.allowNoIndices; } @@ -49,11 +49,11 @@ public final ExpandWildcards expandWildcards() { return this.expandWildcards; } - public final boolean flatSettings() { + public final Boolean flatSettings() { return this.flatSettings; } - public final boolean ignoreUnavailable() { + public final Boolean ignoreUnavailable() { return this.ignoreUnavailable; } @@ -61,7 +61,7 @@ public final String includeDefaults() { return this.includeDefaults; } - public final boolean local() { + public final Boolean local() { return this.local; } @@ -72,16 +72,16 @@ public final String masterTimeout() { /** Builder for {@link GetSettingsIndexSettingRequest}. */ public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private boolean allowNoIndices; + private Boolean allowNoIndices; private String clusterManagerTimeout; private ExpandWildcards expandWildcards; - private boolean flatSettings; - private boolean ignoreUnavailable; + private Boolean flatSettings; + private Boolean ignoreUnavailable; private String includeDefaults; - private boolean local; + private Boolean local; private String masterTimeout; - public final Builder allowNoIndices(boolean value) { + public final Builder allowNoIndices(Boolean value) { this.allowNoIndices = value; return this; } @@ -101,12 +101,12 @@ public final Builder expandWildcards( return expandWildcards(fn.apply(new ExpandWildcards.Builder()).build()); } - public final Builder flatSettings(boolean value) { + public final Builder flatSettings(Boolean value) { this.flatSettings = value; return this; } - public final Builder ignoreUnavailable(boolean value) { + public final Builder ignoreUnavailable(Boolean value) { this.ignoreUnavailable = value; return this; } @@ -116,7 +116,7 @@ public final Builder includeDefaults(String value) { return this; } - public final Builder local(boolean value) { + public final Builder local(Boolean value) { this.local = value; return this; } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingResponse.java new file mode 100644 index 0000000000..4284457182 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingResponse.java @@ -0,0 +1,55 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class GetSettingsIndexSettingResponse implements JsonpSerializable { + + public GetSettingsIndexSettingResponse(Builder builder) {} + + public static GetSettingsIndexSettingResponse of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {} + + /** Builder for {@link GetSettingsIndexSettingResponse}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + + /** + * Builds a {@link GetSettingsIndexSettingResponse}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public GetSettingsIndexSettingResponse build() { + _checkSingleUse(); + + return new GetSettingsIndexSettingResponse(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, + GetSettingsIndexSettingResponse + ::setupGetSettingsIndexSettingResponseDeserializer); + + protected static void setupGetSettingsIndexSettingResponseDeserializer( + ObjectDeserializer op) {} +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/HealthStatus.java b/java-client/src/generated/java/org/opensearch/client/opensearch/HealthStatus.java new file mode 100644 index 0000000000..6bea21054d --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/HealthStatus.java @@ -0,0 +1,31 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.json.JsonEnum; +import org.opensearch.client.json.JsonpDeserializable; + +@JsonpDeserializable +public enum HealthStatus implements JsonEnum { + Green("green"), + Yellow("yellow"), + Red("red"), + ; + + private final String jsonValue; + private final String[] aliases; + + HealthStatus(String jsonValue, String... aliases) { + this.jsonValue = jsonValue; + this.aliases = aliases; + } + + public String jsonValue() { + return this.jsonValue; + } + + public String[] aliases() { + return this.aliases; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = + new JsonEnum.Deserializer<>(HealthStatus.values()); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/Hits.java b/java-client/src/generated/java/org/opensearch/client/opensearch/Hits.java new file mode 100644 index 0000000000..289b8b6368 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/Hits.java @@ -0,0 +1,159 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class Hits implements JsonpSerializable { + @Nullable private final String id; + @Nullable private final String index; + @Nullable private final Float score; + @Nullable private final JsonData source; + @Nullable private final String type; + @Nullable private final JsonData fields; + + public Hits(Builder builder) { + this.id = builder.id; + this.index = builder.index; + this.score = builder.score; + this.source = builder.source; + this.type = builder.type; + this.fields = builder.fields; + } + + public static Hits of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final String id() { + return this.id; + } + + public final String index() { + return this.index; + } + + public final Float score() { + return this.score; + } + + public final JsonData source() { + return this.source; + } + + public final String type() { + return this.type; + } + + public final JsonData fields() { + return this.fields; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.id != null) { + generator.writeKey("_id"); + generator.write(this.id); + } + + if (this.index != null) { + generator.writeKey("_index"); + generator.write(this.index); + } + + if (this.score != null) { + generator.writeKey("_score"); + generator.write(this.score); + } + + if (this.source != null) { + generator.writeKey("_source"); + this.source.serialize(generator, mapper); + } + + if (this.type != null) { + generator.writeKey("_type"); + generator.write(this.type); + } + + if (this.fields != null) { + generator.writeKey("fields"); + this.fields.serialize(generator, mapper); + } + } + + /** Builder for {@link Hits}. */ + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private String id; + private String index; + private Float score; + private JsonData source; + private String type; + private JsonData fields; + + public final Builder id(String value) { + this.id = value; + return this; + } + + public final Builder index(String value) { + this.index = value; + return this; + } + + public final Builder score(Float value) { + this.score = value; + return this; + } + + public final Builder source(JsonData value) { + this.source = value; + return this; + } + + public final Builder type(String value) { + this.type = value; + return this; + } + + public final Builder fields(JsonData value) { + this.fields = value; + return this; + } + + /** + * Builds a {@link Hits}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public Hits build() { + _checkSingleUse(); + + return new Hits(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy(Builder::new, Hits::setupHitsDeserializer); + + protected static void setupHitsDeserializer(ObjectDeserializer op) { + op.add(Builder::id, JsonpDeserializer.stringDeserializer(), "_id"); + op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "_index"); + op.add(Builder::score, JsonpDeserializer.floatDeserializer(), "_score"); + op.add(Builder::source, JsonData._DESERIALIZER, "_source"); + op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "_type"); + op.add(Builder::fields, JsonData._DESERIALIZER, "fields"); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/HitsMetadata.java b/java-client/src/generated/java/org/opensearch/client/opensearch/HitsMetadata.java new file mode 100644 index 0000000000..ca35e6f0c8 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/HitsMetadata.java @@ -0,0 +1,124 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class HitsMetadata implements JsonpSerializable { + @Nullable private final List hits; + @Nullable private final Double maxScore; + @Nullable private final Total total; + + public HitsMetadata(Builder builder) { + this.hits = ApiTypeHelper.unmodifiable(builder.hits); + this.maxScore = builder.maxScore; + this.total = builder.total; + } + + public static HitsMetadata of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final List hits() { + return this.hits; + } + + public final Double maxScore() { + return this.maxScore; + } + + public final Total total() { + return this.total; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (ApiTypeHelper.isDefined(this.hits)) { + generator.writeKey("hits"); + generator.writeStartArray(); + for (Hits item0 : this.hits) { + item0.serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (this.maxScore != null) { + generator.writeKey("max_score"); + generator.write(this.maxScore); + } + + if (this.total != null) { + generator.writeKey("total"); + this.total.serialize(generator, mapper); + } + } + + /** Builder for {@link HitsMetadata}. */ + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private List hits; + private Double maxScore; + private Total total; + + public final Builder hits(List list) { + this.hits = _listAddAll(this.hits, list); + return this; + } + + public final Builder hits(Hits value, Hits... values) { + this.hits = _listAdd(this.hits, value, values); + return this; + } + + public final Builder hits(Function> fn) { + return hits(fn.apply(new Hits.Builder()).build()); + } + + public final Builder maxScore(Double value) { + this.maxScore = value; + return this; + } + + public final Builder total(Total value) { + this.total = value; + return this; + } + + public final Builder total(Function> fn) { + return total(fn.apply(new Total.Builder()).build()); + } + + /** + * Builds a {@link HitsMetadata}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public HitsMetadata build() { + _checkSingleUse(); + + return new HitsMetadata(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, HitsMetadata::setupHitsMetadataDeserializer); + + protected static void setupHitsMetadataDeserializer( + ObjectDeserializer op) { + op.add(Builder::hits, JsonpDeserializer.arrayDeserializer(Hits._DESERIALIZER), "hits"); + op.add(Builder::maxScore, JsonpDeserializer.doubleDeserializer(), "max_score"); + op.add(Builder::total, Total._DESERIALIZER, "total"); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesRequest.java index 7f92d4c003..0c02ced3d6 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesRequest.java @@ -13,10 +13,10 @@ /** Adds or removes index aliases. */ @JsonpDeserializable public class PostAliasesRequest extends RequestBase implements JsonpSerializable { - private final ActionObjectStructure actions; - private final String clusterManagerTimeout; - private final String masterTimeout; - private final String timeout; + @Nullable private final ActionObjectStructure actions; + @Nullable private final String clusterManagerTimeout; + @Nullable private final String masterTimeout; + @Nullable private final String timeout; public PostAliasesRequest(Builder builder) { this.actions = builder.actions; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesResponse.java new file mode 100644 index 0000000000..9bf32312ed --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesResponse.java @@ -0,0 +1,73 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class PostAliasesResponse implements JsonpSerializable { + + private final boolean acknowledged; + + public PostAliasesResponse(Builder builder) { + this.acknowledged = builder.acknowledged; + } + + public static PostAliasesResponse of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final boolean acknowledged() { + return this.acknowledged; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.acknowledged != null) { + generator.writeKey("acknowledged"); + generator.write(this.acknowledged); + } + } + + /** Builder for {@link PostAliasesResponse}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private boolean acknowledged; + + public final Builder acknowledged(boolean value) { + this.acknowledged = value; + return this; + } + + /** + * Builds a {@link PostAliasesResponse}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public PostAliasesResponse build() { + _checkSingleUse(); + + return new PostAliasesResponse(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, PostAliasesResponse::setupPostAliasesResponseDeserializer); + + protected static void setupPostAliasesResponseDeserializer( + ObjectDeserializer op) { + op.add(Builder::acknowledged, JsonpDeserializer.booleanDeserializer(), "acknowledged"); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreRequest.java index 09dc536214..5906aa4d5a 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreRequest.java @@ -13,9 +13,10 @@ /** Restore one or more indices from a remote backup. */ @JsonpDeserializable public class PostRemoteStoreRestoreRequest extends RequestBase implements JsonpSerializable { - private final String clusterManagerTimeout; + @Nullable private final String clusterManagerTimeout; + private final List indices; - private final boolean waitForCompletion; + @Nullable private final Boolean waitForCompletion; public PostRemoteStoreRestoreRequest(Builder builder) { this.clusterManagerTimeout = builder.clusterManagerTimeout; @@ -36,7 +37,7 @@ public final List indices() { return this.indices; } - public final boolean waitForCompletion() { + public final Boolean waitForCompletion() { return this.waitForCompletion; } @@ -62,7 +63,7 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private String clusterManagerTimeout; private List indices; - private boolean waitForCompletion; + private Boolean waitForCompletion; public final Builder clusterManagerTimeout(String value) { this.clusterManagerTimeout = value; @@ -79,7 +80,7 @@ public final Builder indices(String value, String... values) { return this; } - public final Builder waitForCompletion(boolean value) { + public final Builder waitForCompletion(Boolean value) { this.waitForCompletion = value; return this; } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreResponse.java new file mode 100644 index 0000000000..c84eccf932 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreResponse.java @@ -0,0 +1,99 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class PostRemoteStoreRestoreResponse implements JsonpSerializable { + @Nullable private final Boolean accepted; + @Nullable private final RemoteStoreRestoreInfo remoteStore; + + public PostRemoteStoreRestoreResponse(Builder builder) { + this.accepted = builder.accepted; + this.remoteStore = builder.remoteStore; + } + + public static PostRemoteStoreRestoreResponse of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final Boolean accepted() { + return this.accepted; + } + + public final RemoteStoreRestoreInfo remoteStore() { + return this.remoteStore; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.accepted != null) { + generator.writeKey("accepted"); + generator.write(this.accepted); + } + + if (this.remoteStore != null) { + generator.writeKey("remote_store"); + this.remoteStore.serialize(generator, mapper); + } + } + + /** Builder for {@link PostRemoteStoreRestoreResponse}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private Boolean accepted; + private RemoteStoreRestoreInfo remoteStore; + + public final Builder accepted(Boolean value) { + this.accepted = value; + return this; + } + + public final Builder remoteStore(RemoteStoreRestoreInfo value) { + this.remoteStore = value; + return this; + } + + public final Builder remoteStore( + Function> + fn) { + return remoteStore(fn.apply(new RemoteStoreRestoreInfo.Builder()).build()); + } + + /** + * Builds a {@link PostRemoteStoreRestoreResponse}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public PostRemoteStoreRestoreResponse build() { + _checkSingleUse(); + + return new PostRemoteStoreRestoreResponse(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, + PostRemoteStoreRestoreResponse + ::setupPostRemoteStoreRestoreResponseDeserializer); + + protected static void setupPostRemoteStoreRestoreResponseDeserializer( + ObjectDeserializer op) { + op.add(Builder::accepted, JsonpDeserializer.booleanDeserializer(), "accepted"); + op.add(Builder::remoteStore, RemoteStoreRestoreInfo._DESERIALIZER, "remote_store"); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchRequest.java index 61ff931723..14a0732d0e 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchRequest.java @@ -13,52 +13,52 @@ /** Returns results matching a query. */ @JsonpDeserializable public class PostSearchRequest extends RequestBase implements JsonpSerializable { - private final boolean allowNoIndices; - private final boolean allowPartialSearchResults; - private final boolean analyzeWildcard; - private final String analyzer; - private final int batchedReduceSize; - private final boolean ccsMinimizeRoundtrips; - private final DefaultOperator defaultOperator; - private final String df; - private final String docvalueFields; - private final ExpandWildcards expandWildcards; - private final boolean explain; - private final List fields; - private final int from; - private final boolean ignoreThrottled; - private final boolean ignoreUnavailable; - private final List indicesBoost; - private final boolean lenient; - private final long maxConcurrentShardRequests; - private final int minScore; - private final long preFilterShardSize; - private final String preference; - private final String q; - private final UserDefinedObjectStructure query; - private final boolean requestCache; - private final boolean restTotalHitsAsInt; - private final String routing; - private final String scroll; - private final SearchType searchType; - private final boolean seqNoPrimaryTerm; - private final int size; - private final List sort; - private final String source; - private final List sourceExcludes; - private final List sourceIncludes; - private final String stats; - private final boolean storedFields; - private final String suggestField; - private final SuggestMode suggestMode; - private final long suggestSize; - private final String suggestText; - private final int terminateAfter; - private final String timeout; - private final boolean trackScores; - private final int trackTotalHits; - private final boolean typedKeys; - private final boolean version; + @Nullable private final Boolean allowNoIndices; + @Nullable private final Boolean allowPartialSearchResults; + @Nullable private final Boolean analyzeWildcard; + @Nullable private final String analyzer; + @Nullable private final Integer batchedReduceSize; + @Nullable private final Boolean ccsMinimizeRoundtrips; + @Nullable private final DefaultOperator defaultOperator; + @Nullable private final String df; + @Nullable private final String docvalueFields; + @Nullable private final ExpandWildcards expandWildcards; + @Nullable private final Boolean explain; + @Nullable private final List fields; + @Nullable private final Integer from; + @Nullable private final Boolean ignoreThrottled; + @Nullable private final Boolean ignoreUnavailable; + @Nullable private final List indicesBoost; + @Nullable private final Boolean lenient; + @Nullable private final Long maxConcurrentShardRequests; + @Nullable private final Integer minScore; + @Nullable private final Long preFilterShardSize; + @Nullable private final String preference; + @Nullable private final String q; + @Nullable private final UserDefinedObjectStructure query; + @Nullable private final Boolean requestCache; + @Nullable private final Boolean restTotalHitsAsInt; + @Nullable private final String routing; + @Nullable private final String scroll; + @Nullable private final SearchType searchType; + @Nullable private final Boolean seqNoPrimaryTerm; + @Nullable private final Integer size; + @Nullable private final List sort; + @Nullable private final String source; + @Nullable private final List sourceExcludes; + @Nullable private final List sourceIncludes; + @Nullable private final String stats; + @Nullable private final Boolean storedFields; + @Nullable private final String suggestField; + @Nullable private final SuggestMode suggestMode; + @Nullable private final Long suggestSize; + @Nullable private final String suggestText; + @Nullable private final Integer terminateAfter; + @Nullable private final String timeout; + @Nullable private final Boolean trackScores; + @Nullable private final Integer trackTotalHits; + @Nullable private final Boolean typedKeys; + @Nullable private final Boolean version; public PostSearchRequest(Builder builder) { this.allowNoIndices = builder.allowNoIndices; @@ -113,15 +113,15 @@ public static PostSearchRequest of(Function fields() { return this.fields; } - public final int from() { + public final Integer from() { return this.from; } - public final boolean ignoreThrottled() { + public final Boolean ignoreThrottled() { return this.ignoreThrottled; } - public final boolean ignoreUnavailable() { + public final Boolean ignoreUnavailable() { return this.ignoreUnavailable; } @@ -177,19 +177,19 @@ public final List indicesBoost() { return this.indicesBoost; } - public final boolean lenient() { + public final Boolean lenient() { return this.lenient; } - public final long maxConcurrentShardRequests() { + public final Long maxConcurrentShardRequests() { return this.maxConcurrentShardRequests; } - public final int minScore() { + public final Integer minScore() { return this.minScore; } - public final long preFilterShardSize() { + public final Long preFilterShardSize() { return this.preFilterShardSize; } @@ -205,11 +205,11 @@ public final UserDefinedObjectStructure query() { return this.query; } - public final boolean requestCache() { + public final Boolean requestCache() { return this.requestCache; } - public final boolean restTotalHitsAsInt() { + public final Boolean restTotalHitsAsInt() { return this.restTotalHitsAsInt; } @@ -225,11 +225,11 @@ public final SearchType searchType() { return this.searchType; } - public final boolean seqNoPrimaryTerm() { + public final Boolean seqNoPrimaryTerm() { return this.seqNoPrimaryTerm; } - public final int size() { + public final Integer size() { return this.size; } @@ -253,7 +253,7 @@ public final String stats() { return this.stats; } - public final boolean storedFields() { + public final Boolean storedFields() { return this.storedFields; } @@ -265,7 +265,7 @@ public final SuggestMode suggestMode() { return this.suggestMode; } - public final long suggestSize() { + public final Long suggestSize() { return this.suggestSize; } @@ -273,7 +273,7 @@ public final String suggestText() { return this.suggestText; } - public final int terminateAfter() { + public final Integer terminateAfter() { return this.terminateAfter; } @@ -281,19 +281,19 @@ public final String timeout() { return this.timeout; } - public final boolean trackScores() { + public final Boolean trackScores() { return this.trackScores; } - public final int trackTotalHits() { + public final Integer trackTotalHits() { return this.trackTotalHits; } - public final boolean typedKeys() { + public final Boolean typedKeys() { return this.typedKeys; } - public final boolean version() { + public final Boolean version() { return this.version; } @@ -386,64 +386,64 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** Builder for {@link PostSearchRequest}. */ public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private boolean allowNoIndices; - private boolean allowPartialSearchResults; - private boolean analyzeWildcard; + private Boolean allowNoIndices; + private Boolean allowPartialSearchResults; + private Boolean analyzeWildcard; private String analyzer; - private int batchedReduceSize; - private boolean ccsMinimizeRoundtrips; + private Integer batchedReduceSize; + private Boolean ccsMinimizeRoundtrips; private DefaultOperator defaultOperator; private String df; private String docvalueFields; private ExpandWildcards expandWildcards; - private boolean explain; + private Boolean explain; private List fields; - private int from; - private boolean ignoreThrottled; - private boolean ignoreUnavailable; + private Integer from; + private Boolean ignoreThrottled; + private Boolean ignoreUnavailable; private List indicesBoost; - private boolean lenient; - private long maxConcurrentShardRequests; - private int minScore; - private long preFilterShardSize; + private Boolean lenient; + private Long maxConcurrentShardRequests; + private Integer minScore; + private Long preFilterShardSize; private String preference; private String q; private UserDefinedObjectStructure query; - private boolean requestCache; - private boolean restTotalHitsAsInt; + private Boolean requestCache; + private Boolean restTotalHitsAsInt; private String routing; private String scroll; private SearchType searchType; - private boolean seqNoPrimaryTerm; - private int size; + private Boolean seqNoPrimaryTerm; + private Integer size; private List sort; private String source; private List sourceExcludes; private List sourceIncludes; private String stats; - private boolean storedFields; + private Boolean storedFields; private String suggestField; private SuggestMode suggestMode; - private long suggestSize; + private Long suggestSize; private String suggestText; - private int terminateAfter; + private Integer terminateAfter; private String timeout; - private boolean trackScores; - private int trackTotalHits; - private boolean typedKeys; - private boolean version; + private Boolean trackScores; + private Integer trackTotalHits; + private Boolean typedKeys; + private Boolean version; - public final Builder allowNoIndices(boolean value) { + public final Builder allowNoIndices(Boolean value) { this.allowNoIndices = value; return this; } - public final Builder allowPartialSearchResults(boolean value) { + public final Builder allowPartialSearchResults(Boolean value) { this.allowPartialSearchResults = value; return this; } - public final Builder analyzeWildcard(boolean value) { + public final Builder analyzeWildcard(Boolean value) { this.analyzeWildcard = value; return this; } @@ -453,12 +453,12 @@ public final Builder analyzer(String value) { return this; } - public final Builder batchedReduceSize(int value) { + public final Builder batchedReduceSize(Integer value) { this.batchedReduceSize = value; return this; } - public final Builder ccsMinimizeRoundtrips(boolean value) { + public final Builder ccsMinimizeRoundtrips(Boolean value) { this.ccsMinimizeRoundtrips = value; return this; } @@ -493,7 +493,7 @@ public final Builder expandWildcards( return expandWildcards(fn.apply(new ExpandWildcards.Builder()).build()); } - public final Builder explain(boolean value) { + public final Builder explain(Boolean value) { this.explain = value; return this; } @@ -508,17 +508,17 @@ public final Builder fields(String value, String... values) { return this; } - public final Builder from(int value) { + public final Builder from(Integer value) { this.from = value; return this; } - public final Builder ignoreThrottled(boolean value) { + public final Builder ignoreThrottled(Boolean value) { this.ignoreThrottled = value; return this; } - public final Builder ignoreUnavailable(boolean value) { + public final Builder ignoreUnavailable(Boolean value) { this.ignoreUnavailable = value; return this; } @@ -533,22 +533,22 @@ public final Builder indicesBoost(JsonData value, JsonData... values) { return this; } - public final Builder lenient(boolean value) { + public final Builder lenient(Boolean value) { this.lenient = value; return this; } - public final Builder maxConcurrentShardRequests(long value) { + public final Builder maxConcurrentShardRequests(Long value) { this.maxConcurrentShardRequests = value; return this; } - public final Builder minScore(int value) { + public final Builder minScore(Integer value) { this.minScore = value; return this; } - public final Builder preFilterShardSize(long value) { + public final Builder preFilterShardSize(Long value) { this.preFilterShardSize = value; return this; } @@ -576,12 +576,12 @@ public final Builder query( return query(fn.apply(new UserDefinedObjectStructure.Builder()).build()); } - public final Builder requestCache(boolean value) { + public final Builder requestCache(Boolean value) { this.requestCache = value; return this; } - public final Builder restTotalHitsAsInt(boolean value) { + public final Builder restTotalHitsAsInt(Boolean value) { this.restTotalHitsAsInt = value; return this; } @@ -606,12 +606,12 @@ public final Builder searchType( return searchType(fn.apply(new SearchType.Builder()).build()); } - public final Builder seqNoPrimaryTerm(boolean value) { + public final Builder seqNoPrimaryTerm(Boolean value) { this.seqNoPrimaryTerm = value; return this; } - public final Builder size(int value) { + public final Builder size(Integer value) { this.size = value; return this; } @@ -656,7 +656,7 @@ public final Builder stats(String value) { return this; } - public final Builder storedFields(boolean value) { + public final Builder storedFields(Boolean value) { this.storedFields = value; return this; } @@ -676,7 +676,7 @@ public final Builder suggestMode( return suggestMode(fn.apply(new SuggestMode.Builder()).build()); } - public final Builder suggestSize(long value) { + public final Builder suggestSize(Long value) { this.suggestSize = value; return this; } @@ -686,7 +686,7 @@ public final Builder suggestText(String value) { return this; } - public final Builder terminateAfter(int value) { + public final Builder terminateAfter(Integer value) { this.terminateAfter = value; return this; } @@ -696,22 +696,22 @@ public final Builder timeout(String value) { return this; } - public final Builder trackScores(boolean value) { + public final Builder trackScores(Boolean value) { this.trackScores = value; return this; } - public final Builder trackTotalHits(int value) { + public final Builder trackTotalHits(Integer value) { this.trackTotalHits = value; return this; } - public final Builder typedKeys(boolean value) { + public final Builder typedKeys(Boolean value) { this.typedKeys = value; return this; } - public final Builder version(boolean value) { + public final Builder version(Boolean value) { this.version = value; return this; } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchResponse.java new file mode 100644 index 0000000000..5d231361ff --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchResponse.java @@ -0,0 +1,153 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class PostSearchResponse implements JsonpSerializable { + @Nullable private final String scrollId; + @Nullable private final ShardStatistics shards; + @Nullable private final HitsMetadata hits; + @Nullable private final Boolean timedOut; + @Nullable private final Long took; + + public PostSearchResponse(Builder builder) { + this.scrollId = builder.scrollId; + this.shards = builder.shards; + this.hits = builder.hits; + this.timedOut = builder.timedOut; + this.took = builder.took; + } + + public static PostSearchResponse of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final String scrollId() { + return this.scrollId; + } + + public final ShardStatistics shards() { + return this.shards; + } + + public final HitsMetadata hits() { + return this.hits; + } + + public final Boolean timedOut() { + return this.timedOut; + } + + public final Long took() { + return this.took; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.scrollId != null) { + generator.writeKey("_scroll_id"); + generator.write(this.scrollId); + } + + if (this.shards != null) { + generator.writeKey("_shards"); + this.shards.serialize(generator, mapper); + } + + if (this.hits != null) { + generator.writeKey("hits"); + this.hits.serialize(generator, mapper); + } + + if (this.timedOut != null) { + generator.writeKey("timed_out"); + generator.write(this.timedOut); + } + + if (this.took != null) { + generator.writeKey("took"); + generator.write(this.took); + } + } + + /** Builder for {@link PostSearchResponse}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private String scrollId; + private ShardStatistics shards; + private HitsMetadata hits; + private Boolean timedOut; + private Long took; + + public final Builder scrollId(String value) { + this.scrollId = value; + return this; + } + + public final Builder shards(ShardStatistics value) { + this.shards = value; + return this; + } + + public final Builder shards( + Function> fn) { + return shards(fn.apply(new ShardStatistics.Builder()).build()); + } + + public final Builder hits(HitsMetadata value) { + this.hits = value; + return this; + } + + public final Builder hits(Function> fn) { + return hits(fn.apply(new HitsMetadata.Builder()).build()); + } + + public final Builder timedOut(Boolean value) { + this.timedOut = value; + return this; + } + + public final Builder took(Long value) { + this.took = value; + return this; + } + + /** + * Builds a {@link PostSearchResponse}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public PostSearchResponse build() { + _checkSingleUse(); + + return new PostSearchResponse(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, PostSearchResponse::setupPostSearchResponseDeserializer); + + protected static void setupPostSearchResponseDeserializer( + ObjectDeserializer op) { + op.add(Builder::scrollId, JsonpDeserializer.stringDeserializer(), "_scroll_id"); + op.add(Builder::shards, ShardStatistics._DESERIALIZER, "_shards"); + op.add(Builder::hits, HitsMetadata._DESERIALIZER, "hits"); + op.add(Builder::timedOut, JsonpDeserializer.booleanDeserializer(), "timed_out"); + op.add(Builder::took, JsonpDeserializer.longDeserializer(), "took"); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java index 16c12646c5..f79d076cf1 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java @@ -13,52 +13,52 @@ /** Returns results matching a query. */ @JsonpDeserializable public class PostSearchWithIndexRequest extends RequestBase implements JsonpSerializable { - private final boolean allowNoIndices; - private final boolean allowPartialSearchResults; - private final boolean analyzeWildcard; - private final String analyzer; - private final int batchedReduceSize; - private final boolean ccsMinimizeRoundtrips; - private final DefaultOperator defaultOperator; - private final String df; - private final String docvalueFields; - private final ExpandWildcards expandWildcards; - private final boolean explain; - private final List fields; - private final int from; - private final boolean ignoreThrottled; - private final boolean ignoreUnavailable; - private final List indicesBoost; - private final boolean lenient; - private final long maxConcurrentShardRequests; - private final int minScore; - private final long preFilterShardSize; - private final String preference; - private final String q; - private final UserDefinedObjectStructure query; - private final boolean requestCache; - private final boolean restTotalHitsAsInt; - private final String routing; - private final String scroll; - private final SearchType searchType; - private final boolean seqNoPrimaryTerm; - private final int size; - private final List sort; - private final String source; - private final List sourceExcludes; - private final List sourceIncludes; - private final String stats; - private final boolean storedFields; - private final String suggestField; - private final SuggestMode suggestMode; - private final long suggestSize; - private final String suggestText; - private final int terminateAfter; - private final String timeout; - private final boolean trackScores; - private final int trackTotalHits; - private final boolean typedKeys; - private final boolean version; + @Nullable private final Boolean allowNoIndices; + @Nullable private final Boolean allowPartialSearchResults; + @Nullable private final Boolean analyzeWildcard; + @Nullable private final String analyzer; + @Nullable private final Integer batchedReduceSize; + @Nullable private final Boolean ccsMinimizeRoundtrips; + @Nullable private final DefaultOperator defaultOperator; + @Nullable private final String df; + @Nullable private final String docvalueFields; + @Nullable private final ExpandWildcards expandWildcards; + @Nullable private final Boolean explain; + @Nullable private final List fields; + @Nullable private final Integer from; + @Nullable private final Boolean ignoreThrottled; + @Nullable private final Boolean ignoreUnavailable; + @Nullable private final List indicesBoost; + @Nullable private final Boolean lenient; + @Nullable private final Long maxConcurrentShardRequests; + @Nullable private final Integer minScore; + @Nullable private final Long preFilterShardSize; + @Nullable private final String preference; + @Nullable private final String q; + @Nullable private final UserDefinedObjectStructure query; + @Nullable private final Boolean requestCache; + @Nullable private final Boolean restTotalHitsAsInt; + @Nullable private final String routing; + @Nullable private final String scroll; + @Nullable private final SearchType searchType; + @Nullable private final Boolean seqNoPrimaryTerm; + @Nullable private final Integer size; + @Nullable private final List sort; + @Nullable private final String source; + @Nullable private final List sourceExcludes; + @Nullable private final List sourceIncludes; + @Nullable private final String stats; + @Nullable private final Boolean storedFields; + @Nullable private final String suggestField; + @Nullable private final SuggestMode suggestMode; + @Nullable private final Long suggestSize; + @Nullable private final String suggestText; + @Nullable private final Integer terminateAfter; + @Nullable private final String timeout; + @Nullable private final Boolean trackScores; + @Nullable private final Integer trackTotalHits; + @Nullable private final Boolean typedKeys; + @Nullable private final Boolean version; public PostSearchWithIndexRequest(Builder builder) { this.allowNoIndices = builder.allowNoIndices; @@ -114,15 +114,15 @@ public static PostSearchWithIndexRequest of( return fn.apply(new Builder()).build(); } - public final boolean allowNoIndices() { + public final Boolean allowNoIndices() { return this.allowNoIndices; } - public final boolean allowPartialSearchResults() { + public final Boolean allowPartialSearchResults() { return this.allowPartialSearchResults; } - public final boolean analyzeWildcard() { + public final Boolean analyzeWildcard() { return this.analyzeWildcard; } @@ -130,11 +130,11 @@ public final String analyzer() { return this.analyzer; } - public final int batchedReduceSize() { + public final Integer batchedReduceSize() { return this.batchedReduceSize; } - public final boolean ccsMinimizeRoundtrips() { + public final Boolean ccsMinimizeRoundtrips() { return this.ccsMinimizeRoundtrips; } @@ -154,7 +154,7 @@ public final ExpandWildcards expandWildcards() { return this.expandWildcards; } - public final boolean explain() { + public final Boolean explain() { return this.explain; } @@ -162,15 +162,15 @@ public final List fields() { return this.fields; } - public final int from() { + public final Integer from() { return this.from; } - public final boolean ignoreThrottled() { + public final Boolean ignoreThrottled() { return this.ignoreThrottled; } - public final boolean ignoreUnavailable() { + public final Boolean ignoreUnavailable() { return this.ignoreUnavailable; } @@ -178,19 +178,19 @@ public final List indicesBoost() { return this.indicesBoost; } - public final boolean lenient() { + public final Boolean lenient() { return this.lenient; } - public final long maxConcurrentShardRequests() { + public final Long maxConcurrentShardRequests() { return this.maxConcurrentShardRequests; } - public final int minScore() { + public final Integer minScore() { return this.minScore; } - public final long preFilterShardSize() { + public final Long preFilterShardSize() { return this.preFilterShardSize; } @@ -206,11 +206,11 @@ public final UserDefinedObjectStructure query() { return this.query; } - public final boolean requestCache() { + public final Boolean requestCache() { return this.requestCache; } - public final boolean restTotalHitsAsInt() { + public final Boolean restTotalHitsAsInt() { return this.restTotalHitsAsInt; } @@ -226,11 +226,11 @@ public final SearchType searchType() { return this.searchType; } - public final boolean seqNoPrimaryTerm() { + public final Boolean seqNoPrimaryTerm() { return this.seqNoPrimaryTerm; } - public final int size() { + public final Integer size() { return this.size; } @@ -254,7 +254,7 @@ public final String stats() { return this.stats; } - public final boolean storedFields() { + public final Boolean storedFields() { return this.storedFields; } @@ -266,7 +266,7 @@ public final SuggestMode suggestMode() { return this.suggestMode; } - public final long suggestSize() { + public final Long suggestSize() { return this.suggestSize; } @@ -274,7 +274,7 @@ public final String suggestText() { return this.suggestText; } - public final int terminateAfter() { + public final Integer terminateAfter() { return this.terminateAfter; } @@ -282,19 +282,19 @@ public final String timeout() { return this.timeout; } - public final boolean trackScores() { + public final Boolean trackScores() { return this.trackScores; } - public final int trackTotalHits() { + public final Integer trackTotalHits() { return this.trackTotalHits; } - public final boolean typedKeys() { + public final Boolean typedKeys() { return this.typedKeys; } - public final boolean version() { + public final Boolean version() { return this.version; } @@ -387,64 +387,64 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** Builder for {@link PostSearchWithIndexRequest}. */ public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private boolean allowNoIndices; - private boolean allowPartialSearchResults; - private boolean analyzeWildcard; + private Boolean allowNoIndices; + private Boolean allowPartialSearchResults; + private Boolean analyzeWildcard; private String analyzer; - private int batchedReduceSize; - private boolean ccsMinimizeRoundtrips; + private Integer batchedReduceSize; + private Boolean ccsMinimizeRoundtrips; private DefaultOperator defaultOperator; private String df; private String docvalueFields; private ExpandWildcards expandWildcards; - private boolean explain; + private Boolean explain; private List fields; - private int from; - private boolean ignoreThrottled; - private boolean ignoreUnavailable; + private Integer from; + private Boolean ignoreThrottled; + private Boolean ignoreUnavailable; private List indicesBoost; - private boolean lenient; - private long maxConcurrentShardRequests; - private int minScore; - private long preFilterShardSize; + private Boolean lenient; + private Long maxConcurrentShardRequests; + private Integer minScore; + private Long preFilterShardSize; private String preference; private String q; private UserDefinedObjectStructure query; - private boolean requestCache; - private boolean restTotalHitsAsInt; + private Boolean requestCache; + private Boolean restTotalHitsAsInt; private String routing; private String scroll; private SearchType searchType; - private boolean seqNoPrimaryTerm; - private int size; + private Boolean seqNoPrimaryTerm; + private Integer size; private List sort; private String source; private List sourceExcludes; private List sourceIncludes; private String stats; - private boolean storedFields; + private Boolean storedFields; private String suggestField; private SuggestMode suggestMode; - private long suggestSize; + private Long suggestSize; private String suggestText; - private int terminateAfter; + private Integer terminateAfter; private String timeout; - private boolean trackScores; - private int trackTotalHits; - private boolean typedKeys; - private boolean version; + private Boolean trackScores; + private Integer trackTotalHits; + private Boolean typedKeys; + private Boolean version; - public final Builder allowNoIndices(boolean value) { + public final Builder allowNoIndices(Boolean value) { this.allowNoIndices = value; return this; } - public final Builder allowPartialSearchResults(boolean value) { + public final Builder allowPartialSearchResults(Boolean value) { this.allowPartialSearchResults = value; return this; } - public final Builder analyzeWildcard(boolean value) { + public final Builder analyzeWildcard(Boolean value) { this.analyzeWildcard = value; return this; } @@ -454,12 +454,12 @@ public final Builder analyzer(String value) { return this; } - public final Builder batchedReduceSize(int value) { + public final Builder batchedReduceSize(Integer value) { this.batchedReduceSize = value; return this; } - public final Builder ccsMinimizeRoundtrips(boolean value) { + public final Builder ccsMinimizeRoundtrips(Boolean value) { this.ccsMinimizeRoundtrips = value; return this; } @@ -494,7 +494,7 @@ public final Builder expandWildcards( return expandWildcards(fn.apply(new ExpandWildcards.Builder()).build()); } - public final Builder explain(boolean value) { + public final Builder explain(Boolean value) { this.explain = value; return this; } @@ -509,17 +509,17 @@ public final Builder fields(String value, String... values) { return this; } - public final Builder from(int value) { + public final Builder from(Integer value) { this.from = value; return this; } - public final Builder ignoreThrottled(boolean value) { + public final Builder ignoreThrottled(Boolean value) { this.ignoreThrottled = value; return this; } - public final Builder ignoreUnavailable(boolean value) { + public final Builder ignoreUnavailable(Boolean value) { this.ignoreUnavailable = value; return this; } @@ -534,22 +534,22 @@ public final Builder indicesBoost(JsonData value, JsonData... values) { return this; } - public final Builder lenient(boolean value) { + public final Builder lenient(Boolean value) { this.lenient = value; return this; } - public final Builder maxConcurrentShardRequests(long value) { + public final Builder maxConcurrentShardRequests(Long value) { this.maxConcurrentShardRequests = value; return this; } - public final Builder minScore(int value) { + public final Builder minScore(Integer value) { this.minScore = value; return this; } - public final Builder preFilterShardSize(long value) { + public final Builder preFilterShardSize(Long value) { this.preFilterShardSize = value; return this; } @@ -577,12 +577,12 @@ public final Builder query( return query(fn.apply(new UserDefinedObjectStructure.Builder()).build()); } - public final Builder requestCache(boolean value) { + public final Builder requestCache(Boolean value) { this.requestCache = value; return this; } - public final Builder restTotalHitsAsInt(boolean value) { + public final Builder restTotalHitsAsInt(Boolean value) { this.restTotalHitsAsInt = value; return this; } @@ -607,12 +607,12 @@ public final Builder searchType( return searchType(fn.apply(new SearchType.Builder()).build()); } - public final Builder seqNoPrimaryTerm(boolean value) { + public final Builder seqNoPrimaryTerm(Boolean value) { this.seqNoPrimaryTerm = value; return this; } - public final Builder size(int value) { + public final Builder size(Integer value) { this.size = value; return this; } @@ -657,7 +657,7 @@ public final Builder stats(String value) { return this; } - public final Builder storedFields(boolean value) { + public final Builder storedFields(Boolean value) { this.storedFields = value; return this; } @@ -677,7 +677,7 @@ public final Builder suggestMode( return suggestMode(fn.apply(new SuggestMode.Builder()).build()); } - public final Builder suggestSize(long value) { + public final Builder suggestSize(Long value) { this.suggestSize = value; return this; } @@ -687,7 +687,7 @@ public final Builder suggestText(String value) { return this; } - public final Builder terminateAfter(int value) { + public final Builder terminateAfter(Integer value) { this.terminateAfter = value; return this; } @@ -697,22 +697,22 @@ public final Builder timeout(String value) { return this; } - public final Builder trackScores(boolean value) { + public final Builder trackScores(Boolean value) { this.trackScores = value; return this; } - public final Builder trackTotalHits(int value) { + public final Builder trackTotalHits(Integer value) { this.trackTotalHits = value; return this; } - public final Builder typedKeys(boolean value) { + public final Builder typedKeys(Boolean value) { this.typedKeys = value; return this; } - public final Builder version(boolean value) { + public final Builder version(Boolean value) { this.version = value; return this; } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexResponse.java new file mode 100644 index 0000000000..074b00b7ed --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexResponse.java @@ -0,0 +1,155 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class PostSearchWithIndexResponse implements JsonpSerializable { + @Nullable private final String scrollId; + @Nullable private final ShardStatistics shards; + @Nullable private final HitsMetadata hits; + @Nullable private final Boolean timedOut; + @Nullable private final Long took; + + public PostSearchWithIndexResponse(Builder builder) { + this.scrollId = builder.scrollId; + this.shards = builder.shards; + this.hits = builder.hits; + this.timedOut = builder.timedOut; + this.took = builder.took; + } + + public static PostSearchWithIndexResponse of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final String scrollId() { + return this.scrollId; + } + + public final ShardStatistics shards() { + return this.shards; + } + + public final HitsMetadata hits() { + return this.hits; + } + + public final Boolean timedOut() { + return this.timedOut; + } + + public final Long took() { + return this.took; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.scrollId != null) { + generator.writeKey("_scroll_id"); + generator.write(this.scrollId); + } + + if (this.shards != null) { + generator.writeKey("_shards"); + this.shards.serialize(generator, mapper); + } + + if (this.hits != null) { + generator.writeKey("hits"); + this.hits.serialize(generator, mapper); + } + + if (this.timedOut != null) { + generator.writeKey("timed_out"); + generator.write(this.timedOut); + } + + if (this.took != null) { + generator.writeKey("took"); + generator.write(this.took); + } + } + + /** Builder for {@link PostSearchWithIndexResponse}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private String scrollId; + private ShardStatistics shards; + private HitsMetadata hits; + private Boolean timedOut; + private Long took; + + public final Builder scrollId(String value) { + this.scrollId = value; + return this; + } + + public final Builder shards(ShardStatistics value) { + this.shards = value; + return this; + } + + public final Builder shards( + Function> fn) { + return shards(fn.apply(new ShardStatistics.Builder()).build()); + } + + public final Builder hits(HitsMetadata value) { + this.hits = value; + return this; + } + + public final Builder hits(Function> fn) { + return hits(fn.apply(new HitsMetadata.Builder()).build()); + } + + public final Builder timedOut(Boolean value) { + this.timedOut = value; + return this; + } + + public final Builder took(Long value) { + this.took = value; + return this; + } + + /** + * Builds a {@link PostSearchWithIndexResponse}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public PostSearchWithIndexResponse build() { + _checkSingleUse(); + + return new PostSearchWithIndexResponse(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, + PostSearchWithIndexResponse::setupPostSearchWithIndexResponseDeserializer); + + protected static void setupPostSearchWithIndexResponseDeserializer( + ObjectDeserializer op) { + op.add(Builder::scrollId, JsonpDeserializer.stringDeserializer(), "_scroll_id"); + op.add(Builder::shards, ShardStatistics._DESERIALIZER, "_shards"); + op.add(Builder::hits, HitsMetadata._DESERIALIZER, "hits"); + op.add(Builder::timedOut, JsonpDeserializer.booleanDeserializer(), "timed_out"); + op.add(Builder::took, JsonpDeserializer.longDeserializer(), "took"); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java index 5587a1c0a1..58c250ee7c 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java @@ -13,14 +13,14 @@ /** Creates index mappings. */ @JsonpDeserializable public class PutCreateIndexRequest extends RequestBase implements JsonpSerializable { - private final Map aliases; - private final String clusterManagerTimeout; - private final boolean includeTypeName; - private final Map mapping; - private final String masterTimeout; - private final Map settings; - private final String timeout; - private final String waitForActiveShards; + @Nullable private final Map aliases; + @Nullable private final String clusterManagerTimeout; + @Nullable private final Boolean includeTypeName; + @Nullable private final Map mapping; + @Nullable private final String masterTimeout; + @Nullable private final Map settings; + @Nullable private final String timeout; + @Nullable private final String waitForActiveShards; public PutCreateIndexRequest(Builder builder) { this.aliases = ApiTypeHelper.unmodifiable(builder.aliases); @@ -46,7 +46,7 @@ public final String clusterManagerTimeout() { return this.clusterManagerTimeout; } - public final boolean includeTypeName() { + public final Boolean includeTypeName() { return this.includeTypeName; } @@ -113,7 +113,7 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private Map aliases; private String clusterManagerTimeout; - private boolean includeTypeName; + private Boolean includeTypeName; private Map mapping; private String masterTimeout; private Map settings; @@ -135,7 +135,7 @@ public final Builder clusterManagerTimeout(String value) { return this; } - public final Builder includeTypeName(boolean value) { + public final Builder includeTypeName(Boolean value) { this.includeTypeName = value; return this; } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexResponse.java new file mode 100644 index 0000000000..3c47030919 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexResponse.java @@ -0,0 +1,115 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class PutCreateIndexResponse implements JsonpSerializable { + + private final boolean acknowledged; + + private final String index; + + private final boolean shardsAcknowledged; + + public PutCreateIndexResponse(Builder builder) { + this.acknowledged = builder.acknowledged; + this.index = builder.index; + this.shardsAcknowledged = builder.shardsAcknowledged; + } + + public static PutCreateIndexResponse of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final boolean acknowledged() { + return this.acknowledged; + } + + public final String index() { + return this.index; + } + + public final boolean shardsAcknowledged() { + return this.shardsAcknowledged; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.acknowledged != null) { + generator.writeKey("acknowledged"); + generator.write(this.acknowledged); + } + + if (this.index != null) { + generator.writeKey("index"); + generator.write(this.index); + } + + if (this.shardsAcknowledged != null) { + generator.writeKey("shards_acknowledged"); + generator.write(this.shardsAcknowledged); + } + } + + /** Builder for {@link PutCreateIndexResponse}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private boolean acknowledged; + private String index; + private boolean shardsAcknowledged; + + public final Builder acknowledged(boolean value) { + this.acknowledged = value; + return this; + } + + public final Builder index(String value) { + this.index = value; + return this; + } + + public final Builder shardsAcknowledged(boolean value) { + this.shardsAcknowledged = value; + return this; + } + + /** + * Builds a {@link PutCreateIndexResponse}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public PutCreateIndexResponse build() { + _checkSingleUse(); + + return new PutCreateIndexResponse(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, PutCreateIndexResponse::setupPutCreateIndexResponseDeserializer); + + protected static void setupPutCreateIndexResponseDeserializer( + ObjectDeserializer op) { + op.add(Builder::acknowledged, JsonpDeserializer.booleanDeserializer(), "acknowledged"); + op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "index"); + op.add( + Builder::shardsAcknowledged, + JsonpDeserializer.booleanDeserializer(), + "shards_acknowledged"); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java index 04e336cf75..5bc16aea49 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java @@ -13,15 +13,15 @@ /** The put mapping API operation lets you add new mappings and fields to an index. */ @JsonpDeserializable public class PutIndexMappingWithIndexRequest extends RequestBase implements JsonpSerializable { - private final boolean allowNoIndices; - private final String clusterManagerTimeout; - private final ExpandWildcards expandWildcards; - private final boolean ignoreUnavailable; - private final boolean includeTypeName; - private final String masterTimeout; - private final JsonData properties; - private final String timeout; - private final boolean writeIndexOnly; + @Nullable private final Boolean allowNoIndices; + @Nullable private final String clusterManagerTimeout; + @Nullable private final ExpandWildcards expandWildcards; + @Nullable private final Boolean ignoreUnavailable; + @Nullable private final Boolean includeTypeName; + @Nullable private final String masterTimeout; + @Nullable private final JsonData properties; + @Nullable private final String timeout; + @Nullable private final Boolean writeIndexOnly; public PutIndexMappingWithIndexRequest(Builder builder) { this.allowNoIndices = builder.allowNoIndices; @@ -40,7 +40,7 @@ public static PutIndexMappingWithIndexRequest of( return fn.apply(new Builder()).build(); } - public final boolean allowNoIndices() { + public final Boolean allowNoIndices() { return this.allowNoIndices; } @@ -52,11 +52,11 @@ public final ExpandWildcards expandWildcards() { return this.expandWildcards; } - public final boolean ignoreUnavailable() { + public final Boolean ignoreUnavailable() { return this.ignoreUnavailable; } - public final boolean includeTypeName() { + public final Boolean includeTypeName() { return this.includeTypeName; } @@ -72,7 +72,7 @@ public final String timeout() { return this.timeout; } - public final boolean writeIndexOnly() { + public final Boolean writeIndexOnly() { return this.writeIndexOnly; } @@ -92,17 +92,17 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** Builder for {@link PutIndexMappingWithIndexRequest}. */ public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private boolean allowNoIndices; + private Boolean allowNoIndices; private String clusterManagerTimeout; private ExpandWildcards expandWildcards; - private boolean ignoreUnavailable; - private boolean includeTypeName; + private Boolean ignoreUnavailable; + private Boolean includeTypeName; private String masterTimeout; private JsonData properties; private String timeout; - private boolean writeIndexOnly; + private Boolean writeIndexOnly; - public final Builder allowNoIndices(boolean value) { + public final Builder allowNoIndices(Boolean value) { this.allowNoIndices = value; return this; } @@ -122,12 +122,12 @@ public final Builder expandWildcards( return expandWildcards(fn.apply(new ExpandWildcards.Builder()).build()); } - public final Builder ignoreUnavailable(boolean value) { + public final Builder ignoreUnavailable(Boolean value) { this.ignoreUnavailable = value; return this; } - public final Builder includeTypeName(boolean value) { + public final Builder includeTypeName(Boolean value) { this.includeTypeName = value; return this; } @@ -147,7 +147,7 @@ public final Builder timeout(String value) { return this; } - public final Builder writeIndexOnly(boolean value) { + public final Builder writeIndexOnly(Boolean value) { this.writeIndexOnly = value; return this; } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexResponse.java new file mode 100644 index 0000000000..9213f0e717 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexResponse.java @@ -0,0 +1,75 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class PutIndexMappingWithIndexResponse implements JsonpSerializable { + @Nullable private final Boolean acknowledged; + + public PutIndexMappingWithIndexResponse(Builder builder) { + this.acknowledged = builder.acknowledged; + } + + public static PutIndexMappingWithIndexResponse of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final Boolean acknowledged() { + return this.acknowledged; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.acknowledged != null) { + generator.writeKey("acknowledged"); + generator.write(this.acknowledged); + } + } + + /** Builder for {@link PutIndexMappingWithIndexResponse}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private Boolean acknowledged; + + public final Builder acknowledged(Boolean value) { + this.acknowledged = value; + return this; + } + + /** + * Builds a {@link PutIndexMappingWithIndexResponse}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public PutIndexMappingWithIndexResponse build() { + _checkSingleUse(); + + return new PutIndexMappingWithIndexResponse(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, + PutIndexMappingWithIndexResponse + ::setupPutIndexMappingWithIndexResponseDeserializer); + + protected static void setupPutIndexMappingWithIndexResponseDeserializer( + ObjectDeserializer op) { + op.add(Builder::acknowledged, JsonpDeserializer.booleanDeserializer(), "acknowledged"); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsRequest.java index 6380fa9d3e..d7cf7563ff 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsRequest.java @@ -13,12 +13,12 @@ /** Updates the cluster settings. */ @JsonpDeserializable public class PutUpdateClusterSettingsRequest extends RequestBase implements JsonpSerializable { - private final String clusterManagerTimeout; - private final boolean flatSettings; - private final String masterTimeout; - private final Map persistent; - private final String timeout; - private final Map transient_; + @Nullable private final String clusterManagerTimeout; + @Nullable private final Boolean flatSettings; + @Nullable private final String masterTimeout; + @Nullable private final Map persistent; + @Nullable private final String timeout; + @Nullable private final Map transient_; public PutUpdateClusterSettingsRequest(Builder builder) { this.clusterManagerTimeout = builder.clusterManagerTimeout; @@ -38,7 +38,7 @@ public final String clusterManagerTimeout() { return this.clusterManagerTimeout; } - public final boolean flatSettings() { + public final Boolean flatSettings() { return this.flatSettings; } @@ -90,7 +90,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private String clusterManagerTimeout; - private boolean flatSettings; + private Boolean flatSettings; private String masterTimeout; private Map persistent; private String timeout; @@ -101,7 +101,7 @@ public final Builder clusterManagerTimeout(String value) { return this; } - public final Builder flatSettings(boolean value) { + public final Builder flatSettings(Boolean value) { this.flatSettings = value; return this; } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsResponse.java new file mode 100644 index 0000000000..0ea1dedb68 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsResponse.java @@ -0,0 +1,137 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class PutUpdateClusterSettingsResponse implements JsonpSerializable { + @Nullable private final Boolean acknowledged; + @Nullable private final Map persistent; + @Nullable private final Map transient_; + + public PutUpdateClusterSettingsResponse(Builder builder) { + this.acknowledged = builder.acknowledged; + this.persistent = ApiTypeHelper.unmodifiable(builder.persistent); + this.transient_ = ApiTypeHelper.unmodifiable(builder.transient_); + } + + public static PutUpdateClusterSettingsResponse of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final Boolean acknowledged() { + return this.acknowledged; + } + + public final Map persistent() { + return this.persistent; + } + + public final Map transient_() { + return this.transient_; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.acknowledged != null) { + generator.writeKey("acknowledged"); + generator.write(this.acknowledged); + } + + if (ApiTypeHelper.isDefined(this.persistent)) { + generator.writeKey("persistent"); + generator.writeStartObject(); + for (Map.Entry item0 : this.persistent.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (ApiTypeHelper.isDefined(this.transient_)) { + generator.writeKey("transient"); + generator.writeStartObject(); + for (Map.Entry item0 : this.transient_.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + } + + /** Builder for {@link PutUpdateClusterSettingsResponse}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private Boolean acknowledged; + private Map persistent; + private Map transient_; + + public final Builder acknowledged(Boolean value) { + this.acknowledged = value; + return this; + } + + public final Builder persistent(Map map) { + this.persistent = _mapPutAll(this.persistent, map); + return this; + } + + public final Builder persistent(String key, JsonData value) { + this.persistent = _mapPut(this.persistent, key, value); + return this; + } + + public final Builder transient_(Map map) { + this.transient_ = _mapPutAll(this.transient_, map); + return this; + } + + public final Builder transient_(String key, JsonData value) { + this.transient_ = _mapPut(this.transient_, key, value); + return this; + } + + /** + * Builds a {@link PutUpdateClusterSettingsResponse}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public PutUpdateClusterSettingsResponse build() { + _checkSingleUse(); + + return new PutUpdateClusterSettingsResponse(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, + PutUpdateClusterSettingsResponse + ::setupPutUpdateClusterSettingsResponseDeserializer); + + protected static void setupPutUpdateClusterSettingsResponseDeserializer( + ObjectDeserializer op) { + op.add(Builder::acknowledged, JsonpDeserializer.booleanDeserializer(), "acknowledged"); + op.add( + Builder::persistent, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "persistent"); + op.add( + Builder::transient_, + JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), + "transient"); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/Relation.java b/java-client/src/generated/java/org/opensearch/client/opensearch/Relation.java new file mode 100644 index 0000000000..6f4a04142b --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/Relation.java @@ -0,0 +1,30 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.json.JsonEnum; +import org.opensearch.client.json.JsonpDeserializable; + +@JsonpDeserializable +public enum Relation implements JsonEnum { + Eq("eq"), + Gte("gte"), + ; + + private final String jsonValue; + private final String[] aliases; + + Relation(String jsonValue, String... aliases) { + this.jsonValue = jsonValue; + this.aliases = aliases; + } + + public String jsonValue() { + return this.jsonValue; + } + + public String[] aliases() { + return this.aliases; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = + new JsonEnum.Deserializer<>(Relation.values()); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreInfo.java b/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreInfo.java new file mode 100644 index 0000000000..d28202206b --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreInfo.java @@ -0,0 +1,129 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class RemoteStoreRestoreInfo implements JsonpSerializable { + @Nullable private final List indices; + @Nullable private final RemoteStoreRestoreShardsInfo shards; + @Nullable private final String snapshot; + + public RemoteStoreRestoreInfo(Builder builder) { + this.indices = ApiTypeHelper.unmodifiable(builder.indices); + this.shards = builder.shards; + this.snapshot = builder.snapshot; + } + + public static RemoteStoreRestoreInfo of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final List indices() { + return this.indices; + } + + public final RemoteStoreRestoreShardsInfo shards() { + return this.shards; + } + + public final String snapshot() { + return this.snapshot; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (ApiTypeHelper.isDefined(this.indices)) { + generator.writeKey("indices"); + generator.writeStartArray(); + for (String item0 : this.indices) { + generator.write(item0); + } + generator.writeEnd(); + } + + if (this.shards != null) { + generator.writeKey("shards"); + this.shards.serialize(generator, mapper); + } + + if (this.snapshot != null) { + generator.writeKey("snapshot"); + generator.write(this.snapshot); + } + } + + /** Builder for {@link RemoteStoreRestoreInfo}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private List indices; + private RemoteStoreRestoreShardsInfo shards; + private String snapshot; + + public final Builder indices(List list) { + this.indices = _listAddAll(this.indices, list); + return this; + } + + public final Builder indices(String value, String... values) { + this.indices = _listAdd(this.indices, value, values); + return this; + } + + public final Builder shards(RemoteStoreRestoreShardsInfo value) { + this.shards = value; + return this; + } + + public final Builder shards( + Function< + RemoteStoreRestoreShardsInfo.Builder, + ObjectBuilder> + fn) { + return shards(fn.apply(new RemoteStoreRestoreShardsInfo.Builder()).build()); + } + + public final Builder snapshot(String value) { + this.snapshot = value; + return this; + } + + /** + * Builds a {@link RemoteStoreRestoreInfo}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public RemoteStoreRestoreInfo build() { + _checkSingleUse(); + + return new RemoteStoreRestoreInfo(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, RemoteStoreRestoreInfo::setupRemoteStoreRestoreInfoDeserializer); + + protected static void setupRemoteStoreRestoreInfoDeserializer( + ObjectDeserializer op) { + op.add( + Builder::indices, + JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), + "indices"); + op.add(Builder::shards, RemoteStoreRestoreShardsInfo._DESERIALIZER, "shards"); + op.add(Builder::snapshot, JsonpDeserializer.stringDeserializer(), "snapshot"); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreShardsInfo.java b/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreShardsInfo.java new file mode 100644 index 0000000000..c0e1d0644a --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreShardsInfo.java @@ -0,0 +1,110 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class RemoteStoreRestoreShardsInfo implements JsonpSerializable { + @Nullable private final Integer failed; + @Nullable private final Integer successful; + @Nullable private final Integer total; + + public RemoteStoreRestoreShardsInfo(Builder builder) { + this.failed = builder.failed; + this.successful = builder.successful; + this.total = builder.total; + } + + public static RemoteStoreRestoreShardsInfo of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final Integer failed() { + return this.failed; + } + + public final Integer successful() { + return this.successful; + } + + public final Integer total() { + return this.total; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.failed != null) { + generator.writeKey("failed"); + generator.write(this.failed); + } + + if (this.successful != null) { + generator.writeKey("successful"); + generator.write(this.successful); + } + + if (this.total != null) { + generator.writeKey("total"); + generator.write(this.total); + } + } + + /** Builder for {@link RemoteStoreRestoreShardsInfo}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private Integer failed; + private Integer successful; + private Integer total; + + public final Builder failed(Integer value) { + this.failed = value; + return this; + } + + public final Builder successful(Integer value) { + this.successful = value; + return this; + } + + public final Builder total(Integer value) { + this.total = value; + return this; + } + + /** + * Builds a {@link RemoteStoreRestoreShardsInfo}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public RemoteStoreRestoreShardsInfo build() { + _checkSingleUse(); + + return new RemoteStoreRestoreShardsInfo(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, + RemoteStoreRestoreShardsInfo::setupRemoteStoreRestoreShardsInfoDeserializer); + + protected static void setupRemoteStoreRestoreShardsInfoDeserializer( + ObjectDeserializer op) { + op.add(Builder::failed, JsonpDeserializer.integerDeserializer(), "failed"); + op.add(Builder::successful, JsonpDeserializer.integerDeserializer(), "successful"); + op.add(Builder::total, JsonpDeserializer.integerDeserializer(), "total"); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/SearchType.java b/java-client/src/generated/java/org/opensearch/client/opensearch/SearchType.java new file mode 100644 index 0000000000..cac4758c0e --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/SearchType.java @@ -0,0 +1,30 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.json.JsonEnum; +import org.opensearch.client.json.JsonpDeserializable; + +@JsonpDeserializable +public enum SearchType implements JsonEnum { + QueryThenFetch("query_then_fetch"), + DfsQueryThenFetch("dfs_query_then_fetch"), + ; + + private final String jsonValue; + private final String[] aliases; + + SearchType(String jsonValue, String... aliases) { + this.jsonValue = jsonValue; + this.aliases = aliases; + } + + public String jsonValue() { + return this.jsonValue; + } + + public String[] aliases() { + return this.aliases; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = + new JsonEnum.Deserializer<>(SearchType.values()); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ShardStatistics.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ShardStatistics.java new file mode 100644 index 0000000000..7b58f06479 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ShardStatistics.java @@ -0,0 +1,126 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class ShardStatistics implements JsonpSerializable { + @Nullable private final Integer failed; + @Nullable private final Integer skipped; + @Nullable private final Integer successful; + @Nullable private final Integer total; + + public ShardStatistics(Builder builder) { + this.failed = builder.failed; + this.skipped = builder.skipped; + this.successful = builder.successful; + this.total = builder.total; + } + + public static ShardStatistics of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final Integer failed() { + return this.failed; + } + + public final Integer skipped() { + return this.skipped; + } + + public final Integer successful() { + return this.successful; + } + + public final Integer total() { + return this.total; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.failed != null) { + generator.writeKey("failed"); + generator.write(this.failed); + } + + if (this.skipped != null) { + generator.writeKey("skipped"); + generator.write(this.skipped); + } + + if (this.successful != null) { + generator.writeKey("successful"); + generator.write(this.successful); + } + + if (this.total != null) { + generator.writeKey("total"); + generator.write(this.total); + } + } + + /** Builder for {@link ShardStatistics}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private Integer failed; + private Integer skipped; + private Integer successful; + private Integer total; + + public final Builder failed(Integer value) { + this.failed = value; + return this; + } + + public final Builder skipped(Integer value) { + this.skipped = value; + return this; + } + + public final Builder successful(Integer value) { + this.successful = value; + return this; + } + + public final Builder total(Integer value) { + this.total = value; + return this; + } + + /** + * Builds a {@link ShardStatistics}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public ShardStatistics build() { + _checkSingleUse(); + + return new ShardStatistics(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, ShardStatistics::setupShardStatisticsDeserializer); + + protected static void setupShardStatisticsDeserializer( + ObjectDeserializer op) { + op.add(Builder::failed, JsonpDeserializer.integerDeserializer(), "failed"); + op.add(Builder::skipped, JsonpDeserializer.integerDeserializer(), "skipped"); + op.add(Builder::successful, JsonpDeserializer.integerDeserializer(), "successful"); + op.add(Builder::total, JsonpDeserializer.integerDeserializer(), "total"); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/SuggestMode.java b/java-client/src/generated/java/org/opensearch/client/opensearch/SuggestMode.java new file mode 100644 index 0000000000..5e7366665c --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/SuggestMode.java @@ -0,0 +1,31 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.json.JsonEnum; +import org.opensearch.client.json.JsonpDeserializable; + +@JsonpDeserializable +public enum SuggestMode implements JsonEnum { + Missing("missing"), + Popular("popular"), + Always("always"), + ; + + private final String jsonValue; + private final String[] aliases; + + SuggestMode(String jsonValue, String... aliases) { + this.jsonValue = jsonValue; + this.aliases = aliases; + } + + public String jsonValue() { + return this.jsonValue; + } + + public String[] aliases() { + return this.aliases; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = + new JsonEnum.Deserializer<>(SuggestMode.values()); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/Total.java b/java-client/src/generated/java/org/opensearch/client/opensearch/Total.java new file mode 100644 index 0000000000..ea649083d5 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/Total.java @@ -0,0 +1,91 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class Total implements JsonpSerializable { + @Nullable private final Relation relation; + @Nullable private final Integer value; + + public Total(Builder builder) { + this.relation = builder.relation; + this.value = builder.value; + } + + public static Total of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final Relation relation() { + return this.relation; + } + + public final Integer value() { + return this.value; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.relation != null) { + generator.writeKey("relation"); + this.relation.serialize(generator, mapper); + } + + if (this.value != null) { + generator.writeKey("value"); + generator.write(this.value); + } + } + + /** Builder for {@link Total}. */ + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Relation relation; + private Integer value; + + public final Builder relation(Relation value) { + this.relation = value; + return this; + } + + public final Builder relation(Function> fn) { + return relation(fn.apply(new Relation.Builder()).build()); + } + + public final Builder value(Integer value) { + this.value = value; + return this; + } + + /** + * Builds a {@link Total}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public Total build() { + _checkSingleUse(); + + return new Total(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy(Builder::new, Total::setupTotalDeserializer); + + protected static void setupTotalDeserializer(ObjectDeserializer op) { + op.add(Builder::relation, Relation._DESERIALIZER, "relation"); + op.add(Builder::value, JsonpDeserializer.integerDeserializer(), "value"); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedObjectStructure.java b/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedObjectStructure.java index bf36d2dba1..a0253c78ec 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedObjectStructure.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedObjectStructure.java @@ -12,59 +12,59 @@ @JsonpDeserializable public class UserDefinedObjectStructure implements JsonpSerializable { - private final JsonData bool; - private final JsonData boosting; - private final JsonData combinedFields; - private final JsonData constantScore; - private final JsonData disMax; - private final JsonData distanceFeature; - private final JsonData exists; - private final JsonData fieldMaskingSpan; - private final JsonData functionScore; - private final Map fuzzy; - private final JsonData geoBoundingBox; - private final JsonData geoDistance; - private final JsonData geoPolygon; - private final JsonData geoShape; - private final JsonData hasChild; - private final JsonData hasParent; - private final JsonData ids; - private final Map intervals; - private final JsonData knn; - private final Map match; - private final JsonData matchAll; - private final Map matchBoolPrefix; - private final JsonData matchNone; - private final Map matchPhrase; - private final Map matchPhrasePrefix; - private final JsonData moreLikeThis; - private final JsonData multiMatch; - private final JsonData nested; - private final JsonData parentId; - private final JsonData percolate; - private final JsonData pinned; - private final Map prefix; - private final JsonData queryString; - private final Map range; - private final JsonData rankFeature; - private final Map regexp; - private final JsonData script; - private final JsonData scriptScore; - private final JsonData shape; - private final JsonData simpleQueryString; - private final JsonData spanContaining; - private final JsonData spanFirst; - private final JsonData spanMulti; - private final JsonData spanNear; - private final JsonData spanNot; - private final JsonData spanOr; - private final Map spanTerm; - private final JsonData spanWithin; - private final Map term; - private final JsonData terms; - private final Map termsSet; - private final Map wildcard; - private final JsonData wrapper; + @Nullable private final JsonData bool; + @Nullable private final JsonData boosting; + @Nullable private final JsonData combinedFields; + @Nullable private final JsonData constantScore; + @Nullable private final JsonData disMax; + @Nullable private final JsonData distanceFeature; + @Nullable private final JsonData exists; + @Nullable private final JsonData fieldMaskingSpan; + @Nullable private final JsonData functionScore; + @Nullable private final Map fuzzy; + @Nullable private final JsonData geoBoundingBox; + @Nullable private final JsonData geoDistance; + @Nullable private final JsonData geoPolygon; + @Nullable private final JsonData geoShape; + @Nullable private final JsonData hasChild; + @Nullable private final JsonData hasParent; + @Nullable private final JsonData ids; + @Nullable private final Map intervals; + @Nullable private final JsonData knn; + @Nullable private final Map match; + @Nullable private final JsonData matchAll; + @Nullable private final Map matchBoolPrefix; + @Nullable private final JsonData matchNone; + @Nullable private final Map matchPhrase; + @Nullable private final Map matchPhrasePrefix; + @Nullable private final JsonData moreLikeThis; + @Nullable private final JsonData multiMatch; + @Nullable private final JsonData nested; + @Nullable private final JsonData parentId; + @Nullable private final JsonData percolate; + @Nullable private final JsonData pinned; + @Nullable private final Map prefix; + @Nullable private final JsonData queryString; + @Nullable private final Map range; + @Nullable private final JsonData rankFeature; + @Nullable private final Map regexp; + @Nullable private final JsonData script; + @Nullable private final JsonData scriptScore; + @Nullable private final JsonData shape; + @Nullable private final JsonData simpleQueryString; + @Nullable private final JsonData spanContaining; + @Nullable private final JsonData spanFirst; + @Nullable private final JsonData spanMulti; + @Nullable private final JsonData spanNear; + @Nullable private final JsonData spanNot; + @Nullable private final JsonData spanOr; + @Nullable private final Map spanTerm; + @Nullable private final JsonData spanWithin; + @Nullable private final Map term; + @Nullable private final JsonData terms; + @Nullable private final Map termsSet; + @Nullable private final Map wildcard; + @Nullable private final JsonData wrapper; public UserDefinedObjectStructure(Builder builder) { this.bool = builder.bool; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedStructure.java b/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedStructure.java index ec238ea9d4..3de78e1dd9 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedStructure.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedStructure.java @@ -12,17 +12,17 @@ @JsonpDeserializable public class UserDefinedStructure implements JsonpSerializable { - private final String alias; - private final List aliases; - private final JsonData filter; - private final String index; - private final String indexRouting; - private final List indices; - private final boolean isHidden; - private final boolean isWriteIndex; - private final String mustExist; - private final String routing; - private final String searchRouting; + @Nullable private final String alias; + @Nullable private final List aliases; + @Nullable private final JsonData filter; + @Nullable private final String index; + @Nullable private final String indexRouting; + @Nullable private final List indices; + @Nullable private final Boolean isHidden; + @Nullable private final Boolean isWriteIndex; + @Nullable private final String mustExist; + @Nullable private final String routing; + @Nullable private final String searchRouting; public UserDefinedStructure(Builder builder) { this.alias = builder.alias; @@ -67,11 +67,11 @@ public final List indices() { return this.indices; } - public final boolean isHidden() { + public final Boolean isHidden() { return this.isHidden; } - public final boolean isWriteIndex() { + public final Boolean isWriteIndex() { return this.isWriteIndex; } @@ -167,8 +167,8 @@ public static class Builder extends ObjectBuilderBase private String index; private String indexRouting; private List indices; - private boolean isHidden; - private boolean isWriteIndex; + private Boolean isHidden; + private Boolean isWriteIndex; private String mustExist; private String routing; private String searchRouting; @@ -213,12 +213,12 @@ public final Builder indices(String value, String... values) { return this; } - public final Builder isHidden(boolean value) { + public final Builder isHidden(Boolean value) { this.isHidden = value; return this; } - public final Builder isWriteIndex(boolean value) { + public final Builder isWriteIndex(Boolean value) { this.isWriteIndex = value; return this; } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/Version.java b/java-client/src/generated/java/org/opensearch/client/opensearch/Version.java new file mode 100644 index 0000000000..2ef07badef --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/Version.java @@ -0,0 +1,219 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class Version implements JsonpSerializable { + @Nullable private final String buildDate; + @Nullable private final String buildHash; + @Nullable private final Boolean buildSnapshot; + @Nullable private final String buildType; + @Nullable private final String distribution; + @Nullable private final String luceneVersion; + @Nullable private final String minimumIndexCompatibilityVersion; + @Nullable private final String minimumWireCompatibilityVersion; + @Nullable private final String number; + + public Version(Builder builder) { + this.buildDate = builder.buildDate; + this.buildHash = builder.buildHash; + this.buildSnapshot = builder.buildSnapshot; + this.buildType = builder.buildType; + this.distribution = builder.distribution; + this.luceneVersion = builder.luceneVersion; + this.minimumIndexCompatibilityVersion = builder.minimumIndexCompatibilityVersion; + this.minimumWireCompatibilityVersion = builder.minimumWireCompatibilityVersion; + this.number = builder.number; + } + + public static Version of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final String buildDate() { + return this.buildDate; + } + + public final String buildHash() { + return this.buildHash; + } + + public final Boolean buildSnapshot() { + return this.buildSnapshot; + } + + public final String buildType() { + return this.buildType; + } + + public final String distribution() { + return this.distribution; + } + + public final String luceneVersion() { + return this.luceneVersion; + } + + public final String minimumIndexCompatibilityVersion() { + return this.minimumIndexCompatibilityVersion; + } + + public final String minimumWireCompatibilityVersion() { + return this.minimumWireCompatibilityVersion; + } + + public final String number() { + return this.number; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.buildDate != null) { + generator.writeKey("build_date"); + generator.write(this.buildDate); + } + + if (this.buildHash != null) { + generator.writeKey("build_hash"); + generator.write(this.buildHash); + } + + if (this.buildSnapshot != null) { + generator.writeKey("build_snapshot"); + generator.write(this.buildSnapshot); + } + + if (this.buildType != null) { + generator.writeKey("build_type"); + generator.write(this.buildType); + } + + if (this.distribution != null) { + generator.writeKey("distribution"); + generator.write(this.distribution); + } + + if (this.luceneVersion != null) { + generator.writeKey("lucene_version"); + generator.write(this.luceneVersion); + } + + if (this.minimumIndexCompatibilityVersion != null) { + generator.writeKey("minimum_index_compatibility_version"); + generator.write(this.minimumIndexCompatibilityVersion); + } + + if (this.minimumWireCompatibilityVersion != null) { + generator.writeKey("minimum_wire_compatibility_version"); + generator.write(this.minimumWireCompatibilityVersion); + } + + if (this.number != null) { + generator.writeKey("number"); + generator.write(this.number); + } + } + + /** Builder for {@link Version}. */ + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private String buildDate; + private String buildHash; + private Boolean buildSnapshot; + private String buildType; + private String distribution; + private String luceneVersion; + private String minimumIndexCompatibilityVersion; + private String minimumWireCompatibilityVersion; + private String number; + + public final Builder buildDate(String value) { + this.buildDate = value; + return this; + } + + public final Builder buildHash(String value) { + this.buildHash = value; + return this; + } + + public final Builder buildSnapshot(Boolean value) { + this.buildSnapshot = value; + return this; + } + + public final Builder buildType(String value) { + this.buildType = value; + return this; + } + + public final Builder distribution(String value) { + this.distribution = value; + return this; + } + + public final Builder luceneVersion(String value) { + this.luceneVersion = value; + return this; + } + + public final Builder minimumIndexCompatibilityVersion(String value) { + this.minimumIndexCompatibilityVersion = value; + return this; + } + + public final Builder minimumWireCompatibilityVersion(String value) { + this.minimumWireCompatibilityVersion = value; + return this; + } + + public final Builder number(String value) { + this.number = value; + return this; + } + + /** + * Builds a {@link Version}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public Version build() { + _checkSingleUse(); + + return new Version(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy(Builder::new, Version::setupVersionDeserializer); + + protected static void setupVersionDeserializer(ObjectDeserializer op) { + op.add(Builder::buildDate, JsonpDeserializer.stringDeserializer(), "build_date"); + op.add(Builder::buildHash, JsonpDeserializer.stringDeserializer(), "build_hash"); + op.add(Builder::buildSnapshot, JsonpDeserializer.booleanDeserializer(), "build_snapshot"); + op.add(Builder::buildType, JsonpDeserializer.stringDeserializer(), "build_type"); + op.add(Builder::distribution, JsonpDeserializer.stringDeserializer(), "distribution"); + op.add(Builder::luceneVersion, JsonpDeserializer.stringDeserializer(), "lucene_version"); + op.add( + Builder::minimumIndexCompatibilityVersion, + JsonpDeserializer.stringDeserializer(), + "minimum_index_compatibility_version"); + op.add( + Builder::minimumWireCompatibilityVersion, + JsonpDeserializer.stringDeserializer(), + "minimum_wire_compatibility_version"); + op.add(Builder::number, JsonpDeserializer.stringDeserializer(), "number"); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/VersionType.java b/java-client/src/generated/java/org/opensearch/client/opensearch/VersionType.java new file mode 100644 index 0000000000..512bcb42af --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/VersionType.java @@ -0,0 +1,31 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.json.JsonEnum; +import org.opensearch.client.json.JsonpDeserializable; + +@JsonpDeserializable +public enum VersionType implements JsonEnum { + Internal("internal"), + External("external"), + ExternalGte("external_gte"), + ; + + private final String jsonValue; + private final String[] aliases; + + VersionType(String jsonValue, String... aliases) { + this.jsonValue = jsonValue; + this.aliases = aliases; + } + + public String jsonValue() { + return this.jsonValue; + } + + public String[] aliases() { + return this.aliases; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = + new JsonEnum.Deserializer<>(VersionType.values()); +} diff --git a/java-codegen/OpenSearch.openapi.json b/java-codegen/OpenSearch.openapi.json index 975639dd2b..69df2e6a00 100644 --- a/java-codegen/OpenSearch.openapi.json +++ b/java-codegen/OpenSearch.openapi.json @@ -2612,8 +2612,8 @@ "SearchType": { "type": "string", "enum": [ - "0", - "1" + "query_then_fetch", + "dfs_query_then_fetch" ] }, "ShardStatistics": { @@ -2640,9 +2640,9 @@ "SuggestMode": { "type": "string", "enum": [ - "0", - "1", - "2" + "missing", + "popular", + "always" ] }, "Total": { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java b/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java index 7db22bbbdb..99e5a03927 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java @@ -10,12 +10,15 @@ import org.openapi4j.parser.model.AbsRefOpenApiSchema; import org.openapi4j.parser.model.v3.*; import org.opensearch.client.codegen.exceptions.ApiSpecificationParseException; +import org.opensearch.client.codegen.model.EnumShape; import org.opensearch.client.codegen.model.Field; import org.opensearch.client.codegen.model.ObjectShape; import org.opensearch.client.codegen.model.OperationRequest; import java.io.File; import java.util.*; +import java.util.function.Consumer; +import java.util.stream.Collectors; import java.util.stream.Stream; public class ApiSpecification { @@ -24,6 +27,7 @@ public class ApiSpecification { private final Set visitedReferencedSchemas; private final List operationRequests; private final List objectShapes; + private final List enumShapes; private final TypeMapper typeMapper; private ApiSpecification(OpenApi3 api) throws ApiSpecificationParseException { @@ -32,6 +36,7 @@ private ApiSpecification(OpenApi3 api) throws ApiSpecificationParseException { visitedReferencedSchemas = new HashSet<>(); operationRequests = new ArrayList<>(); objectShapes = new ArrayList<>(); + enumShapes = new ArrayList<>(); typeMapper = new TypeMapper(this.api, this::visitReferencedSchema); visit(this.api); } @@ -49,7 +54,13 @@ public List getOperationRequests() { return Collections.unmodifiableList(operationRequests); } - public List getObjectShapes() { return Collections.unmodifiableList(objectShapes); } + public List getObjectShapes() { + return Collections.unmodifiableList(objectShapes); + } + + public List getEnumShapes() { + return Collections.unmodifiableList(enumShapes); + } private void visit(OpenApi3 api) throws ApiSpecificationParseException { for (Map.Entry entry : api.getPaths().entrySet()) { @@ -78,17 +89,21 @@ private void visit(String httpPath, Path path, String httpMethod, Operation oper RequestBody requestBody = resolve(operation.getRequestBody()); if (requestBody != null) { - resolve(requestBody.getContentMediaType("application/json").getSchema()) - .getProperties() - .forEach((name, schema) -> operationRequest.addBodyField(new Field(name, typeMapper.mapType(schema)))); + Schema requestBodySchema = resolve(requestBody.getContentMediaType("application/json").getSchema()); + visitFields(requestBodySchema, operationRequest::addBodyField); } Stream.of(path.getParametersIn(context, "query"), operation.getParametersIn(context, "query")) .flatMap(List::stream) - .map(p -> new Field(p.getName(), typeMapper.mapType(p.getSchema()))) + .map(p -> new Field(p.getName(), typeMapper.mapType(p.getSchema()), p.isRequired())) .forEach(operationRequest::addQueryParam); operationRequests.add(operationRequest); + + + MediaType responseMediaType = operation.getResponse("200").getContentMediaType("application/json"); + Schema responseSchema = responseMediaType != null ? resolve(responseMediaType.getSchema()) : new Schema(); + visitObjectShape(operation.getOperationId() + "Response", responseSchema); } private void visitReferencedSchema(String ref, Schema schema) { @@ -98,16 +113,34 @@ private void visitReferencedSchema(String ref, Schema schema) { String name = refParts[refParts.length - 1]; if (OAI3SchemaKeywords.TYPE_OBJECT.equals(schema.getType())) { - ObjectShape shape = new ObjectShape(); + visitObjectShape(name, schema); + } else if (OAI3SchemaKeywords.TYPE_STRING.equals(schema.getType()) && schema.hasEnums()) { + enumShapes.add(new EnumShape(name, schema.getEnums().stream().map(Object::toString).collect(Collectors.toList()))); + } + } - shape.name = name; + private void visitObjectShape(String name, Schema schema) { + ObjectShape shape = new ObjectShape(); - for (Map.Entry entry : schema.getProperties().entrySet()) { - shape.addField(new Field(entry.getKey(), typeMapper.mapType(entry.getValue()))); - } + shape.name = name; - objectShapes.add(shape); - } + visitFields(schema, shape::addField); + + objectShapes.add(shape); + } + + private void visitFields(Schema schema, Consumer fieldVisitor) { + Map properties = schema.getProperties(); + + if (properties == null) return; + + Set requiredFields = new HashSet<>(schema.hasRequiredFields() ? schema.getRequiredFields() : new ArrayList<>(0)); + + properties.forEach((name, propertySchema) -> fieldVisitor.accept(new Field( + name, + typeMapper.mapType(propertySchema), + requiredFields.contains(name) + ))); } private RequestBody resolve(RequestBody body) throws ApiSpecificationParseException { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java b/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java index 322cf6cdb0..3cbed93c38 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java @@ -2,6 +2,7 @@ import org.opensearch.client.codegen.exceptions.ApiSpecificationParseException; import org.opensearch.client.codegen.exceptions.RenderException; +import org.opensearch.client.codegen.model.EnumShape; import org.opensearch.client.codegen.model.ObjectShape; import org.opensearch.client.codegen.model.OperationRequest; @@ -45,5 +46,10 @@ public void generate() throws RenderException { File file = new File(packageDir, objectShape.className() + ".java"); renderer.render(objectShape, file); } + + for (EnumShape enumShape : apiSpecification.getEnumShapes()) { + File file = new File(packageDir, enumShape.className() + ".java"); + renderer.render(enumShape, file); + } } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java b/java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java index bd641a27cf..6554a40f11 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java @@ -45,10 +45,15 @@ public String render(T object) throws RenderException { template.execute(object, lambdas, writer); String output = writer.toString(); - output = formatter.formatSource(output); + + try { + output = formatter.formatSource(output); + } catch (FormatterException e) { + output = "// FAILED FORMATTING: " + e + "\n\n" + output; + } return output; - } catch (MustacheException | FormatterException e) { + } catch (MustacheException e) { throw new RenderException("Failed to render: " + object, e); } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java b/java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java index f205503678..b3a2fb150e 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java @@ -59,6 +59,8 @@ private Type mapTypeInner(Schema schema) { return new Type(schema, "JsonData"); } + String format = schema.getFormat(); + switch (type) { case OAI3SchemaKeywords.TYPE_ARRAY: return new Type(schema, "List", mapType(schema.getItemsSchema(), true)); @@ -67,7 +69,6 @@ private Type mapTypeInner(Schema schema) { case OAI3SchemaKeywords.TYPE_BOOLEAN: return new Type(schema, "boolean"); case OAI3SchemaKeywords.TYPE_INTEGER: - String format = schema.getFormat(); if (format == null) format = OAI3SchemaKeywords.FORMAT_INT32; switch (format) { case OAI3SchemaKeywords.FORMAT_INT32: @@ -77,6 +78,15 @@ private Type mapTypeInner(Schema schema) { default: throw new UnsupportedOperationException("Can not get type name for integer with format: " + format); } + case OAI3SchemaKeywords.TYPE_NUMBER: + switch (format) { + case OAI3SchemaKeywords.FORMAT_FLOAT: + return new Type(schema, "float"); + case OAI3SchemaKeywords.FORMAT_DOUBLE: + return new Type(schema, "double"); + default: + throw new UnsupportedOperationException("Can not get type name for number with format: " + format); + } } throw new UnsupportedOperationException("Can not get type name for: " + type); diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java new file mode 100644 index 0000000000..4ccc141d13 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java @@ -0,0 +1,31 @@ +package org.opensearch.client.codegen.model; + +import org.apache.commons.text.CaseUtils; + +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +public class EnumShape { + public final String name; + public final List variants; + + public EnumShape(String name, Collection variants) { + this.name = name; + this.variants = variants.stream().map(Variant::new).collect(Collectors.toList()); + } + + public String className() { return name; } + + public static class Variant { + public final String wireName; + + public Variant(String wireName) { + this.wireName = wireName; + } + + public String name() { + return CaseUtils.toCamelCase(wireName, true, '_'); + } + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java index 3b042a2c5a..40f2949923 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java @@ -5,10 +5,12 @@ public class Field { public String wireName; public Type type; + public boolean required; - public Field(String wireName, Type type) { + public Field(String wireName, Type type, boolean required) { this.wireName = wireName; - this.type = type; + this.type = required ? type : type.boxed(); + this.required = required; } public String name() { diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache new file mode 100644 index 0000000000..7aa1819e49 --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache @@ -0,0 +1,26 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.json.JsonEnum; +import org.opensearch.client.json.JsonpDeserializable; + +@JsonpDeserializable +public enum {{className}} implements JsonEnum { + {{#variants}} + {{name}}({{#dq}}{{wireName}}{{/dq}}), + {{/variants}} + ; + + private final String jsonValue; + private final String[] aliases; + + {{className}}(String jsonValue, String... aliases) { + this.jsonValue = jsonValue; + this.aliases = aliases; + } + + public String jsonValue() { return this.jsonValue; } + + public String[] aliases() { return this.aliases; } + + public static final JsonEnum.Deserializer<{{className}}> _DESERIALIZER = new JsonEnum.Deserializer<>({{className}}.values()); +} \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache index 0ba3f7f276..6bf238f163 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache @@ -13,6 +13,7 @@ import javax.annotation.*; @JsonpDeserializable public class {{className}} implements JsonpSerializable { {{#fields}} + {{^required}}@Nullable{{/required}} private final {{{type}}} {{name}}; {{/fields}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache index c00f391b34..1cf7c7bc05 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache @@ -16,6 +16,7 @@ import javax.annotation.*; {{#hasRequestBody}}@JsonpDeserializable{{/hasRequestBody}} public class {{className}} extends RequestBase{{#hasRequestBody}} implements JsonpSerializable{{/hasRequestBody}} { {{#fields}} + {{^required}}@Nullable{{/required}} private final {{{type}}} {{name}}; {{/fields}} From f2329a7f4372a5173d8e44e564dd6ecaada5e669 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Tue, 14 Feb 2023 16:51:07 +1300 Subject: [PATCH 04/50] Fix builder setters for enums Signed-off-by: Thomas Farr --- .../client/opensearch/DeleteIndexRequest.java | 6 +- .../opensearch/GetCatIndicesRequest.java | 11 +--- .../GetCatIndicesWithIndexRequest.java | 11 +--- .../client/opensearch/GetCatNodesRequest.java | 1 + .../opensearch/GetClusterInfoRequest.java | 1 + .../opensearch/GetClusterSettingsRequest.java | 1 + .../opensearch/GetDocumentDocRequest.java | 6 +- .../opensearch/GetDocumentSourceRequest.java | 6 +- .../opensearch/GetSettingsIndexRequest.java | 6 +- .../GetSettingsIndexSettingRequest.java | 6 +- .../client/opensearch/PostAliasesRequest.java | 1 + .../PostRemoteStoreRestoreRequest.java | 1 + .../client/opensearch/PostSearchRequest.java | 21 +----- .../PostSearchWithIndexRequest.java | 21 +----- .../opensearch/PutCreateIndexRequest.java | 1 + .../PutIndexMappingWithIndexRequest.java | 6 +- .../PutUpdateClusterSettingsRequest.java | 1 + .../opensearch/client/opensearch/Total.java | 4 -- .../client/codegen/ApiSpecification.java | 5 +- .../opensearch/client/codegen/model/Type.java | 9 ++- .../codegen/templates/ObjectBuilder.mustache | 63 ++++++++++++++++++ .../codegen/templates/ObjectShape.mustache | 64 +----------------- .../templates/OperationRequest.mustache | 65 +------------------ 23 files changed, 93 insertions(+), 224 deletions(-) create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectBuilder.mustache diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java index 7c6758b16c..90042648a5 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java @@ -8,6 +8,7 @@ import java.util.*; import java.util.function.Function; +import java.util.stream.*; import javax.annotation.*; /** Removes a document from the index. */ @@ -81,11 +82,6 @@ public final Builder expandWildcards(ExpandWildcards value) { return this; } - public final Builder expandWildcards( - Function> fn) { - return expandWildcards(fn.apply(new ExpandWildcards.Builder()).build()); - } - public final Builder ignoreUnavailable(Boolean value) { this.ignoreUnavailable = value; return this; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesRequest.java index aaf55ba50b..cd5ca54df5 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesRequest.java @@ -8,6 +8,7 @@ import java.util.*; import java.util.function.Function; +import java.util.stream.*; import javax.annotation.*; /** @@ -106,11 +107,6 @@ public final Builder expandWildcards(ExpandWildcards value) { return this; } - public final Builder expandWildcards( - Function> fn) { - return expandWildcards(fn.apply(new ExpandWildcards.Builder()).build()); - } - public final Builder format(String value) { this.format = value; return this; @@ -121,11 +117,6 @@ public final Builder health(HealthStatus value) { return this; } - public final Builder health( - Function> fn) { - return health(fn.apply(new HealthStatus.Builder()).build()); - } - public final Builder includeUnloadedSegments(Boolean value) { this.includeUnloadedSegments = value; return this; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java index b9bc3b0e5f..9b66490cff 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java @@ -8,6 +8,7 @@ import java.util.*; import java.util.function.Function; +import java.util.stream.*; import javax.annotation.*; /** @@ -106,11 +107,6 @@ public final Builder expandWildcards(ExpandWildcards value) { return this; } - public final Builder expandWildcards( - Function> fn) { - return expandWildcards(fn.apply(new ExpandWildcards.Builder()).build()); - } - public final Builder format(String value) { this.format = value; return this; @@ -121,11 +117,6 @@ public final Builder health(HealthStatus value) { return this; } - public final Builder health( - Function> fn) { - return health(fn.apply(new HealthStatus.Builder()).build()); - } - public final Builder includeUnloadedSegments(Boolean value) { this.includeUnloadedSegments = value; return this; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesRequest.java index 28aad4b982..537ef92afd 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesRequest.java @@ -8,6 +8,7 @@ import java.util.*; import java.util.function.Function; +import java.util.stream.*; import javax.annotation.*; /** Returns basic statistics about performance of cluster nodes. */ diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoRequest.java index def287e015..9e9d2a4230 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoRequest.java @@ -8,6 +8,7 @@ import java.util.*; import java.util.function.Function; +import java.util.stream.*; import javax.annotation.*; /** Returns whether the cluster is running. */ diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsRequest.java index 477812368b..9e47d32a2a 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsRequest.java @@ -8,6 +8,7 @@ import java.util.*; import java.util.function.Function; +import java.util.stream.*; import javax.annotation.*; /** Returns cluster settings. */ diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java index 0af6d96f56..a11b62e085 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java @@ -8,6 +8,7 @@ import java.util.*; import java.util.function.Function; +import java.util.stream.*; import javax.annotation.*; /** Returns a document */ @@ -145,11 +146,6 @@ public final Builder versionType(VersionType value) { return this; } - public final Builder versionType( - Function> fn) { - return versionType(fn.apply(new VersionType.Builder()).build()); - } - /** * Builds a {@link GetDocumentDocRequest}. * diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java index eb3a8e3e2f..1ebd1da9d1 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java @@ -8,6 +8,7 @@ import java.util.*; import java.util.function.Function; +import java.util.stream.*; import javax.annotation.*; /** Returns a document. */ @@ -145,11 +146,6 @@ public final Builder versionType(VersionType value) { return this; } - public final Builder versionType( - Function> fn) { - return versionType(fn.apply(new VersionType.Builder()).build()); - } - /** * Builds a {@link GetDocumentSourceRequest}. * diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java index 8b59fa9bac..e347514197 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java @@ -8,6 +8,7 @@ import java.util.*; import java.util.function.Function; +import java.util.stream.*; import javax.annotation.*; /** The get settings API operation returns all the settings in your index. */ @@ -96,11 +97,6 @@ public final Builder expandWildcards(ExpandWildcards value) { return this; } - public final Builder expandWildcards( - Function> fn) { - return expandWildcards(fn.apply(new ExpandWildcards.Builder()).build()); - } - public final Builder flatSettings(Boolean value) { this.flatSettings = value; return this; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java index 0b7c295fea..23ae4d4e1b 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java @@ -8,6 +8,7 @@ import java.util.*; import java.util.function.Function; +import java.util.stream.*; import javax.annotation.*; /** The get settings API operation returns all the settings in your index. */ @@ -96,11 +97,6 @@ public final Builder expandWildcards(ExpandWildcards value) { return this; } - public final Builder expandWildcards( - Function> fn) { - return expandWildcards(fn.apply(new ExpandWildcards.Builder()).build()); - } - public final Builder flatSettings(Boolean value) { this.flatSettings = value; return this; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesRequest.java index 0c02ced3d6..3cb094389b 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesRequest.java @@ -8,6 +8,7 @@ import jakarta.json.stream.JsonGenerator; import java.util.*; import java.util.function.Function; +import java.util.stream.*; import javax.annotation.*; /** Adds or removes index aliases. */ diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreRequest.java index 5906aa4d5a..c013f52384 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreRequest.java @@ -8,6 +8,7 @@ import jakarta.json.stream.JsonGenerator; import java.util.*; import java.util.function.Function; +import java.util.stream.*; import javax.annotation.*; /** Restore one or more indices from a remote backup. */ diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchRequest.java index 14a0732d0e..c050c15a2c 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchRequest.java @@ -8,6 +8,7 @@ import jakarta.json.stream.JsonGenerator; import java.util.*; import java.util.function.Function; +import java.util.stream.*; import javax.annotation.*; /** Returns results matching a query. */ @@ -468,11 +469,6 @@ public final Builder defaultOperator(DefaultOperator value) { return this; } - public final Builder defaultOperator( - Function> fn) { - return defaultOperator(fn.apply(new DefaultOperator.Builder()).build()); - } - public final Builder df(String value) { this.df = value; return this; @@ -488,11 +484,6 @@ public final Builder expandWildcards(ExpandWildcards value) { return this; } - public final Builder expandWildcards( - Function> fn) { - return expandWildcards(fn.apply(new ExpandWildcards.Builder()).build()); - } - public final Builder explain(Boolean value) { this.explain = value; return this; @@ -601,11 +592,6 @@ public final Builder searchType(SearchType value) { return this; } - public final Builder searchType( - Function> fn) { - return searchType(fn.apply(new SearchType.Builder()).build()); - } - public final Builder seqNoPrimaryTerm(Boolean value) { this.seqNoPrimaryTerm = value; return this; @@ -671,11 +657,6 @@ public final Builder suggestMode(SuggestMode value) { return this; } - public final Builder suggestMode( - Function> fn) { - return suggestMode(fn.apply(new SuggestMode.Builder()).build()); - } - public final Builder suggestSize(Long value) { this.suggestSize = value; return this; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java index f79d076cf1..cd479f85d7 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java @@ -8,6 +8,7 @@ import jakarta.json.stream.JsonGenerator; import java.util.*; import java.util.function.Function; +import java.util.stream.*; import javax.annotation.*; /** Returns results matching a query. */ @@ -469,11 +470,6 @@ public final Builder defaultOperator(DefaultOperator value) { return this; } - public final Builder defaultOperator( - Function> fn) { - return defaultOperator(fn.apply(new DefaultOperator.Builder()).build()); - } - public final Builder df(String value) { this.df = value; return this; @@ -489,11 +485,6 @@ public final Builder expandWildcards(ExpandWildcards value) { return this; } - public final Builder expandWildcards( - Function> fn) { - return expandWildcards(fn.apply(new ExpandWildcards.Builder()).build()); - } - public final Builder explain(Boolean value) { this.explain = value; return this; @@ -602,11 +593,6 @@ public final Builder searchType(SearchType value) { return this; } - public final Builder searchType( - Function> fn) { - return searchType(fn.apply(new SearchType.Builder()).build()); - } - public final Builder seqNoPrimaryTerm(Boolean value) { this.seqNoPrimaryTerm = value; return this; @@ -672,11 +658,6 @@ public final Builder suggestMode(SuggestMode value) { return this; } - public final Builder suggestMode( - Function> fn) { - return suggestMode(fn.apply(new SuggestMode.Builder()).build()); - } - public final Builder suggestSize(Long value) { this.suggestSize = value; return this; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java index 58c250ee7c..a8dddc31c5 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java @@ -8,6 +8,7 @@ import jakarta.json.stream.JsonGenerator; import java.util.*; import java.util.function.Function; +import java.util.stream.*; import javax.annotation.*; /** Creates index mappings. */ diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java index 5bc16aea49..f7dceeece6 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java @@ -8,6 +8,7 @@ import jakarta.json.stream.JsonGenerator; import java.util.*; import java.util.function.Function; +import java.util.stream.*; import javax.annotation.*; /** The put mapping API operation lets you add new mappings and fields to an index. */ @@ -117,11 +118,6 @@ public final Builder expandWildcards(ExpandWildcards value) { return this; } - public final Builder expandWildcards( - Function> fn) { - return expandWildcards(fn.apply(new ExpandWildcards.Builder()).build()); - } - public final Builder ignoreUnavailable(Boolean value) { this.ignoreUnavailable = value; return this; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsRequest.java index d7cf7563ff..048718fd43 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsRequest.java @@ -8,6 +8,7 @@ import jakarta.json.stream.JsonGenerator; import java.util.*; import java.util.function.Function; +import java.util.stream.*; import javax.annotation.*; /** Updates the cluster settings. */ diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/Total.java b/java-client/src/generated/java/org/opensearch/client/opensearch/Total.java index ea649083d5..bb9e8cf8c0 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/Total.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/Total.java @@ -60,10 +60,6 @@ public final Builder relation(Relation value) { return this; } - public final Builder relation(Function> fn) { - return relation(fn.apply(new Relation.Builder()).build()); - } - public final Builder value(Integer value) { this.value = value; return this; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java b/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java index 99e5a03927..91491a3719 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java @@ -14,6 +14,7 @@ import org.opensearch.client.codegen.model.Field; import org.opensearch.client.codegen.model.ObjectShape; import org.opensearch.client.codegen.model.OperationRequest; +import org.opensearch.client.codegen.utils.Schemas; import java.io.File; import java.util.*; @@ -112,9 +113,9 @@ private void visitReferencedSchema(String ref, Schema schema) { String[] refParts = ref.split("/"); String name = refParts[refParts.length - 1]; - if (OAI3SchemaKeywords.TYPE_OBJECT.equals(schema.getType())) { + if (Schemas.isObject(schema)) { visitObjectShape(name, schema); - } else if (OAI3SchemaKeywords.TYPE_STRING.equals(schema.getType()) && schema.hasEnums()) { + } else if (Schemas.isString(schema) && schema.hasEnums()) { enumShapes.add(new EnumShape(name, schema.getEnums().stream().map(Object::toString).collect(Collectors.toList()))); } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java index 49fa12cc34..f08b525616 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java @@ -1,6 +1,7 @@ package org.opensearch.client.codegen.model; import com.samskivert.mustache.Mustache; +import org.openapi4j.core.model.v3.OAI3SchemaKeywords; import org.openapi4j.parser.model.v3.Schema; import org.opensearch.client.codegen.utils.Schemas; @@ -108,14 +109,18 @@ public Type listValueType() { public boolean isBuiltIn() { return isListOrMap() || isPrimitive() || "JsonData".equals(name); } + public boolean hasBuilder() { + return !isBuiltIn() && !Schemas.hasEnums(schema); + } + public Type builderType() { - if (isBuiltIn()) return null; + if (!hasBuilder()) return null; return new Type(name + ".Builder"); } public Type builderFuncType() { - if (isBuiltIn()) return null; + if (!hasBuilder()) return null; return new Type(null, "Function", builderType(), new Type(null, "ObjectBuilder", this)); } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectBuilder.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectBuilder.mustache new file mode 100644 index 0000000000..cb9c2818be --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectBuilder.mustache @@ -0,0 +1,63 @@ + /** + * Builder for {@link {{className}}}. + */ + public static class Builder extends ObjectBuilderBase implements ObjectBuilder<{{className}}> { + {{#fields}} + private {{{type}}} {{name}}; + {{/fields}} + + {{#fields}} + {{#type.isMap}} + public final Builder {{name}}({{{type}}} map) { + this.{{name}} = _mapPutAll(this.{{name}}, map); + return this; + } + + public final Builder {{name}}({{{type.mapKeyType}}} key, {{{type.mapValueType}}} value) { + this.{{name}} = _mapPut(this.{{name}}, key, value); + return this; + } + {{/type.isMap}} + {{#type.isList}} + public final Builder {{name}}({{{type}}} list) { + this.{{name}} = _listAddAll(this.{{name}}, list); + return this; + } + + public final Builder {{name}}({{{type.listValueType}}} value, {{{type.listValueType}}}... values) { + this.{{name}} = _listAdd(this.{{name}}, value, values); + return this; + } + {{#type.listValueType.hasBuilder}} + + public final Builder {{name}}({{{type.listValueType.builderFuncType}}} fn) { + return {{name}}(fn.apply(new {{{type.listValueType.builderType}}}()).build()); + } + {{/type.listValueType.hasBuilder}} + {{/type.isList}} + {{^type.isListOrMap}} + public final Builder {{name}}({{{type}}} value) { + this.{{name}} = value; + return this; + } + {{#type.hasBuilder}} + + public final Builder {{name}}({{{type.builderFuncType}}} fn) { + return {{name}}(fn.apply(new {{{type.builderType}}}()).build()); + } + {{/type.hasBuilder}} + {{/type.isListOrMap}} + + {{/fields}} + /** + * Builds a {@link {{className}}}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public {{className}} build() { + _checkSingleUse(); + + return new {{className}}(this); + } + } \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache index 6bf238f163..200d879919 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache @@ -54,69 +54,7 @@ public class {{className}} implements JsonpSerializable { {{/fields}} } - /** - * Builder for {@link {{className}}}. - */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder<{{className}}> { - {{#fields}} - private {{{type}}} {{name}}; - {{/fields}} - - {{#fields}} - {{#type.isMap}} - public final Builder {{name}}({{{type}}} map) { - this.{{name}} = _mapPutAll(this.{{name}}, map); - return this; - } - - public final Builder {{name}}({{{type.mapKeyType}}} key, {{{type.mapValueType}}} value) { - this.{{name}} = _mapPut(this.{{name}}, key, value); - return this; - } - {{/type.isMap}} - {{#type.isList}} - public final Builder {{name}}({{{type}}} list) { - this.{{name}} = _listAddAll(this.{{name}}, list); - return this; - } - - public final Builder {{name}}({{{type.listValueType}}} value, {{{type.listValueType}}}... values) { - this.{{name}} = _listAdd(this.{{name}}, value, values); - return this; - } - {{^type.listValueType.isBuiltIn}} - - public final Builder {{name}}({{{type.listValueType.builderFuncType}}} fn) { - return {{name}}(fn.apply(new {{{type.listValueType.builderType}}}()).build()); - } - {{/type.listValueType.isBuiltIn}} - {{/type.isList}} - {{^type.isListOrMap}} - public final Builder {{name}}({{{type}}} value) { - this.{{name}} = value; - return this; - } - {{^type.isBuiltIn}} - - public final Builder {{name}}({{{type.builderFuncType}}} fn) { - return {{name}}(fn.apply(new {{{type.builderType}}}()).build()); - } - {{/type.isBuiltIn}} - {{/type.isListOrMap}} - - {{/fields}} - /** - * Builds a {@link {{className}}}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public {{className}} build() { - _checkSingleUse(); - - return new {{className}}(this); - } - } + {{>ObjectBuilder}} public static final JsonpDeserializer<{{className}}> _DESERIALIZER = ObjectBuilderDeserializer .lazy(Builder::new, {{className}}::setup{{className}}Deserializer); diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache index 1cf7c7bc05..42ee3cfb99 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache @@ -8,6 +8,7 @@ import org.opensearch.client.util.*; {{#hasRequestBody}}import jakarta.json.stream.JsonGenerator;{{/hasRequestBody}} import java.util.*; import java.util.function.Function; +import java.util.stream.*; import javax.annotation.*; /** @@ -59,69 +60,7 @@ public class {{className}} extends RequestBase{{#hasRequestBody}} implements Jso } {{/hasRequestBody}} - /** - * Builder for {@link {{className}}}. - */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder<{{className}}> { - {{#fields}} - private {{{type}}} {{name}}; - {{/fields}} - - {{#fields}} - {{#type.isMap}} - public final Builder {{name}}({{{type}}} map) { - this.{{name}} = _mapPutAll(this.{{name}}, map); - return this; - } - - public final Builder {{name}}({{{type.mapKeyType}}} key, {{{type.mapValueType}}} value) { - this.{{name}} = _mapPut(this.{{name}}, key, value); - return this; - } - {{/type.isMap}} - {{#type.isList}} - public final Builder {{name}}({{{type}}} list) { - this.{{name}} = _listAddAll(this.{{name}}, list); - return this; - } - - public final Builder {{name}}({{{type.listValueType}}} value, {{{type.listValueType}}}... values) { - this.{{name}} = _listAdd(this.{{name}}, value, values); - return this; - } - {{^type.listValueType.isBuiltIn}} - - public final Builder {{name}}({{{type.listValueType.builderFuncType}}} fn) { - return {{name}}(fn.apply(new {{{type.listValueType.builderType}}}()).build()); - } - {{/type.listValueType.isBuiltIn}} - {{/type.isList}} - {{^type.isListOrMap}} - public final Builder {{name}}({{{type}}} value) { - this.{{name}} = value; - return this; - } - {{^type.isBuiltIn}} - - public final Builder {{name}}({{{type.builderFuncType}}} fn) { - return {{name}}(fn.apply(new {{{type.builderType}}}()).build()); - } - {{/type.isBuiltIn}} - {{/type.isListOrMap}} - - {{/fields}} - /** - * Builds a {@link {{className}}}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public {{className}} build() { - _checkSingleUse(); - - return new {{className}}(this); - } - } + {{>ObjectBuilder}} {{#hasRequestBody}} public static final JsonpDeserializer<{{className}}> _DESERIALIZER = ObjectBuilderDeserializer From 02dec0441d95b8a2fe4d87c6907cd5ce7959f986 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Tue, 14 Feb 2023 17:10:55 +1300 Subject: [PATCH 05/50] Better handling of required fields Signed-off-by: Thomas Farr --- .../opensearch/ActionObjectStructure.java | 3 -- .../opensearch/DeleteIndexResponse.java | 3 -- .../opensearch/GetCatIndicesResponse.java | 3 -- .../GetCatIndicesWithIndexResponse.java | 3 -- .../opensearch/GetCatNodesResponse.java | 3 -- .../opensearch/GetClusterInfoResponse.java | 3 -- .../GetClusterSettingsResponse.java | 3 -- .../opensearch/GetDocumentDocResponse.java | 29 ++++++--------- .../opensearch/GetDocumentSourceResponse.java | 3 -- .../opensearch/GetSettingsIndexResponse.java | 3 -- .../GetSettingsIndexSettingResponse.java | 3 -- .../opensearch/client/opensearch/Hits.java | 3 -- .../client/opensearch/HitsMetadata.java | 3 -- .../opensearch/PostAliasesResponse.java | 15 ++++---- .../PostRemoteStoreRestoreResponse.java | 3 -- .../client/opensearch/PostSearchResponse.java | 3 -- .../PostSearchWithIndexResponse.java | 3 -- .../opensearch/PutCreateIndexResponse.java | 35 ++++++++----------- .../PutIndexMappingWithIndexResponse.java | 3 -- .../PutUpdateClusterSettingsResponse.java | 3 -- .../opensearch/RemoteStoreRestoreInfo.java | 3 -- .../RemoteStoreRestoreShardsInfo.java | 3 -- .../client/opensearch/ShardStatistics.java | 3 -- .../opensearch/client/opensearch/Total.java | 3 -- .../UserDefinedObjectStructure.java | 3 -- .../opensearch/UserDefinedStructure.java | 3 -- .../opensearch/client/opensearch/Version.java | 3 -- .../codegen/templates/ObjectBuilder.mustache | 2 +- .../codegen/templates/ObjectShape.mustache | 12 ++++--- .../templates/OperationRequest.mustache | 5 +++ 30 files changed, 44 insertions(+), 126 deletions(-) diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ActionObjectStructure.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ActionObjectStructure.java index f5d583943a..e62fc09557 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ActionObjectStructure.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ActionObjectStructure.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexResponse.java index 4da9057bd3..19a81bf229 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexResponse.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesResponse.java index debfd6b6ea..b0770295ff 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesResponse.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexResponse.java index c69d5cf019..8aad3408f1 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexResponse.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesResponse.java index 8178cca356..692abbaf60 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesResponse.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoResponse.java index 14b3c8a747..91513c5c22 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoResponse.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsResponse.java index d262e2afc3..ac05a8caf8 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsResponse.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocResponse.java index 6d5ffc073d..8b54dbd340 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocResponse.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; @@ -28,12 +25,12 @@ public class GetDocumentDocResponse implements JsonpSerializable { public GetDocumentDocResponse(Builder builder) { this.fields = ApiTypeHelper.unmodifiable(builder.fields); - this.id = builder.id; - this.index = builder.index; + this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); + this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); this.routing = builder.routing; this.source = ApiTypeHelper.unmodifiable(builder.source); this.type = builder.type; - this.found = builder.found; + this.found = ApiTypeHelper.requireNonNull(builder.found, this, "found"); this.primaryTerm = builder.primaryTerm; this.seqNo = builder.seqNo; this.version = builder.version; @@ -101,15 +98,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeEnd(); } - if (this.id != null) { - generator.writeKey("_id"); - generator.write(this.id); - } + generator.writeKey("_id"); + generator.write(this.id); - if (this.index != null) { - generator.writeKey("_index"); - generator.write(this.index); - } + generator.writeKey("_index"); + generator.write(this.index); if (this.routing != null) { generator.writeKey("_routing"); @@ -131,10 +124,8 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write(this.type); } - if (this.found != null) { - generator.writeKey("found"); - generator.write(this.found); - } + generator.writeKey("found"); + generator.write(this.found); if (this.primaryTerm != null) { generator.writeKey("primary_term"); @@ -161,7 +152,7 @@ public static class Builder extends ObjectBuilderBase private String routing; private Map source; private String type; - private boolean found; + private Boolean found; private Long primaryTerm; private Long seqNo; private Integer version; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceResponse.java index 9dd5df8d19..4152aef63c 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceResponse.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexResponse.java index fb69d71747..34c05cbdc6 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexResponse.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingResponse.java index 4284457182..48f11fc6a4 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingResponse.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/Hits.java b/java-client/src/generated/java/org/opensearch/client/opensearch/Hits.java index 289b8b6368..a9d7015502 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/Hits.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/Hits.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/HitsMetadata.java b/java-client/src/generated/java/org/opensearch/client/opensearch/HitsMetadata.java index ca35e6f0c8..ec8d810bd3 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/HitsMetadata.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/HitsMetadata.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesResponse.java index 9bf32312ed..edd38c8e71 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesResponse.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; @@ -16,7 +13,8 @@ public class PostAliasesResponse implements JsonpSerializable { private final boolean acknowledged; public PostAliasesResponse(Builder builder) { - this.acknowledged = builder.acknowledged; + this.acknowledged = + ApiTypeHelper.requireNonNull(builder.acknowledged, this, "acknowledged"); } public static PostAliasesResponse of(Function> fn) { @@ -34,16 +32,15 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.acknowledged != null) { - generator.writeKey("acknowledged"); - generator.write(this.acknowledged); - } + + generator.writeKey("acknowledged"); + generator.write(this.acknowledged); } /** Builder for {@link PostAliasesResponse}. */ public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private boolean acknowledged; + private Boolean acknowledged; public final Builder acknowledged(boolean value) { this.acknowledged = value; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreResponse.java index c84eccf932..2e6bd0d13c 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreResponse.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchResponse.java index 5d231361ff..b845c101b7 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchResponse.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexResponse.java index 074b00b7ed..ec4f52ff76 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexResponse.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexResponse.java index 3c47030919..e3013968e0 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexResponse.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; @@ -20,9 +17,12 @@ public class PutCreateIndexResponse implements JsonpSerializable { private final boolean shardsAcknowledged; public PutCreateIndexResponse(Builder builder) { - this.acknowledged = builder.acknowledged; - this.index = builder.index; - this.shardsAcknowledged = builder.shardsAcknowledged; + this.acknowledged = + ApiTypeHelper.requireNonNull(builder.acknowledged, this, "acknowledged"); + this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); + this.shardsAcknowledged = + ApiTypeHelper.requireNonNull( + builder.shardsAcknowledged, this, "shardsAcknowledged"); } public static PutCreateIndexResponse of( @@ -49,28 +49,23 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.acknowledged != null) { - generator.writeKey("acknowledged"); - generator.write(this.acknowledged); - } - if (this.index != null) { - generator.writeKey("index"); - generator.write(this.index); - } + generator.writeKey("acknowledged"); + generator.write(this.acknowledged); - if (this.shardsAcknowledged != null) { - generator.writeKey("shards_acknowledged"); - generator.write(this.shardsAcknowledged); - } + generator.writeKey("index"); + generator.write(this.index); + + generator.writeKey("shards_acknowledged"); + generator.write(this.shardsAcknowledged); } /** Builder for {@link PutCreateIndexResponse}. */ public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private boolean acknowledged; + private Boolean acknowledged; private String index; - private boolean shardsAcknowledged; + private Boolean shardsAcknowledged; public final Builder acknowledged(boolean value) { this.acknowledged = value; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexResponse.java index 9213f0e717..39ea8e82cf 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexResponse.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsResponse.java index 0ea1dedb68..4de0611c92 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsResponse.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreInfo.java b/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreInfo.java index d28202206b..6879a5a0ab 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreInfo.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreInfo.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreShardsInfo.java b/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreShardsInfo.java index c0e1d0644a..ab4149ab89 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreShardsInfo.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreShardsInfo.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ShardStatistics.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ShardStatistics.java index 7b58f06479..cade306dc8 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ShardStatistics.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ShardStatistics.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/Total.java b/java-client/src/generated/java/org/opensearch/client/opensearch/Total.java index bb9e8cf8c0..8d528c575a 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/Total.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/Total.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedObjectStructure.java b/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedObjectStructure.java index a0253c78ec..e2fadb4506 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedObjectStructure.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedObjectStructure.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedStructure.java b/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedStructure.java index 3de78e1dd9..83d13573f5 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedStructure.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedStructure.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/Version.java b/java-client/src/generated/java/org/opensearch/client/opensearch/Version.java index 2ef07badef..ec19170d96 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/Version.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/Version.java @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectBuilder.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectBuilder.mustache index cb9c2818be..bfee40ecde 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectBuilder.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectBuilder.mustache @@ -3,7 +3,7 @@ */ public static class Builder extends ObjectBuilderBase implements ObjectBuilder<{{className}}> { {{#fields}} - private {{{type}}} {{name}}; + private {{{type.boxed}}} {{name}}; {{/fields}} {{#fields}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache index 200d879919..d11b7c91cd 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache @@ -1,9 +1,6 @@ package org.opensearch.client.opensearch; -import org.opensearch.client.opensearch._types.*; import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; import jakarta.json.stream.JsonGenerator; import java.util.*; @@ -23,7 +20,12 @@ public class {{className}} implements JsonpSerializable { this.{{name}} = ApiTypeHelper.unmodifiable(builder.{{name}}); {{/type.isListOrMap}} {{^type.isListOrMap}} + {{#required}} + this.{{name}} = ApiTypeHelper.requireNonNull(builder.{{name}}, this, {{#dq}}{{name}}{{/dq}}); + {{/required}} + {{^required}} this.{{name}} = builder.{{name}}; + {{/required}} {{/type.isListOrMap}} {{/fields}} } @@ -46,10 +48,10 @@ public class {{className}} implements JsonpSerializable { protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { {{#fields}} - if ({{#type.isDefined}}this.{{name}}{{/type.isDefined}}) { + {{^required}}if ({{#type.isDefined}}this.{{name}}{{/type.isDefined}}) { {{/required}} generator.writeKey({{#dq}}{{wireName}}{{/dq}}); {{#type.serializer}}this.{{name}}{{/type.serializer}} - } + {{^required}} } {{/required}} {{/fields}} } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache index 42ee3cfb99..5cf73fbcb0 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache @@ -27,7 +27,12 @@ public class {{className}} extends RequestBase{{#hasRequestBody}} implements Jso this.{{name}} = ApiTypeHelper.unmodifiable(builder.{{name}}); {{/type.isListOrMap}} {{^type.isListOrMap}} + {{#required}} + this.{{name}} = ApiTypeHelper.requireNonNull(builder.{{name}}, this, {{#dq}}{{name}}{{/dq}}); + {{/required}} + {{^required}} this.{{name}} = builder.{{name}}; + {{/required}} {{/type.isListOrMap}} {{/fields}} } From e2c9c5b4f441254498bedbff8d062f88b7c14b24 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Wed, 15 Feb 2023 12:36:53 +1300 Subject: [PATCH 06/50] Unify templates for ObjectShape/OperationRequest Signed-off-by: Thomas Farr --- .../opensearch/ActionObjectStructure.java | 3 + .../client/opensearch/DeleteIndexRequest.java | 8 +- .../opensearch/DeleteIndexResponse.java | 1 + .../opensearch/GetCatIndicesRequest.java | 11 ++- .../GetCatIndicesWithIndexRequest.java | 11 ++- .../client/opensearch/GetCatNodesRequest.java | 10 ++- .../opensearch/GetClusterInfoRequest.java | 2 - .../opensearch/GetClusterInfoResponse.java | 5 ++ .../opensearch/GetClusterSettingsRequest.java | 6 +- .../GetClusterSettingsResponse.java | 3 + .../opensearch/GetDocumentDocRequest.java | 12 ++- .../opensearch/GetDocumentDocResponse.java | 7 ++ .../opensearch/GetDocumentSourceRequest.java | 12 ++- .../opensearch/GetSettingsIndexRequest.java | 10 ++- .../GetSettingsIndexSettingRequest.java | 10 ++- .../opensearch/client/opensearch/Hits.java | 6 ++ .../client/opensearch/HitsMetadata.java | 3 + .../client/opensearch/PostAliasesRequest.java | 4 + .../opensearch/PostAliasesResponse.java | 1 - .../PostRemoteStoreRestoreRequest.java | 16 ++-- .../PostRemoteStoreRestoreResponse.java | 2 + .../client/opensearch/PostSearchRequest.java | 46 ++++++++++++ .../client/opensearch/PostSearchResponse.java | 5 ++ .../PostSearchWithIndexRequest.java | 46 ++++++++++++ .../PostSearchWithIndexResponse.java | 5 ++ .../opensearch/PutCreateIndexRequest.java | 8 ++ .../opensearch/PutCreateIndexResponse.java | 1 - .../PutIndexMappingWithIndexRequest.java | 9 +++ .../PutIndexMappingWithIndexResponse.java | 1 + .../PutUpdateClusterSettingsRequest.java | 6 ++ .../PutUpdateClusterSettingsResponse.java | 3 + .../opensearch/RemoteStoreRestoreInfo.java | 3 + .../RemoteStoreRestoreShardsInfo.java | 3 + .../client/opensearch/ShardStatistics.java | 4 + .../opensearch/client/opensearch/Total.java | 2 + .../UserDefinedObjectStructure.java | 53 ++++++++++++++ .../opensearch/UserDefinedStructure.java | 11 +++ .../opensearch/client/opensearch/Version.java | 9 +++ .../client/codegen/ApiSpecification.java | 36 +++------ .../opensearch/client/codegen/TypeMapper.java | 10 +-- .../client/codegen/model/ObjectShape.java | 18 +++-- .../codegen/model/OperationRequest.java | 35 ++++++--- .../codegen/templates/ObjectShape.mustache | 61 ++-------------- .../Builder.mustache} | 0 .../ObjectShape/Constructor.mustache | 24 ++++++ .../ObjectShape/Deserialize.mustache | 7 ++ .../templates/ObjectShape/Fields.mustache | 7 ++ .../templates/ObjectShape/Getters.mustache | 6 ++ .../templates/ObjectShape/Serialize.mustache | 19 +++++ .../templates/OperationRequest.mustache | 73 ++++--------------- 50 files changed, 464 insertions(+), 190 deletions(-) rename java-codegen/src/main/resources/org/opensearch/client/codegen/templates/{ObjectBuilder.mustache => ObjectShape/Builder.mustache} (100%) create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Constructor.mustache create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Fields.mustache create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Getters.mustache create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ActionObjectStructure.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ActionObjectStructure.java index e62fc09557..584bf575ef 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ActionObjectStructure.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ActionObjectStructure.java @@ -9,8 +9,11 @@ @JsonpDeserializable public class ActionObjectStructure implements JsonpSerializable { + @Nullable private final UserDefinedStructure add; + @Nullable private final UserDefinedStructure remove; + @Nullable private final UserDefinedStructure removeIndex; public ActionObjectStructure(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java index 90042648a5..b6b9008593 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java @@ -1,11 +1,9 @@ package org.opensearch.client.opensearch; import org.opensearch.client.opensearch._types.*; - import org.opensearch.client.transport.*; import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; - import java.util.*; import java.util.function.Function; import java.util.stream.*; @@ -13,11 +11,17 @@ /** Removes a document from the index. */ public class DeleteIndexRequest extends RequestBase { + @Nullable private final Boolean allowNoIndices; + @Nullable private final String clusterManagerTimeout; + @Nullable private final ExpandWildcards expandWildcards; + @Nullable private final Boolean ignoreUnavailable; + @Nullable private final String masterTimeout; + @Nullable private final String timeout; public DeleteIndexRequest(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexResponse.java index 19a81bf229..36af738b03 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexResponse.java @@ -9,6 +9,7 @@ @JsonpDeserializable public class DeleteIndexResponse implements JsonpSerializable { + @Nullable private final Boolean acknowledged; public DeleteIndexResponse(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesRequest.java index cd5ca54df5..db7e69a89c 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesRequest.java @@ -1,11 +1,9 @@ package org.opensearch.client.opensearch; import org.opensearch.client.opensearch._types.*; - import org.opensearch.client.transport.*; import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; - import java.util.*; import java.util.function.Function; import java.util.stream.*; @@ -16,14 +14,23 @@ * etc. */ public class GetCatIndicesRequest extends RequestBase { + @Nullable private final Integer bytes; + @Nullable private final String clusterManagerTimeout; + @Nullable private final ExpandWildcards expandWildcards; + @Nullable private final String format; + @Nullable private final HealthStatus health; + @Nullable private final Boolean includeUnloadedSegments; + @Nullable private final String masterTimeout; + @Nullable private final Boolean pri; + @Nullable private final String time; public GetCatIndicesRequest(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java index 9b66490cff..96e2dfca6d 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java @@ -1,11 +1,9 @@ package org.opensearch.client.opensearch; import org.opensearch.client.opensearch._types.*; - import org.opensearch.client.transport.*; import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; - import java.util.*; import java.util.function.Function; import java.util.stream.*; @@ -16,14 +14,23 @@ * etc. */ public class GetCatIndicesWithIndexRequest extends RequestBase { + @Nullable private final Integer bytes; + @Nullable private final String clusterManagerTimeout; + @Nullable private final ExpandWildcards expandWildcards; + @Nullable private final String format; + @Nullable private final HealthStatus health; + @Nullable private final Boolean includeUnloadedSegments; + @Nullable private final String masterTimeout; + @Nullable private final Boolean pri; + @Nullable private final String time; public GetCatIndicesWithIndexRequest(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesRequest.java index 537ef92afd..9e236ca1f6 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesRequest.java @@ -1,11 +1,9 @@ package org.opensearch.client.opensearch; import org.opensearch.client.opensearch._types.*; - import org.opensearch.client.transport.*; import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; - import java.util.*; import java.util.function.Function; import java.util.stream.*; @@ -13,13 +11,21 @@ /** Returns basic statistics about performance of cluster nodes. */ public class GetCatNodesRequest extends RequestBase { + @Nullable private final Integer bytes; + @Nullable private final String clusterManagerTimeout; + @Nullable private final String format; + @Nullable private final Boolean fullId; + @Nullable private final Boolean includeUnloadedSegments; + @Nullable private final Boolean local; + @Nullable private final String masterTimeout; + @Nullable private final String time; public GetCatNodesRequest(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoRequest.java index 9e9d2a4230..15d740edcc 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoRequest.java @@ -1,11 +1,9 @@ package org.opensearch.client.opensearch; import org.opensearch.client.opensearch._types.*; - import org.opensearch.client.transport.*; import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; - import java.util.*; import java.util.function.Function; import java.util.stream.*; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoResponse.java index 91513c5c22..65215b64b2 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoResponse.java @@ -9,10 +9,15 @@ @JsonpDeserializable public class GetClusterInfoResponse implements JsonpSerializable { + @Nullable private final String clusterName; + @Nullable private final String clusterUuid; + @Nullable private final String name; + @Nullable private final String tagline; + @Nullable private final Version version; public GetClusterInfoResponse(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsRequest.java index 9e47d32a2a..6f237a27e0 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsRequest.java @@ -1,11 +1,9 @@ package org.opensearch.client.opensearch; import org.opensearch.client.opensearch._types.*; - import org.opensearch.client.transport.*; import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; - import java.util.*; import java.util.function.Function; import java.util.stream.*; @@ -13,9 +11,13 @@ /** Returns cluster settings. */ public class GetClusterSettingsRequest extends RequestBase { + @Nullable private final String clusterManagerTimeout; + @Nullable private final Boolean flatSettings; + @Nullable private final Boolean includeDefaults; + @Nullable private final String masterTimeout; public GetClusterSettingsRequest(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsResponse.java index ac05a8caf8..b4056e2214 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsResponse.java @@ -9,8 +9,11 @@ @JsonpDeserializable public class GetClusterSettingsResponse implements JsonpSerializable { + @Nullable private final Map defaults; + @Nullable private final Map persistent; + @Nullable private final Map transient_; public GetClusterSettingsResponse(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java index a11b62e085..ac43d3d217 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java @@ -1,11 +1,9 @@ package org.opensearch.client.opensearch; import org.opensearch.client.opensearch._types.*; - import org.opensearch.client.transport.*; import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; - import java.util.*; import java.util.function.Function; import java.util.stream.*; @@ -13,15 +11,25 @@ /** Returns a document */ public class GetDocumentDocRequest extends RequestBase { + @Nullable private final String source; + @Nullable private final String sourceExcludes; + @Nullable private final String sourceIncludes; + @Nullable private final String preference; + @Nullable private final Boolean realtime; + @Nullable private final Boolean refresh; + @Nullable private final String routing; + @Nullable private final Boolean storedFields; + @Nullable private final Integer version; + @Nullable private final VersionType versionType; public GetDocumentDocRequest(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocResponse.java index 8b54dbd340..6b68a24900 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocResponse.java @@ -9,18 +9,25 @@ @JsonpDeserializable public class GetDocumentDocResponse implements JsonpSerializable { + @Nullable private final Map fields; private final String id; private final String index; + @Nullable private final String routing; + @Nullable private final Map source; + @Nullable private final String type; private final boolean found; + @Nullable private final Long primaryTerm; + @Nullable private final Long seqNo; + @Nullable private final Integer version; public GetDocumentDocResponse(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java index 1ebd1da9d1..c15867ba7d 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java @@ -1,11 +1,9 @@ package org.opensearch.client.opensearch; import org.opensearch.client.opensearch._types.*; - import org.opensearch.client.transport.*; import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; - import java.util.*; import java.util.function.Function; import java.util.stream.*; @@ -13,15 +11,25 @@ /** Returns a document. */ public class GetDocumentSourceRequest extends RequestBase { + @Nullable private final String source; + @Nullable private final String sourceExcludes; + @Nullable private final String sourceIncludes; + @Nullable private final String preference; + @Nullable private final Boolean realtime; + @Nullable private final Boolean refresh; + @Nullable private final String routing; + @Nullable private final Boolean storedFields; + @Nullable private final Integer version; + @Nullable private final VersionType versionType; public GetDocumentSourceRequest(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java index e347514197..d9d4f899fa 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java @@ -1,11 +1,9 @@ package org.opensearch.client.opensearch; import org.opensearch.client.opensearch._types.*; - import org.opensearch.client.transport.*; import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; - import java.util.*; import java.util.function.Function; import java.util.stream.*; @@ -13,13 +11,21 @@ /** The get settings API operation returns all the settings in your index. */ public class GetSettingsIndexRequest extends RequestBase { + @Nullable private final Boolean allowNoIndices; + @Nullable private final String clusterManagerTimeout; + @Nullable private final ExpandWildcards expandWildcards; + @Nullable private final Boolean flatSettings; + @Nullable private final Boolean ignoreUnavailable; + @Nullable private final String includeDefaults; + @Nullable private final Boolean local; + @Nullable private final String masterTimeout; public GetSettingsIndexRequest(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java index 23ae4d4e1b..e8c8b55b3c 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java @@ -1,11 +1,9 @@ package org.opensearch.client.opensearch; import org.opensearch.client.opensearch._types.*; - import org.opensearch.client.transport.*; import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; - import java.util.*; import java.util.function.Function; import java.util.stream.*; @@ -13,13 +11,21 @@ /** The get settings API operation returns all the settings in your index. */ public class GetSettingsIndexSettingRequest extends RequestBase { + @Nullable private final Boolean allowNoIndices; + @Nullable private final String clusterManagerTimeout; + @Nullable private final ExpandWildcards expandWildcards; + @Nullable private final Boolean flatSettings; + @Nullable private final Boolean ignoreUnavailable; + @Nullable private final String includeDefaults; + @Nullable private final Boolean local; + @Nullable private final String masterTimeout; public GetSettingsIndexSettingRequest(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/Hits.java b/java-client/src/generated/java/org/opensearch/client/opensearch/Hits.java index a9d7015502..aed09276bb 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/Hits.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/Hits.java @@ -9,11 +9,17 @@ @JsonpDeserializable public class Hits implements JsonpSerializable { + @Nullable private final String id; + @Nullable private final String index; + @Nullable private final Float score; + @Nullable private final JsonData source; + @Nullable private final String type; + @Nullable private final JsonData fields; public Hits(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/HitsMetadata.java b/java-client/src/generated/java/org/opensearch/client/opensearch/HitsMetadata.java index ec8d810bd3..9ec65d9054 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/HitsMetadata.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/HitsMetadata.java @@ -9,8 +9,11 @@ @JsonpDeserializable public class HitsMetadata implements JsonpSerializable { + @Nullable private final List hits; + @Nullable private final Double maxScore; + @Nullable private final Total total; public HitsMetadata(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesRequest.java index 3cb094389b..03ed4eecba 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesRequest.java @@ -14,9 +14,13 @@ /** Adds or removes index aliases. */ @JsonpDeserializable public class PostAliasesRequest extends RequestBase implements JsonpSerializable { + @Nullable private final ActionObjectStructure actions; + @Nullable private final String clusterManagerTimeout; + @Nullable private final String masterTimeout; + @Nullable private final String timeout; public PostAliasesRequest(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesResponse.java index edd38c8e71..205b356d63 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesResponse.java @@ -32,7 +32,6 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("acknowledged"); generator.write(this.acknowledged); } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreRequest.java index c013f52384..ec57ef737a 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreRequest.java @@ -14,14 +14,16 @@ /** Restore one or more indices from a remote backup. */ @JsonpDeserializable public class PostRemoteStoreRestoreRequest extends RequestBase implements JsonpSerializable { + @Nullable private final String clusterManagerTimeout; private final List indices; + @Nullable private final Boolean waitForCompletion; public PostRemoteStoreRestoreRequest(Builder builder) { this.clusterManagerTimeout = builder.clusterManagerTimeout; - this.indices = ApiTypeHelper.unmodifiable(builder.indices); + this.indices = ApiTypeHelper.unmodifiableRequired(builder.indices, this, "indices"); this.waitForCompletion = builder.waitForCompletion; } @@ -49,14 +51,12 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (ApiTypeHelper.isDefined(this.indices)) { - generator.writeKey("indices"); - generator.writeStartArray(); - for (String item0 : this.indices) { - generator.write(item0); - } - generator.writeEnd(); + generator.writeKey("indices"); + generator.writeStartArray(); + for (String item0 : this.indices) { + generator.write(item0); } + generator.writeEnd(); } /** Builder for {@link PostRemoteStoreRestoreRequest}. */ diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreResponse.java index 2e6bd0d13c..fdf61e2d5d 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreResponse.java @@ -9,7 +9,9 @@ @JsonpDeserializable public class PostRemoteStoreRestoreResponse implements JsonpSerializable { + @Nullable private final Boolean accepted; + @Nullable private final RemoteStoreRestoreInfo remoteStore; public PostRemoteStoreRestoreResponse(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchRequest.java index c050c15a2c..396bd648a1 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchRequest.java @@ -14,51 +14,97 @@ /** Returns results matching a query. */ @JsonpDeserializable public class PostSearchRequest extends RequestBase implements JsonpSerializable { + @Nullable private final Boolean allowNoIndices; + @Nullable private final Boolean allowPartialSearchResults; + @Nullable private final Boolean analyzeWildcard; + @Nullable private final String analyzer; + @Nullable private final Integer batchedReduceSize; + @Nullable private final Boolean ccsMinimizeRoundtrips; + @Nullable private final DefaultOperator defaultOperator; + @Nullable private final String df; + @Nullable private final String docvalueFields; + @Nullable private final ExpandWildcards expandWildcards; + @Nullable private final Boolean explain; + @Nullable private final List fields; + @Nullable private final Integer from; + @Nullable private final Boolean ignoreThrottled; + @Nullable private final Boolean ignoreUnavailable; + @Nullable private final List indicesBoost; + @Nullable private final Boolean lenient; + @Nullable private final Long maxConcurrentShardRequests; + @Nullable private final Integer minScore; + @Nullable private final Long preFilterShardSize; + @Nullable private final String preference; + @Nullable private final String q; + @Nullable private final UserDefinedObjectStructure query; + @Nullable private final Boolean requestCache; + @Nullable private final Boolean restTotalHitsAsInt; + @Nullable private final String routing; + @Nullable private final String scroll; + @Nullable private final SearchType searchType; + @Nullable private final Boolean seqNoPrimaryTerm; + @Nullable private final Integer size; + @Nullable private final List sort; + @Nullable private final String source; + @Nullable private final List sourceExcludes; + @Nullable private final List sourceIncludes; + @Nullable private final String stats; + @Nullable private final Boolean storedFields; + @Nullable private final String suggestField; + @Nullable private final SuggestMode suggestMode; + @Nullable private final Long suggestSize; + @Nullable private final String suggestText; + @Nullable private final Integer terminateAfter; + @Nullable private final String timeout; + @Nullable private final Boolean trackScores; + @Nullable private final Integer trackTotalHits; + @Nullable private final Boolean typedKeys; + @Nullable private final Boolean version; public PostSearchRequest(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchResponse.java index b845c101b7..b1fea660df 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchResponse.java @@ -9,10 +9,15 @@ @JsonpDeserializable public class PostSearchResponse implements JsonpSerializable { + @Nullable private final String scrollId; + @Nullable private final ShardStatistics shards; + @Nullable private final HitsMetadata hits; + @Nullable private final Boolean timedOut; + @Nullable private final Long took; public PostSearchResponse(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java index cd479f85d7..66dcf7816e 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java @@ -14,51 +14,97 @@ /** Returns results matching a query. */ @JsonpDeserializable public class PostSearchWithIndexRequest extends RequestBase implements JsonpSerializable { + @Nullable private final Boolean allowNoIndices; + @Nullable private final Boolean allowPartialSearchResults; + @Nullable private final Boolean analyzeWildcard; + @Nullable private final String analyzer; + @Nullable private final Integer batchedReduceSize; + @Nullable private final Boolean ccsMinimizeRoundtrips; + @Nullable private final DefaultOperator defaultOperator; + @Nullable private final String df; + @Nullable private final String docvalueFields; + @Nullable private final ExpandWildcards expandWildcards; + @Nullable private final Boolean explain; + @Nullable private final List fields; + @Nullable private final Integer from; + @Nullable private final Boolean ignoreThrottled; + @Nullable private final Boolean ignoreUnavailable; + @Nullable private final List indicesBoost; + @Nullable private final Boolean lenient; + @Nullable private final Long maxConcurrentShardRequests; + @Nullable private final Integer minScore; + @Nullable private final Long preFilterShardSize; + @Nullable private final String preference; + @Nullable private final String q; + @Nullable private final UserDefinedObjectStructure query; + @Nullable private final Boolean requestCache; + @Nullable private final Boolean restTotalHitsAsInt; + @Nullable private final String routing; + @Nullable private final String scroll; + @Nullable private final SearchType searchType; + @Nullable private final Boolean seqNoPrimaryTerm; + @Nullable private final Integer size; + @Nullable private final List sort; + @Nullable private final String source; + @Nullable private final List sourceExcludes; + @Nullable private final List sourceIncludes; + @Nullable private final String stats; + @Nullable private final Boolean storedFields; + @Nullable private final String suggestField; + @Nullable private final SuggestMode suggestMode; + @Nullable private final Long suggestSize; + @Nullable private final String suggestText; + @Nullable private final Integer terminateAfter; + @Nullable private final String timeout; + @Nullable private final Boolean trackScores; + @Nullable private final Integer trackTotalHits; + @Nullable private final Boolean typedKeys; + @Nullable private final Boolean version; public PostSearchWithIndexRequest(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexResponse.java index ec4f52ff76..aa9d9b44fe 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexResponse.java @@ -9,10 +9,15 @@ @JsonpDeserializable public class PostSearchWithIndexResponse implements JsonpSerializable { + @Nullable private final String scrollId; + @Nullable private final ShardStatistics shards; + @Nullable private final HitsMetadata hits; + @Nullable private final Boolean timedOut; + @Nullable private final Long took; public PostSearchWithIndexResponse(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java index a8dddc31c5..d809d02410 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java @@ -14,13 +14,21 @@ /** Creates index mappings. */ @JsonpDeserializable public class PutCreateIndexRequest extends RequestBase implements JsonpSerializable { + @Nullable private final Map aliases; + @Nullable private final String clusterManagerTimeout; + @Nullable private final Boolean includeTypeName; + @Nullable private final Map mapping; + @Nullable private final String masterTimeout; + @Nullable private final Map settings; + @Nullable private final String timeout; + @Nullable private final String waitForActiveShards; public PutCreateIndexRequest(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexResponse.java index e3013968e0..a6d18ea208 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexResponse.java @@ -49,7 +49,6 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("acknowledged"); generator.write(this.acknowledged); diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java index f7dceeece6..ec1fc9a170 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java @@ -14,14 +14,23 @@ /** The put mapping API operation lets you add new mappings and fields to an index. */ @JsonpDeserializable public class PutIndexMappingWithIndexRequest extends RequestBase implements JsonpSerializable { + @Nullable private final Boolean allowNoIndices; + @Nullable private final String clusterManagerTimeout; + @Nullable private final ExpandWildcards expandWildcards; + @Nullable private final Boolean ignoreUnavailable; + @Nullable private final Boolean includeTypeName; + @Nullable private final String masterTimeout; + @Nullable private final JsonData properties; + @Nullable private final String timeout; + @Nullable private final Boolean writeIndexOnly; public PutIndexMappingWithIndexRequest(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexResponse.java index 39ea8e82cf..996f291c39 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexResponse.java @@ -9,6 +9,7 @@ @JsonpDeserializable public class PutIndexMappingWithIndexResponse implements JsonpSerializable { + @Nullable private final Boolean acknowledged; public PutIndexMappingWithIndexResponse(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsRequest.java index 048718fd43..d8c4d50354 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsRequest.java @@ -14,11 +14,17 @@ /** Updates the cluster settings. */ @JsonpDeserializable public class PutUpdateClusterSettingsRequest extends RequestBase implements JsonpSerializable { + @Nullable private final String clusterManagerTimeout; + @Nullable private final Boolean flatSettings; + @Nullable private final String masterTimeout; + @Nullable private final Map persistent; + @Nullable private final String timeout; + @Nullable private final Map transient_; public PutUpdateClusterSettingsRequest(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsResponse.java index 4de0611c92..e2ef0420d5 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsResponse.java @@ -9,8 +9,11 @@ @JsonpDeserializable public class PutUpdateClusterSettingsResponse implements JsonpSerializable { + @Nullable private final Boolean acknowledged; + @Nullable private final Map persistent; + @Nullable private final Map transient_; public PutUpdateClusterSettingsResponse(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreInfo.java b/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreInfo.java index 6879a5a0ab..8ab1fad1ab 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreInfo.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreInfo.java @@ -9,8 +9,11 @@ @JsonpDeserializable public class RemoteStoreRestoreInfo implements JsonpSerializable { + @Nullable private final List indices; + @Nullable private final RemoteStoreRestoreShardsInfo shards; + @Nullable private final String snapshot; public RemoteStoreRestoreInfo(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreShardsInfo.java b/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreShardsInfo.java index ab4149ab89..222c8e10b4 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreShardsInfo.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreShardsInfo.java @@ -9,8 +9,11 @@ @JsonpDeserializable public class RemoteStoreRestoreShardsInfo implements JsonpSerializable { + @Nullable private final Integer failed; + @Nullable private final Integer successful; + @Nullable private final Integer total; public RemoteStoreRestoreShardsInfo(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ShardStatistics.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ShardStatistics.java index cade306dc8..a5c5a544c7 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ShardStatistics.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ShardStatistics.java @@ -9,9 +9,13 @@ @JsonpDeserializable public class ShardStatistics implements JsonpSerializable { + @Nullable private final Integer failed; + @Nullable private final Integer skipped; + @Nullable private final Integer successful; + @Nullable private final Integer total; public ShardStatistics(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/Total.java b/java-client/src/generated/java/org/opensearch/client/opensearch/Total.java index 8d528c575a..3a9fe5450a 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/Total.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/Total.java @@ -9,7 +9,9 @@ @JsonpDeserializable public class Total implements JsonpSerializable { + @Nullable private final Relation relation; + @Nullable private final Integer value; public Total(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedObjectStructure.java b/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedObjectStructure.java index e2fadb4506..a6832226a5 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedObjectStructure.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedObjectStructure.java @@ -9,58 +9,111 @@ @JsonpDeserializable public class UserDefinedObjectStructure implements JsonpSerializable { + @Nullable private final JsonData bool; + @Nullable private final JsonData boosting; + @Nullable private final JsonData combinedFields; + @Nullable private final JsonData constantScore; + @Nullable private final JsonData disMax; + @Nullable private final JsonData distanceFeature; + @Nullable private final JsonData exists; + @Nullable private final JsonData fieldMaskingSpan; + @Nullable private final JsonData functionScore; + @Nullable private final Map fuzzy; + @Nullable private final JsonData geoBoundingBox; + @Nullable private final JsonData geoDistance; + @Nullable private final JsonData geoPolygon; + @Nullable private final JsonData geoShape; + @Nullable private final JsonData hasChild; + @Nullable private final JsonData hasParent; + @Nullable private final JsonData ids; + @Nullable private final Map intervals; + @Nullable private final JsonData knn; + @Nullable private final Map match; + @Nullable private final JsonData matchAll; + @Nullable private final Map matchBoolPrefix; + @Nullable private final JsonData matchNone; + @Nullable private final Map matchPhrase; + @Nullable private final Map matchPhrasePrefix; + @Nullable private final JsonData moreLikeThis; + @Nullable private final JsonData multiMatch; + @Nullable private final JsonData nested; + @Nullable private final JsonData parentId; + @Nullable private final JsonData percolate; + @Nullable private final JsonData pinned; + @Nullable private final Map prefix; + @Nullable private final JsonData queryString; + @Nullable private final Map range; + @Nullable private final JsonData rankFeature; + @Nullable private final Map regexp; + @Nullable private final JsonData script; + @Nullable private final JsonData scriptScore; + @Nullable private final JsonData shape; + @Nullable private final JsonData simpleQueryString; + @Nullable private final JsonData spanContaining; + @Nullable private final JsonData spanFirst; + @Nullable private final JsonData spanMulti; + @Nullable private final JsonData spanNear; + @Nullable private final JsonData spanNot; + @Nullable private final JsonData spanOr; + @Nullable private final Map spanTerm; + @Nullable private final JsonData spanWithin; + @Nullable private final Map term; + @Nullable private final JsonData terms; + @Nullable private final Map termsSet; + @Nullable private final Map wildcard; + @Nullable private final JsonData wrapper; public UserDefinedObjectStructure(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedStructure.java b/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedStructure.java index 83d13573f5..b57971d3e6 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedStructure.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedStructure.java @@ -9,16 +9,27 @@ @JsonpDeserializable public class UserDefinedStructure implements JsonpSerializable { + @Nullable private final String alias; + @Nullable private final List aliases; + @Nullable private final JsonData filter; + @Nullable private final String index; + @Nullable private final String indexRouting; + @Nullable private final List indices; + @Nullable private final Boolean isHidden; + @Nullable private final Boolean isWriteIndex; + @Nullable private final String mustExist; + @Nullable private final String routing; + @Nullable private final String searchRouting; public UserDefinedStructure(Builder builder) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/Version.java b/java-client/src/generated/java/org/opensearch/client/opensearch/Version.java index ec19170d96..a9cd5a1f0f 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/Version.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/Version.java @@ -9,14 +9,23 @@ @JsonpDeserializable public class Version implements JsonpSerializable { + @Nullable private final String buildDate; + @Nullable private final String buildHash; + @Nullable private final Boolean buildSnapshot; + @Nullable private final String buildType; + @Nullable private final String distribution; + @Nullable private final String luceneVersion; + @Nullable private final String minimumIndexCompatibilityVersion; + @Nullable private final String minimumWireCompatibilityVersion; + @Nullable private final String number; public Version(Builder builder) { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java b/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java index 91491a3719..34c6d700e7 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java @@ -4,7 +4,6 @@ import org.openapi4j.core.exception.ResolutionException; import org.openapi4j.core.model.OAIContext; import org.openapi4j.core.model.reference.Reference; -import org.openapi4j.core.model.v3.OAI3SchemaKeywords; import org.openapi4j.core.validation.ValidationException; import org.openapi4j.parser.OpenApi3Parser; import org.openapi4j.parser.model.AbsRefOpenApiSchema; @@ -23,7 +22,6 @@ import java.util.stream.Stream; public class ApiSpecification { - private final OpenApi3 api; private final OAIContext context; private final Set visitedReferencedSchemas; private final List operationRequests; @@ -32,14 +30,13 @@ public class ApiSpecification { private final TypeMapper typeMapper; private ApiSpecification(OpenApi3 api) throws ApiSpecificationParseException { - this.api = api; context = api.getContext(); visitedReferencedSchemas = new HashSet<>(); operationRequests = new ArrayList<>(); objectShapes = new ArrayList<>(); enumShapes = new ArrayList<>(); - typeMapper = new TypeMapper(this.api, this::visitReferencedSchema); - visit(this.api); + typeMapper = new TypeMapper(context, this::visitReferencedSchema); + visit(api); } public static ApiSpecification parse(File schemaFile) throws ApiSpecificationParseException { @@ -65,27 +62,23 @@ public List getEnumShapes() { private void visit(OpenApi3 api) throws ApiSpecificationParseException { for (Map.Entry entry : api.getPaths().entrySet()) { - String httpPath = entry.getKey(); - Path path = entry.getValue(); - - visit(httpPath, path); + visit(entry.getKey(), entry.getValue()); } } private void visit(String httpPath, Path path) throws ApiSpecificationParseException { for (Map.Entry entry : path.getOperations().entrySet()) { - String httpMethod = entry.getKey(); - Operation operation = entry.getValue(); - visit(httpPath, path, httpMethod, operation); + visit(httpPath, path, entry.getKey(), entry.getValue()); } } private void visit(String httpPath, Path path, String httpMethod, Operation operation) throws ApiSpecificationParseException { - OperationRequest operationRequest = new OperationRequest(); - operationRequest.operationId = operation.getOperationId(); - operationRequest.description = operation.getDescription(); - operationRequest.httpMethod = httpMethod; - operationRequest.httpPath = httpPath; + OperationRequest operationRequest = new OperationRequest( + operation.getOperationId(), + operation.getDescription(), + httpMethod, + httpPath + ); RequestBody requestBody = resolve(operation.getRequestBody()); @@ -101,7 +94,6 @@ private void visit(String httpPath, Path path, String httpMethod, Operation oper operationRequests.add(operationRequest); - MediaType responseMediaType = operation.getResponse("200").getContentMediaType("application/json"); Schema responseSchema = responseMediaType != null ? resolve(responseMediaType.getSchema()) : new Schema(); visitObjectShape(operation.getOperationId() + "Response", responseSchema); @@ -121,12 +113,8 @@ private void visitReferencedSchema(String ref, Schema schema) { } private void visitObjectShape(String name, Schema schema) { - ObjectShape shape = new ObjectShape(); - - shape.name = name; - - visitFields(schema, shape::addField); - + ObjectShape shape = new ObjectShape(name); + visitFields(schema, shape::addBodyField); objectShapes.add(shape); } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java b/java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java index b3a2fb150e..4f84d1e65b 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java @@ -1,7 +1,7 @@ package org.opensearch.client.codegen; +import org.openapi4j.core.model.OAIContext; import org.openapi4j.core.model.v3.OAI3SchemaKeywords; -import org.openapi4j.parser.model.v3.OpenApi3; import org.openapi4j.parser.model.v3.Schema; import org.opensearch.client.codegen.model.Type; import org.opensearch.client.codegen.utils.Schemas; @@ -11,12 +11,12 @@ import java.util.function.BiConsumer; public class TypeMapper { - private final OpenApi3 api; + private final OAIContext context; private final Map cache = new ConcurrentHashMap<>(); private final BiConsumer referencedSchemaVisitor; - public TypeMapper(OpenApi3 api, BiConsumer referencedSchemaVisitor) { - this.api = api; + public TypeMapper(OAIContext context, BiConsumer referencedSchemaVisitor) { + this.context = context; this.referencedSchemaVisitor = referencedSchemaVisitor; } @@ -35,7 +35,7 @@ public Type mapType(Schema schema, boolean boxed) { private Type mapTypeInner(Schema schema) { if (schema.isRef()) { - Schema target = schema.getFlatSchema(api.getContext()); + Schema target = schema.getFlatSchema(context); if (!shouldKeepRef(target)) { return mapType(target); diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java index 328d8d92ac..d398ade0dc 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java @@ -5,18 +5,24 @@ import java.util.TreeMap; public class ObjectShape { - public String name; - private final Map fields = new TreeMap<>(); + private final String className; + private final Map bodyFields = new TreeMap<>(); - public void addField(Field field) { - fields.put(field.wireName, field); + public ObjectShape(String className) { + this.className = className; + } + + public void addBodyField(Field field) { + bodyFields.put(field.wireName, field); } public String className() { - return name; + return className; } + public Collection bodyFields() { return bodyFields.values(); } + public Collection fields() { - return fields.values(); + return bodyFields(); } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/OperationRequest.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/OperationRequest.java index 241f2505f2..5c3ac58bf2 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/OperationRequest.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/OperationRequest.java @@ -2,29 +2,40 @@ import java.util.*; -public class OperationRequest { - public String operationId; - public String description; - public String httpMethod; - public String httpPath; - private final Map bodyFields = new TreeMap<>(); +public class OperationRequest extends ObjectShape { + private final String id; + private final String description; + private final String httpMethod; + private final String httpPath; private final Map queryParams = new TreeMap<>(); private final Map fields = new TreeMap<>(); - public String className() { - return operationId + "Request"; + public OperationRequest(String id, String description, String httpMethod, String httpPath) { + super(id + "Request"); + this.id = id; + this.description = description; + this.httpMethod = httpMethod; + this.httpPath = httpPath; } - public String responseType() { return operationId + "Response"; } + public String description() { return description; } - public boolean hasRequestBody() { return !bodyFields.isEmpty(); } + public String httpMethod() { return httpMethod; } + + public String httpPath() { return httpPath; } + + public String responseType() { return id + "Response"; } + + public boolean hasRequestBody() { return !bodyFields().isEmpty(); } - public Collection bodyFields() { return bodyFields.values(); } public Collection queryParams() { return queryParams.values(); } + + @Override public Collection fields() { return fields.values(); } + @Override public void addBodyField(Field field) { - bodyFields.put(field.wireName, field); + super.addBodyField(field); fields.put(field.wireName, field); } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache index d11b7c91cd..15430f824c 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache @@ -9,62 +9,13 @@ import javax.annotation.*; @JsonpDeserializable public class {{className}} implements JsonpSerializable { - {{#fields}} - {{^required}}@Nullable{{/required}} - private final {{{type}}} {{name}}; - {{/fields}} + {{>ObjectShape/Fields}} + {{>ObjectShape/Constructor}} + {{>ObjectShape/Getters}} - public {{className}}(Builder builder) { - {{#fields}} - {{#type.isListOrMap}} - this.{{name}} = ApiTypeHelper.unmodifiable(builder.{{name}}); - {{/type.isListOrMap}} - {{^type.isListOrMap}} - {{#required}} - this.{{name}} = ApiTypeHelper.requireNonNull(builder.{{name}}, this, {{#dq}}{{name}}{{/dq}}); - {{/required}} - {{^required}} - this.{{name}} = builder.{{name}}; - {{/required}} - {{/type.isListOrMap}} - {{/fields}} - } + {{>ObjectShape/Serialize}} - public static {{className}} of(Function> fn) { - return fn.apply(new Builder()).build(); - } + {{>ObjectShape/Builder}} - {{#fields}} - public final {{{type}}} {{name}}() { - return this.{{name}}; - } - - {{/fields}} - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - {{#fields}} - {{^required}}if ({{#type.isDefined}}this.{{name}}{{/type.isDefined}}) { {{/required}} - generator.writeKey({{#dq}}{{wireName}}{{/dq}}); - {{#type.serializer}}this.{{name}}{{/type.serializer}} - {{^required}} } {{/required}} - - {{/fields}} - } - - {{>ObjectBuilder}} - - public static final JsonpDeserializer<{{className}}> _DESERIALIZER = ObjectBuilderDeserializer - .lazy(Builder::new, {{className}}::setup{{className}}Deserializer); - - protected static void setup{{className}}Deserializer( - ObjectDeserializer<{{className}}.Builder> op) { - {{#fields}} - op.add(Builder::{{name}}, {{{type.deserializer}}}, {{#dq}}{{wireName}}{{/dq}}); - {{/fields}} - } + {{>ObjectShape/Deserialize}} } \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectBuilder.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache similarity index 100% rename from java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectBuilder.mustache rename to java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Constructor.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Constructor.mustache new file mode 100644 index 0000000000..7d7cd67e2b --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Constructor.mustache @@ -0,0 +1,24 @@ + public {{className}}(Builder builder) { +{{#fields}} +{{#type.isListOrMap}} + {{#required}} + this.{{name}} = ApiTypeHelper.unmodifiableRequired(builder.{{name}}, this, {{#dq}}{{name}}{{/dq}}); + {{/required}} + {{^required}} + this.{{name}} = ApiTypeHelper.unmodifiable(builder.{{name}}); + {{/required}} +{{/type.isListOrMap}} +{{^type.isListOrMap}} + {{#required}} + this.{{name}} = ApiTypeHelper.requireNonNull(builder.{{name}}, this, {{#dq}}{{name}}{{/dq}}); + {{/required}} + {{^required}} + this.{{name}} = builder.{{name}}; + {{/required}} +{{/type.isListOrMap}} +{{/fields}} + } + + public static {{className}} of(Function> fn) { + return fn.apply(new Builder()).build(); + } \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache new file mode 100644 index 0000000000..241b2a0c7f --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache @@ -0,0 +1,7 @@ + public static final JsonpDeserializer<{{className}}> _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, {{className}}::setup{{className}}Deserializer); + + protected static void setup{{className}}Deserializer(ObjectDeserializer<{{className}}.Builder> op) { + {{#bodyFields}} + op.add(Builder::{{name}}, {{{type.deserializer}}}, {{#dq}}{{wireName}}{{/dq}}); + {{/bodyFields}} + } \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Fields.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Fields.mustache new file mode 100644 index 0000000000..6822decb32 --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Fields.mustache @@ -0,0 +1,7 @@ +{{#fields}} + + {{^required}} + @Nullable + {{/required}} + private final {{{type}}} {{name}}; +{{/fields}} \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Getters.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Getters.mustache new file mode 100644 index 0000000000..cac3b57373 --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Getters.mustache @@ -0,0 +1,6 @@ +{{#fields}} + + public final {{{type}}} {{name}}() { + return this.{{name}}; + } +{{/fields}} \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache new file mode 100644 index 0000000000..0658f16b0a --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache @@ -0,0 +1,19 @@ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { +{{#bodyFields}} + {{^required}} + if ({{#type.isDefined}}this.{{name}}{{/type.isDefined}}) { + {{/required}} + generator.writeKey({{#dq}}{{wireName}}{{/dq}}); + {{#type.serializer}}this.{{name}}{{/type.serializer}} + {{^required}} + } + {{/required}} + +{{/bodyFields}} + } \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache index 5cf73fbcb0..291970f4f2 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache @@ -1,11 +1,15 @@ package org.opensearch.client.opensearch; import org.opensearch.client.opensearch._types.*; -{{#hasRequestBody}}import org.opensearch.client.json.*;{{/hasRequestBody}} +{{#hasRequestBody}} +import org.opensearch.client.json.*; +{{/hasRequestBody}} import org.opensearch.client.transport.*; import org.opensearch.client.transport.endpoints.*; import org.opensearch.client.util.*; -{{#hasRequestBody}}import jakarta.json.stream.JsonGenerator;{{/hasRequestBody}} +{{#hasRequestBody}} +import jakarta.json.stream.JsonGenerator; +{{/hasRequestBody}} import java.util.*; import java.util.function.Function; import java.util.stream.*; @@ -14,69 +18,22 @@ import javax.annotation.*; /** * {{description}} */ -{{#hasRequestBody}}@JsonpDeserializable{{/hasRequestBody}} +{{#hasRequestBody}} +@JsonpDeserializable +{{/hasRequestBody}} public class {{className}} extends RequestBase{{#hasRequestBody}} implements JsonpSerializable{{/hasRequestBody}} { - {{#fields}} - {{^required}}@Nullable{{/required}} - private final {{{type}}} {{name}}; - {{/fields}} + {{>ObjectShape/Fields}} + {{>ObjectShape/Constructor}} + {{>ObjectShape/Getters}} - public {{className}}(Builder builder) { - {{#fields}} - {{#type.isListOrMap}} - this.{{name}} = ApiTypeHelper.unmodifiable(builder.{{name}}); - {{/type.isListOrMap}} - {{^type.isListOrMap}} - {{#required}} - this.{{name}} = ApiTypeHelper.requireNonNull(builder.{{name}}, this, {{#dq}}{{name}}{{/dq}}); - {{/required}} - {{^required}} - this.{{name}} = builder.{{name}}; - {{/required}} - {{/type.isListOrMap}} - {{/fields}} - } - - public static {{className}} of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - {{#fields}} - public final {{{type}}} {{name}}() { - return this.{{name}}; - } - - {{/fields}} {{#hasRequestBody}} - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - {{#bodyFields}} - if ({{#type.isDefined}}this.{{name}}{{/type.isDefined}}) { - generator.writeKey({{#dq}}{{wireName}}{{/dq}}); - {{#type.serializer}}this.{{name}}{{/type.serializer}} - } - - {{/bodyFields}} - } + {{>ObjectShape/Serialize}} {{/hasRequestBody}} - {{>ObjectBuilder}} + {{>ObjectShape/Builder}} {{#hasRequestBody}} - public static final JsonpDeserializer<{{className}}> _DESERIALIZER = ObjectBuilderDeserializer - .lazy(Builder::new, {{className}}::setup{{className}}Deserializer); - - protected static void setup{{className}}Deserializer( - ObjectDeserializer<{{className}}.Builder> op) { - {{#bodyFields}} - op.add(Builder::{{name}}, {{{type.deserializer}}}, {{#dq}}{{wireName}}{{/dq}}); - {{/bodyFields}} - } + {{>ObjectShape/Deserialize}} {{/hasRequestBody}} public static final Endpoint<{{className}}, {{responseType}}, ErrorResponse> _ENDPOINT = new SimpleEndpoint<>( From c9d3df19feaf5f430152208f814963d267f786b2 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Wed, 15 Feb 2023 13:33:26 +1300 Subject: [PATCH 07/50] Simple http path expression Signed-off-by: Thomas Farr --- .../client/opensearch/DeleteIndexRequest.java | 15 ++- .../GetCatIndicesWithIndexRequest.java | 15 ++- .../opensearch/GetDocumentDocRequest.java | 100 ++++++++++------ .../opensearch/GetDocumentDocResponse.java | 110 +++++++++--------- .../opensearch/GetDocumentSourceRequest.java | 100 ++++++++++------ .../opensearch/GetSettingsIndexRequest.java | 15 ++- .../GetSettingsIndexSettingRequest.java | 28 ++++- .../opensearch/client/opensearch/Hits.java | 38 +++--- .../client/opensearch/PostSearchResponse.java | 46 ++++---- .../PostSearchWithIndexRequest.java | 15 ++- .../PostSearchWithIndexResponse.java | 46 ++++---- .../opensearch/PutCreateIndexRequest.java | 15 ++- .../PutIndexMappingWithIndexRequest.java | 15 ++- .../client/codegen/ApiSpecification.java | 5 + .../client/codegen/model/ObjectShape.java | 2 +- .../codegen/model/OperationRequest.java | 16 ++- .../templates/OperationRequest.mustache | 2 +- 17 files changed, 376 insertions(+), 207 deletions(-) diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java index b6b9008593..6d42fbd932 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java @@ -20,6 +20,8 @@ public class DeleteIndexRequest extends RequestBase { @Nullable private final Boolean ignoreUnavailable; + private final String index; + @Nullable private final String masterTimeout; @Nullable private final String timeout; @@ -29,6 +31,7 @@ public DeleteIndexRequest(Builder builder) { this.clusterManagerTimeout = builder.clusterManagerTimeout; this.expandWildcards = builder.expandWildcards; this.ignoreUnavailable = builder.ignoreUnavailable; + this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); this.masterTimeout = builder.masterTimeout; this.timeout = builder.timeout; } @@ -53,6 +56,10 @@ public final Boolean ignoreUnavailable() { return this.ignoreUnavailable; } + public final String index() { + return this.index; + } + public final String masterTimeout() { return this.masterTimeout; } @@ -68,6 +75,7 @@ public static class Builder extends ObjectBuilderBase private String clusterManagerTimeout; private ExpandWildcards expandWildcards; private Boolean ignoreUnavailable; + private String index; private String masterTimeout; private String timeout; @@ -91,6 +99,11 @@ public final Builder ignoreUnavailable(Boolean value) { return this; } + public final Builder index(String value) { + this.index = value; + return this; + } + public final Builder masterTimeout(String value) { this.masterTimeout = value; return this; @@ -121,7 +134,7 @@ public DeleteIndexRequest build() { }, // Request path request -> { - return "/{index}"; + return "/" + request.index + ""; }, // Request parameters request -> { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java index 96e2dfca6d..862e33105e 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java @@ -27,6 +27,8 @@ public class GetCatIndicesWithIndexRequest extends RequestBase { @Nullable private final Boolean includeUnloadedSegments; + private final String index; + @Nullable private final String masterTimeout; @Nullable private final Boolean pri; @@ -40,6 +42,7 @@ public GetCatIndicesWithIndexRequest(Builder builder) { this.format = builder.format; this.health = builder.health; this.includeUnloadedSegments = builder.includeUnloadedSegments; + this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); this.masterTimeout = builder.masterTimeout; this.pri = builder.pri; this.time = builder.time; @@ -74,6 +77,10 @@ public final Boolean includeUnloadedSegments() { return this.includeUnloadedSegments; } + public final String index() { + return this.index; + } + public final String masterTimeout() { return this.masterTimeout; } @@ -95,6 +102,7 @@ public static class Builder extends ObjectBuilderBase private String format; private HealthStatus health; private Boolean includeUnloadedSegments; + private String index; private String masterTimeout; private Boolean pri; private String time; @@ -129,6 +137,11 @@ public final Builder includeUnloadedSegments(Boolean value) { return this; } + public final Builder index(String value) { + this.index = value; + return this; + } + public final Builder masterTimeout(String value) { this.masterTimeout = value; return this; @@ -166,7 +179,7 @@ public GetCatIndicesWithIndexRequest build() { }, // Request path request -> { - return "/_cat/indices/{index}"; + return "/_cat/indices/" + request.index + ""; }, // Request parameters request -> { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java index ac43d3d217..4b7e30786e 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java @@ -12,11 +12,9 @@ /** Returns a document */ public class GetDocumentDocRequest extends RequestBase { - @Nullable private final String source; - - @Nullable private final String sourceExcludes; + private final String id; - @Nullable private final String sourceIncludes; + private final String index; @Nullable private final String preference; @@ -26,6 +24,12 @@ public class GetDocumentDocRequest extends RequestBase { @Nullable private final String routing; + @Nullable private final String source; + + @Nullable private final String sourceExcludes; + + @Nullable private final String sourceIncludes; + @Nullable private final Boolean storedFields; @Nullable private final Integer version; @@ -33,13 +37,15 @@ public class GetDocumentDocRequest extends RequestBase { @Nullable private final VersionType versionType; public GetDocumentDocRequest(Builder builder) { - this.source = builder.source; - this.sourceExcludes = builder.sourceExcludes; - this.sourceIncludes = builder.sourceIncludes; + this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); + this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); this.preference = builder.preference; this.realtime = builder.realtime; this.refresh = builder.refresh; this.routing = builder.routing; + this.source = builder.source; + this.sourceExcludes = builder.sourceExcludes; + this.sourceIncludes = builder.sourceIncludes; this.storedFields = builder.storedFields; this.version = builder.version; this.versionType = builder.versionType; @@ -50,16 +56,12 @@ public static GetDocumentDocRequest of( return fn.apply(new Builder()).build(); } - public final String source() { - return this.source; - } - - public final String sourceExcludes() { - return this.sourceExcludes; + public final String id() { + return this.id; } - public final String sourceIncludes() { - return this.sourceIncludes; + public final String index() { + return this.index; } public final String preference() { @@ -78,6 +80,18 @@ public final String routing() { return this.routing; } + public final String source() { + return this.source; + } + + public final String sourceExcludes() { + return this.sourceExcludes; + } + + public final String sourceIncludes() { + return this.sourceIncludes; + } + public final Boolean storedFields() { return this.storedFields; } @@ -93,29 +107,26 @@ public final VersionType versionType() { /** Builder for {@link GetDocumentDocRequest}. */ public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private String source; - private String sourceExcludes; - private String sourceIncludes; + private String id; + private String index; private String preference; private Boolean realtime; private Boolean refresh; private String routing; + private String source; + private String sourceExcludes; + private String sourceIncludes; private Boolean storedFields; private Integer version; private VersionType versionType; - public final Builder source(String value) { - this.source = value; + public final Builder id(String value) { + this.id = value; return this; } - public final Builder sourceExcludes(String value) { - this.sourceExcludes = value; - return this; - } - - public final Builder sourceIncludes(String value) { - this.sourceIncludes = value; + public final Builder index(String value) { + this.index = value; return this; } @@ -139,6 +150,21 @@ public final Builder routing(String value) { return this; } + public final Builder source(String value) { + this.source = value; + return this; + } + + public final Builder sourceExcludes(String value) { + this.sourceExcludes = value; + return this; + } + + public final Builder sourceIncludes(String value) { + this.sourceIncludes = value; + return this; + } + public final Builder storedFields(Boolean value) { this.storedFields = value; return this; @@ -175,20 +201,11 @@ public GetDocumentDocRequest build() { }, // Request path request -> { - return "/{index}/_doc/{id}"; + return "/" + request.index + "/_doc/" + request.id + ""; }, // Request parameters request -> { Map params = new HashMap<>(); - if (request.source != null) { - params.put("_source", request.source); - } - if (request.sourceExcludes != null) { - params.put("_source_excludes", request.sourceExcludes); - } - if (request.sourceIncludes != null) { - params.put("_source_includes", request.sourceIncludes); - } if (request.preference != null) { params.put("preference", request.preference); } @@ -201,6 +218,15 @@ public GetDocumentDocRequest build() { if (request.routing != null) { params.put("routing", request.routing); } + if (request.source != null) { + params.put("_source", request.source); + } + if (request.sourceExcludes != null) { + params.put("_source_excludes", request.sourceExcludes); + } + if (request.sourceIncludes != null) { + params.put("_source_includes", request.sourceIncludes); + } if (request.storedFields != null) { params.put( "stored_fields", String.valueOf(request.storedFields)); diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocResponse.java index 6b68a24900..ac03241abe 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocResponse.java @@ -12,34 +12,34 @@ public class GetDocumentDocResponse implements JsonpSerializable { @Nullable private final Map fields; + private final boolean found; + private final String id; private final String index; + @Nullable private final Long primaryTerm; + @Nullable private final String routing; + @Nullable private final Long seqNo; + @Nullable private final Map source; @Nullable private final String type; - private final boolean found; - - @Nullable private final Long primaryTerm; - - @Nullable private final Long seqNo; - @Nullable private final Integer version; public GetDocumentDocResponse(Builder builder) { this.fields = ApiTypeHelper.unmodifiable(builder.fields); + this.found = ApiTypeHelper.requireNonNull(builder.found, this, "found"); this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); + this.primaryTerm = builder.primaryTerm; this.routing = builder.routing; + this.seqNo = builder.seqNo; this.source = ApiTypeHelper.unmodifiable(builder.source); this.type = builder.type; - this.found = ApiTypeHelper.requireNonNull(builder.found, this, "found"); - this.primaryTerm = builder.primaryTerm; - this.seqNo = builder.seqNo; this.version = builder.version; } @@ -52,6 +52,10 @@ public final Map fields() { return this.fields; } + public final boolean found() { + return this.found; + } + public final String id() { return this.id; } @@ -60,10 +64,18 @@ public final String index() { return this.index; } + public final Long primaryTerm() { + return this.primaryTerm; + } + public final String routing() { return this.routing; } + public final Long seqNo() { + return this.seqNo; + } + public final Map source() { return this.source; } @@ -72,18 +84,6 @@ public final String type() { return this.type; } - public final boolean found() { - return this.found; - } - - public final Long primaryTerm() { - return this.primaryTerm; - } - - public final Long seqNo() { - return this.seqNo; - } - public final Integer version() { return this.version; } @@ -105,17 +105,30 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeEnd(); } + generator.writeKey("found"); + generator.write(this.found); + generator.writeKey("_id"); generator.write(this.id); generator.writeKey("_index"); generator.write(this.index); + if (this.primaryTerm != null) { + generator.writeKey("primary_term"); + generator.write(this.primaryTerm); + } + if (this.routing != null) { generator.writeKey("_routing"); generator.write(this.routing); } + if (this.seqNo != null) { + generator.writeKey("seq_no"); + generator.write(this.seqNo); + } + if (ApiTypeHelper.isDefined(this.source)) { generator.writeKey("_source"); generator.writeStartObject(); @@ -131,19 +144,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write(this.type); } - generator.writeKey("found"); - generator.write(this.found); - - if (this.primaryTerm != null) { - generator.writeKey("primary_term"); - generator.write(this.primaryTerm); - } - - if (this.seqNo != null) { - generator.writeKey("seq_no"); - generator.write(this.seqNo); - } - if (this.version != null) { generator.writeKey("version"); generator.write(this.version); @@ -154,14 +154,14 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private Map fields; + private Boolean found; private String id; private String index; + private Long primaryTerm; private String routing; + private Long seqNo; private Map source; private String type; - private Boolean found; - private Long primaryTerm; - private Long seqNo; private Integer version; public final Builder fields(Map map) { @@ -174,6 +174,11 @@ public final Builder fields(String key, JsonData value) { return this; } + public final Builder found(boolean value) { + this.found = value; + return this; + } + public final Builder id(String value) { this.id = value; return this; @@ -184,11 +189,21 @@ public final Builder index(String value) { return this; } + public final Builder primaryTerm(Long value) { + this.primaryTerm = value; + return this; + } + public final Builder routing(String value) { this.routing = value; return this; } + public final Builder seqNo(Long value) { + this.seqNo = value; + return this; + } + public final Builder source(Map map) { this.source = _mapPutAll(this.source, map); return this; @@ -204,21 +219,6 @@ public final Builder type(String value) { return this; } - public final Builder found(boolean value) { - this.found = value; - return this; - } - - public final Builder primaryTerm(Long value) { - this.primaryTerm = value; - return this; - } - - public final Builder seqNo(Long value) { - this.seqNo = value; - return this; - } - public final Builder version(Integer value) { this.version = value; return this; @@ -246,17 +246,17 @@ protected static void setupGetDocumentDocResponseDeserializer( Builder::fields, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "_fields"); + op.add(Builder::found, JsonpDeserializer.booleanDeserializer(), "found"); op.add(Builder::id, JsonpDeserializer.stringDeserializer(), "_id"); op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "_index"); + op.add(Builder::primaryTerm, JsonpDeserializer.longDeserializer(), "primary_term"); op.add(Builder::routing, JsonpDeserializer.stringDeserializer(), "_routing"); + op.add(Builder::seqNo, JsonpDeserializer.longDeserializer(), "seq_no"); op.add( Builder::source, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "_source"); op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "_type"); - op.add(Builder::found, JsonpDeserializer.booleanDeserializer(), "found"); - op.add(Builder::primaryTerm, JsonpDeserializer.longDeserializer(), "primary_term"); - op.add(Builder::seqNo, JsonpDeserializer.longDeserializer(), "seq_no"); op.add(Builder::version, JsonpDeserializer.integerDeserializer(), "version"); } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java index c15867ba7d..27763382f0 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java @@ -12,11 +12,9 @@ /** Returns a document. */ public class GetDocumentSourceRequest extends RequestBase { - @Nullable private final String source; - - @Nullable private final String sourceExcludes; + private final String id; - @Nullable private final String sourceIncludes; + private final String index; @Nullable private final String preference; @@ -26,6 +24,12 @@ public class GetDocumentSourceRequest extends RequestBase { @Nullable private final String routing; + @Nullable private final String source; + + @Nullable private final String sourceExcludes; + + @Nullable private final String sourceIncludes; + @Nullable private final Boolean storedFields; @Nullable private final Integer version; @@ -33,13 +37,15 @@ public class GetDocumentSourceRequest extends RequestBase { @Nullable private final VersionType versionType; public GetDocumentSourceRequest(Builder builder) { - this.source = builder.source; - this.sourceExcludes = builder.sourceExcludes; - this.sourceIncludes = builder.sourceIncludes; + this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); + this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); this.preference = builder.preference; this.realtime = builder.realtime; this.refresh = builder.refresh; this.routing = builder.routing; + this.source = builder.source; + this.sourceExcludes = builder.sourceExcludes; + this.sourceIncludes = builder.sourceIncludes; this.storedFields = builder.storedFields; this.version = builder.version; this.versionType = builder.versionType; @@ -50,16 +56,12 @@ public static GetDocumentSourceRequest of( return fn.apply(new Builder()).build(); } - public final String source() { - return this.source; - } - - public final String sourceExcludes() { - return this.sourceExcludes; + public final String id() { + return this.id; } - public final String sourceIncludes() { - return this.sourceIncludes; + public final String index() { + return this.index; } public final String preference() { @@ -78,6 +80,18 @@ public final String routing() { return this.routing; } + public final String source() { + return this.source; + } + + public final String sourceExcludes() { + return this.sourceExcludes; + } + + public final String sourceIncludes() { + return this.sourceIncludes; + } + public final Boolean storedFields() { return this.storedFields; } @@ -93,29 +107,26 @@ public final VersionType versionType() { /** Builder for {@link GetDocumentSourceRequest}. */ public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private String source; - private String sourceExcludes; - private String sourceIncludes; + private String id; + private String index; private String preference; private Boolean realtime; private Boolean refresh; private String routing; + private String source; + private String sourceExcludes; + private String sourceIncludes; private Boolean storedFields; private Integer version; private VersionType versionType; - public final Builder source(String value) { - this.source = value; + public final Builder id(String value) { + this.id = value; return this; } - public final Builder sourceExcludes(String value) { - this.sourceExcludes = value; - return this; - } - - public final Builder sourceIncludes(String value) { - this.sourceIncludes = value; + public final Builder index(String value) { + this.index = value; return this; } @@ -139,6 +150,21 @@ public final Builder routing(String value) { return this; } + public final Builder source(String value) { + this.source = value; + return this; + } + + public final Builder sourceExcludes(String value) { + this.sourceExcludes = value; + return this; + } + + public final Builder sourceIncludes(String value) { + this.sourceIncludes = value; + return this; + } + public final Builder storedFields(Boolean value) { this.storedFields = value; return this; @@ -175,20 +201,11 @@ public GetDocumentSourceRequest build() { }, // Request path request -> { - return "/{index}/_source/{id}"; + return "/" + request.index + "/_source/" + request.id + ""; }, // Request parameters request -> { Map params = new HashMap<>(); - if (request.source != null) { - params.put("_source", request.source); - } - if (request.sourceExcludes != null) { - params.put("_source_excludes", request.sourceExcludes); - } - if (request.sourceIncludes != null) { - params.put("_source_includes", request.sourceIncludes); - } if (request.preference != null) { params.put("preference", request.preference); } @@ -201,6 +218,15 @@ public GetDocumentSourceRequest build() { if (request.routing != null) { params.put("routing", request.routing); } + if (request.source != null) { + params.put("_source", request.source); + } + if (request.sourceExcludes != null) { + params.put("_source_excludes", request.sourceExcludes); + } + if (request.sourceIncludes != null) { + params.put("_source_includes", request.sourceIncludes); + } if (request.storedFields != null) { params.put( "stored_fields", String.valueOf(request.storedFields)); diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java index d9d4f899fa..d31a44b253 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java @@ -24,6 +24,8 @@ public class GetSettingsIndexRequest extends RequestBase { @Nullable private final String includeDefaults; + private final String index; + @Nullable private final Boolean local; @Nullable private final String masterTimeout; @@ -35,6 +37,7 @@ public GetSettingsIndexRequest(Builder builder) { this.flatSettings = builder.flatSettings; this.ignoreUnavailable = builder.ignoreUnavailable; this.includeDefaults = builder.includeDefaults; + this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); this.local = builder.local; this.masterTimeout = builder.masterTimeout; } @@ -68,6 +71,10 @@ public final String includeDefaults() { return this.includeDefaults; } + public final String index() { + return this.index; + } + public final Boolean local() { return this.local; } @@ -85,6 +92,7 @@ public static class Builder extends ObjectBuilderBase private Boolean flatSettings; private Boolean ignoreUnavailable; private String includeDefaults; + private String index; private Boolean local; private String masterTimeout; @@ -118,6 +126,11 @@ public final Builder includeDefaults(String value) { return this; } + public final Builder index(String value) { + this.index = value; + return this; + } + public final Builder local(Boolean value) { this.local = value; return this; @@ -149,7 +162,7 @@ public GetSettingsIndexRequest build() { }, // Request path request -> { - return "/{index}/_settings"; + return "/" + request.index + "/_settings"; }, // Request parameters request -> { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java index e8c8b55b3c..2e47d66451 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java @@ -24,10 +24,14 @@ public class GetSettingsIndexSettingRequest extends RequestBase { @Nullable private final String includeDefaults; + private final String index; + @Nullable private final Boolean local; @Nullable private final String masterTimeout; + private final String setting; + public GetSettingsIndexSettingRequest(Builder builder) { this.allowNoIndices = builder.allowNoIndices; this.clusterManagerTimeout = builder.clusterManagerTimeout; @@ -35,8 +39,10 @@ public GetSettingsIndexSettingRequest(Builder builder) { this.flatSettings = builder.flatSettings; this.ignoreUnavailable = builder.ignoreUnavailable; this.includeDefaults = builder.includeDefaults; + this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); this.local = builder.local; this.masterTimeout = builder.masterTimeout; + this.setting = ApiTypeHelper.requireNonNull(builder.setting, this, "setting"); } public static GetSettingsIndexSettingRequest of( @@ -68,6 +74,10 @@ public final String includeDefaults() { return this.includeDefaults; } + public final String index() { + return this.index; + } + public final Boolean local() { return this.local; } @@ -76,6 +86,10 @@ public final String masterTimeout() { return this.masterTimeout; } + public final String setting() { + return this.setting; + } + /** Builder for {@link GetSettingsIndexSettingRequest}. */ public static class Builder extends ObjectBuilderBase implements ObjectBuilder { @@ -85,8 +99,10 @@ public static class Builder extends ObjectBuilderBase private Boolean flatSettings; private Boolean ignoreUnavailable; private String includeDefaults; + private String index; private Boolean local; private String masterTimeout; + private String setting; public final Builder allowNoIndices(Boolean value) { this.allowNoIndices = value; @@ -118,6 +134,11 @@ public final Builder includeDefaults(String value) { return this; } + public final Builder index(String value) { + this.index = value; + return this; + } + public final Builder local(Boolean value) { this.local = value; return this; @@ -128,6 +149,11 @@ public final Builder masterTimeout(String value) { return this; } + public final Builder setting(String value) { + this.setting = value; + return this; + } + /** * Builds a {@link GetSettingsIndexSettingRequest}. * @@ -150,7 +176,7 @@ public GetSettingsIndexSettingRequest build() { }, // Request path request -> { - return "/{index}/_settings/{setting}"; + return "/" + request.index + "/_settings/" + request.setting + ""; }, // Request parameters request -> { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/Hits.java b/java-client/src/generated/java/org/opensearch/client/opensearch/Hits.java index aed09276bb..5c5ea165f6 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/Hits.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/Hits.java @@ -10,6 +10,8 @@ @JsonpDeserializable public class Hits implements JsonpSerializable { + @Nullable private final JsonData fields; + @Nullable private final String id; @Nullable private final String index; @@ -20,21 +22,23 @@ public class Hits implements JsonpSerializable { @Nullable private final String type; - @Nullable private final JsonData fields; - public Hits(Builder builder) { + this.fields = builder.fields; this.id = builder.id; this.index = builder.index; this.score = builder.score; this.source = builder.source; this.type = builder.type; - this.fields = builder.fields; } public static Hits of(Function> fn) { return fn.apply(new Builder()).build(); } + public final JsonData fields() { + return this.fields; + } + public final String id() { return this.id; } @@ -55,10 +59,6 @@ public final String type() { return this.type; } - public final JsonData fields() { - return this.fields; - } - public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -66,6 +66,11 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.fields != null) { + generator.writeKey("fields"); + this.fields.serialize(generator, mapper); + } + if (this.id != null) { generator.writeKey("_id"); generator.write(this.id); @@ -90,21 +95,21 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("_type"); generator.write(this.type); } - - if (this.fields != null) { - generator.writeKey("fields"); - this.fields.serialize(generator, mapper); - } } /** Builder for {@link Hits}. */ public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private JsonData fields; private String id; private String index; private Float score; private JsonData source; private String type; - private JsonData fields; + + public final Builder fields(JsonData value) { + this.fields = value; + return this; + } public final Builder id(String value) { this.id = value; @@ -131,11 +136,6 @@ public final Builder type(String value) { return this; } - public final Builder fields(JsonData value) { - this.fields = value; - return this; - } - /** * Builds a {@link Hits}. * @@ -152,11 +152,11 @@ public Hits build() { ObjectBuilderDeserializer.lazy(Builder::new, Hits::setupHitsDeserializer); protected static void setupHitsDeserializer(ObjectDeserializer op) { + op.add(Builder::fields, JsonData._DESERIALIZER, "fields"); op.add(Builder::id, JsonpDeserializer.stringDeserializer(), "_id"); op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "_index"); op.add(Builder::score, JsonpDeserializer.floatDeserializer(), "_score"); op.add(Builder::source, JsonData._DESERIALIZER, "_source"); op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "_type"); - op.add(Builder::fields, JsonData._DESERIALIZER, "fields"); } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchResponse.java index b1fea660df..6f73a0b038 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchResponse.java @@ -10,20 +10,20 @@ @JsonpDeserializable public class PostSearchResponse implements JsonpSerializable { + @Nullable private final HitsMetadata hits; + @Nullable private final String scrollId; @Nullable private final ShardStatistics shards; - @Nullable private final HitsMetadata hits; - @Nullable private final Boolean timedOut; @Nullable private final Long took; public PostSearchResponse(Builder builder) { + this.hits = builder.hits; this.scrollId = builder.scrollId; this.shards = builder.shards; - this.hits = builder.hits; this.timedOut = builder.timedOut; this.took = builder.took; } @@ -32,6 +32,10 @@ public static PostSearchResponse of(Function { + private HitsMetadata hits; private String scrollId; private ShardStatistics shards; - private HitsMetadata hits; private Boolean timedOut; private Long took; + public final Builder hits(HitsMetadata value) { + this.hits = value; + return this; + } + + public final Builder hits(Function> fn) { + return hits(fn.apply(new HitsMetadata.Builder()).build()); + } + public final Builder scrollId(String value) { this.scrollId = value; return this; @@ -109,15 +118,6 @@ public final Builder shards( return shards(fn.apply(new ShardStatistics.Builder()).build()); } - public final Builder hits(HitsMetadata value) { - this.hits = value; - return this; - } - - public final Builder hits(Function> fn) { - return hits(fn.apply(new HitsMetadata.Builder()).build()); - } - public final Builder timedOut(Boolean value) { this.timedOut = value; return this; @@ -146,9 +146,9 @@ public PostSearchResponse build() { protected static void setupPostSearchResponseDeserializer( ObjectDeserializer op) { + op.add(Builder::hits, HitsMetadata._DESERIALIZER, "hits"); op.add(Builder::scrollId, JsonpDeserializer.stringDeserializer(), "_scroll_id"); op.add(Builder::shards, ShardStatistics._DESERIALIZER, "_shards"); - op.add(Builder::hits, HitsMetadata._DESERIALIZER, "hits"); op.add(Builder::timedOut, JsonpDeserializer.booleanDeserializer(), "timed_out"); op.add(Builder::took, JsonpDeserializer.longDeserializer(), "took"); } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java index 66dcf7816e..8a8a438727 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java @@ -45,6 +45,8 @@ public class PostSearchWithIndexRequest extends RequestBase implements JsonpSeri @Nullable private final Boolean ignoreUnavailable; + private final String index; + @Nullable private final List indicesBoost; @Nullable private final Boolean lenient; @@ -123,6 +125,7 @@ public PostSearchWithIndexRequest(Builder builder) { this.from = builder.from; this.ignoreThrottled = builder.ignoreThrottled; this.ignoreUnavailable = builder.ignoreUnavailable; + this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); this.indicesBoost = ApiTypeHelper.unmodifiable(builder.indicesBoost); this.lenient = builder.lenient; this.maxConcurrentShardRequests = builder.maxConcurrentShardRequests; @@ -221,6 +224,10 @@ public final Boolean ignoreUnavailable() { return this.ignoreUnavailable; } + public final String index() { + return this.index; + } + public final List indicesBoost() { return this.indicesBoost; } @@ -449,6 +456,7 @@ public static class Builder extends ObjectBuilderBase private Integer from; private Boolean ignoreThrottled; private Boolean ignoreUnavailable; + private String index; private List indicesBoost; private Boolean lenient; private Long maxConcurrentShardRequests; @@ -561,6 +569,11 @@ public final Builder ignoreUnavailable(Boolean value) { return this; } + public final Builder index(String value) { + this.index = value; + return this; + } + public final Builder indicesBoost(List list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; @@ -798,7 +811,7 @@ protected static void setupPostSearchWithIndexRequestDeserializer( }, // Request path request -> { - return "/{index}/_search"; + return "/" + request.index + "/_search"; }, // Request parameters request -> { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexResponse.java index aa9d9b44fe..812600c33e 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexResponse.java @@ -10,20 +10,20 @@ @JsonpDeserializable public class PostSearchWithIndexResponse implements JsonpSerializable { + @Nullable private final HitsMetadata hits; + @Nullable private final String scrollId; @Nullable private final ShardStatistics shards; - @Nullable private final HitsMetadata hits; - @Nullable private final Boolean timedOut; @Nullable private final Long took; public PostSearchWithIndexResponse(Builder builder) { + this.hits = builder.hits; this.scrollId = builder.scrollId; this.shards = builder.shards; - this.hits = builder.hits; this.timedOut = builder.timedOut; this.took = builder.took; } @@ -33,6 +33,10 @@ public static PostSearchWithIndexResponse of( return fn.apply(new Builder()).build(); } + public final HitsMetadata hits() { + return this.hits; + } + public final String scrollId() { return this.scrollId; } @@ -41,10 +45,6 @@ public final ShardStatistics shards() { return this.shards; } - public final HitsMetadata hits() { - return this.hits; - } - public final Boolean timedOut() { return this.timedOut; } @@ -60,6 +60,11 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.hits != null) { + generator.writeKey("hits"); + this.hits.serialize(generator, mapper); + } + if (this.scrollId != null) { generator.writeKey("_scroll_id"); generator.write(this.scrollId); @@ -70,11 +75,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { this.shards.serialize(generator, mapper); } - if (this.hits != null) { - generator.writeKey("hits"); - this.hits.serialize(generator, mapper); - } - if (this.timedOut != null) { generator.writeKey("timed_out"); generator.write(this.timedOut); @@ -89,12 +89,21 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** Builder for {@link PostSearchWithIndexResponse}. */ public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private HitsMetadata hits; private String scrollId; private ShardStatistics shards; - private HitsMetadata hits; private Boolean timedOut; private Long took; + public final Builder hits(HitsMetadata value) { + this.hits = value; + return this; + } + + public final Builder hits(Function> fn) { + return hits(fn.apply(new HitsMetadata.Builder()).build()); + } + public final Builder scrollId(String value) { this.scrollId = value; return this; @@ -110,15 +119,6 @@ public final Builder shards( return shards(fn.apply(new ShardStatistics.Builder()).build()); } - public final Builder hits(HitsMetadata value) { - this.hits = value; - return this; - } - - public final Builder hits(Function> fn) { - return hits(fn.apply(new HitsMetadata.Builder()).build()); - } - public final Builder timedOut(Boolean value) { this.timedOut = value; return this; @@ -148,9 +148,9 @@ public PostSearchWithIndexResponse build() { protected static void setupPostSearchWithIndexResponseDeserializer( ObjectDeserializer op) { + op.add(Builder::hits, HitsMetadata._DESERIALIZER, "hits"); op.add(Builder::scrollId, JsonpDeserializer.stringDeserializer(), "_scroll_id"); op.add(Builder::shards, ShardStatistics._DESERIALIZER, "_shards"); - op.add(Builder::hits, HitsMetadata._DESERIALIZER, "hits"); op.add(Builder::timedOut, JsonpDeserializer.booleanDeserializer(), "timed_out"); op.add(Builder::took, JsonpDeserializer.longDeserializer(), "took"); } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java index d809d02410..fdc88ded9d 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java @@ -21,6 +21,8 @@ public class PutCreateIndexRequest extends RequestBase implements JsonpSerializa @Nullable private final Boolean includeTypeName; + private final String index; + @Nullable private final Map mapping; @Nullable private final String masterTimeout; @@ -35,6 +37,7 @@ public PutCreateIndexRequest(Builder builder) { this.aliases = ApiTypeHelper.unmodifiable(builder.aliases); this.clusterManagerTimeout = builder.clusterManagerTimeout; this.includeTypeName = builder.includeTypeName; + this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); this.mapping = ApiTypeHelper.unmodifiable(builder.mapping); this.masterTimeout = builder.masterTimeout; this.settings = ApiTypeHelper.unmodifiable(builder.settings); @@ -59,6 +62,10 @@ public final Boolean includeTypeName() { return this.includeTypeName; } + public final String index() { + return this.index; + } + public final Map mapping() { return this.mapping; } @@ -123,6 +130,7 @@ public static class Builder extends ObjectBuilderBase private Map aliases; private String clusterManagerTimeout; private Boolean includeTypeName; + private String index; private Map mapping; private String masterTimeout; private Map settings; @@ -149,6 +157,11 @@ public final Builder includeTypeName(Boolean value) { return this; } + public final Builder index(String value) { + this.index = value; + return this; + } + public final Builder mapping(Map map) { this.mapping = _mapPutAll(this.mapping, map); return this; @@ -225,7 +238,7 @@ protected static void setupPutCreateIndexRequestDeserializer( }, // Request path request -> { - return "/{index}"; + return "/" + request.index + ""; }, // Request parameters request -> { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java index ec1fc9a170..21b54a78ab 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java @@ -25,6 +25,8 @@ public class PutIndexMappingWithIndexRequest extends RequestBase implements Json @Nullable private final Boolean includeTypeName; + private final String index; + @Nullable private final String masterTimeout; @Nullable private final JsonData properties; @@ -39,6 +41,7 @@ public PutIndexMappingWithIndexRequest(Builder builder) { this.expandWildcards = builder.expandWildcards; this.ignoreUnavailable = builder.ignoreUnavailable; this.includeTypeName = builder.includeTypeName; + this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); this.masterTimeout = builder.masterTimeout; this.properties = builder.properties; this.timeout = builder.timeout; @@ -70,6 +73,10 @@ public final Boolean includeTypeName() { return this.includeTypeName; } + public final String index() { + return this.index; + } + public final String masterTimeout() { return this.masterTimeout; } @@ -107,6 +114,7 @@ public static class Builder extends ObjectBuilderBase private ExpandWildcards expandWildcards; private Boolean ignoreUnavailable; private Boolean includeTypeName; + private String index; private String masterTimeout; private JsonData properties; private String timeout; @@ -137,6 +145,11 @@ public final Builder includeTypeName(Boolean value) { return this; } + public final Builder index(String value) { + this.index = value; + return this; + } + public final Builder masterTimeout(String value) { this.masterTimeout = value; return this; @@ -192,7 +205,7 @@ protected static void setupPutIndexMappingWithIndexRequestDeserializer( }, // Request path request -> { - return "/{index}/_mapping"; + return "/" + request.index + "/_mapping"; }, // Request parameters request -> { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java b/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java index 34c6d700e7..088a492a9a 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java @@ -92,6 +92,11 @@ private void visit(String httpPath, Path path, String httpMethod, Operation oper .map(p -> new Field(p.getName(), typeMapper.mapType(p.getSchema()), p.isRequired())) .forEach(operationRequest::addQueryParam); + Stream.of(path.getParametersIn(context, "path"), operation.getParametersIn(context, "path")) + .flatMap(List::stream) + .map(p -> new Field(p.getName(), typeMapper.mapType(p.getSchema()), p.isRequired())) + .forEach(operationRequest::addPathParam); + operationRequests.add(operationRequest); MediaType responseMediaType = operation.getResponse("200").getContentMediaType("application/json"); diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java index d398ade0dc..6b937275e8 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java @@ -13,7 +13,7 @@ public ObjectShape(String className) { } public void addBodyField(Field field) { - bodyFields.put(field.wireName, field); + bodyFields.put(field.name(), field); } public String className() { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/OperationRequest.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/OperationRequest.java index 5c3ac58bf2..251678a778 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/OperationRequest.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/OperationRequest.java @@ -8,6 +8,7 @@ public class OperationRequest extends ObjectShape { private final String httpMethod; private final String httpPath; private final Map queryParams = new TreeMap<>(); + private final Map pathParams = new TreeMap<>(); private final Map fields = new TreeMap<>(); public OperationRequest(String id, String description, String httpMethod, String httpPath) { @@ -22,7 +23,7 @@ public OperationRequest(String id, String description, String httpMethod, String public String httpMethod() { return httpMethod; } - public String httpPath() { return httpPath; } + public String httpPath() { return '"' + httpPath.replace("{", "\" + request.").replace("}", " + \"") + '"'; } public String responseType() { return id + "Response"; } @@ -30,17 +31,24 @@ public OperationRequest(String id, String description, String httpMethod, String public Collection queryParams() { return queryParams.values(); } + public Collection pathParams() { return pathParams.values(); } + @Override public Collection fields() { return fields.values(); } @Override public void addBodyField(Field field) { super.addBodyField(field); - fields.put(field.wireName, field); + fields.put(field.name(), field); } public void addQueryParam(Field field) { - queryParams.put(field.wireName, field); - fields.put(field.wireName, field); + queryParams.put(field.name(), field); + fields.put(field.name(), field); + } + + public void addPathParam(Field field) { + pathParams.put(field.name(), field); + fields.put(field.name(), field); } } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache index 291970f4f2..df4e16873c 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache @@ -43,7 +43,7 @@ public class {{className}} extends RequestBase{{#hasRequestBody}} implements Jso }, // Request path request -> { - return {{#dq}}{{httpPath}}{{/dq}}; + return {{{httpPath}}}; }, // Request parameters request -> { From de863c1b326a8a61f397ec70012298a35321b178 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Thu, 16 Feb 2023 13:21:57 +1300 Subject: [PATCH 08/50] Generate client class Signed-off-by: Thomas Farr --- .../opensearch/OpenSearchAsyncClient.java | 340 ++++++++++++++++++ .../client/opensearch/OpenSearchClient.java | 339 +++++++++++++++++ .../client/codegen/ApiSpecification.java | 20 +- .../opensearch/client/codegen/Generator.java | 21 +- .../client/codegen/NameSanitizer.java | 4 +- .../client/codegen/model/Client.java | 41 +++ .../client/codegen/model/ClientOperation.java | 23 ++ .../client/codegen/model/EnumShape.java | 4 +- ...perationRequest.java => RequestShape.java} | 44 ++- .../client/codegen/utils/Strings.java | 29 ++ .../client/codegen/templates/Client.mustache | 43 +++ ...Request.mustache => RequestShape.mustache} | 0 12 files changed, 879 insertions(+), 29 deletions(-) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClient.java create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/model/Client.java create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/model/ClientOperation.java rename java-codegen/src/main/java/org/opensearch/client/codegen/model/{OperationRequest.java => RequestShape.java} (51%) create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/utils/Strings.java create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Client.mustache rename java-codegen/src/main/resources/org/opensearch/client/codegen/templates/{OperationRequest.mustache => RequestShape.mustache} (100%) diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java b/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java new file mode 100644 index 0000000000..25b20708ea --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java @@ -0,0 +1,340 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.ApiClient; +import org.opensearch.client.opensearch._types.OpenSearchException; +import org.opensearch.client.opensearch._types.ErrorResponse; +import org.opensearch.client.transport.OpenSearchTransport; +import org.opensearch.client.transport.JsonEndpoint; +import org.opensearch.client.transport.TransportOptions; +import org.opensearch.client.util.ObjectBuilder; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import java.util.function.Function; +import javax.annotation.Nullable; + +public class OpenSearchAsyncClient extends ApiClient { + public OpenSearchAsyncClient(OpenSearchTransport transport) { + super(transport, null); + } + + public OpenSearchAsyncClient( + OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { + super(transport, transportOptions); + } + + @Override + public OpenSearchAsyncClient withTransportOptions(@Nullable TransportOptions transportOptions) { + return new OpenSearchAsyncClient(this.transport, transportOptions); + } + + public CompletableFuture deleteIndex(DeleteIndexRequest request) + throws IOException, OpenSearchException { + JsonEndpoint endpoint = + (JsonEndpoint) + DeleteIndexRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + public final CompletableFuture deleteIndex( + Function> fn) + throws IOException, OpenSearchException { + return deleteIndex(fn.apply(new DeleteIndexRequest.Builder()).build()); + } + + public CompletableFuture getCatIndices(GetCatIndicesRequest request) + throws IOException, OpenSearchException { + JsonEndpoint endpoint = + (JsonEndpoint) + GetCatIndicesRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + public final CompletableFuture getCatIndices( + Function> fn) + throws IOException, OpenSearchException { + return getCatIndices(fn.apply(new GetCatIndicesRequest.Builder()).build()); + } + + public CompletableFuture getCatIndicesWithIndex( + GetCatIndicesWithIndexRequest request) throws IOException, OpenSearchException { + JsonEndpoint + endpoint = + (JsonEndpoint< + GetCatIndicesWithIndexRequest, + GetCatIndicesWithIndexResponse, + ErrorResponse>) + GetCatIndicesWithIndexRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + public final CompletableFuture getCatIndicesWithIndex( + Function< + GetCatIndicesWithIndexRequest.Builder, + ObjectBuilder> + fn) + throws IOException, OpenSearchException { + return getCatIndicesWithIndex( + fn.apply(new GetCatIndicesWithIndexRequest.Builder()).build()); + } + + public CompletableFuture getCatNodes(GetCatNodesRequest request) + throws IOException, OpenSearchException { + JsonEndpoint endpoint = + (JsonEndpoint) + GetCatNodesRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + public final CompletableFuture getCatNodes( + Function> fn) + throws IOException, OpenSearchException { + return getCatNodes(fn.apply(new GetCatNodesRequest.Builder()).build()); + } + + public CompletableFuture getClusterInfo(GetClusterInfoRequest request) + throws IOException, OpenSearchException { + JsonEndpoint endpoint = + (JsonEndpoint) + GetClusterInfoRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + public final CompletableFuture getClusterInfo( + Function> fn) + throws IOException, OpenSearchException { + return getClusterInfo(fn.apply(new GetClusterInfoRequest.Builder()).build()); + } + + public CompletableFuture getClusterSettings( + GetClusterSettingsRequest request) throws IOException, OpenSearchException { + JsonEndpoint + endpoint = + (JsonEndpoint< + GetClusterSettingsRequest, + GetClusterSettingsResponse, + ErrorResponse>) + GetClusterSettingsRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + public final CompletableFuture getClusterSettings( + Function> + fn) + throws IOException, OpenSearchException { + return getClusterSettings(fn.apply(new GetClusterSettingsRequest.Builder()).build()); + } + + public CompletableFuture getDocumentDoc(GetDocumentDocRequest request) + throws IOException, OpenSearchException { + JsonEndpoint endpoint = + (JsonEndpoint) + GetDocumentDocRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + public final CompletableFuture getDocumentDoc( + Function> fn) + throws IOException, OpenSearchException { + return getDocumentDoc(fn.apply(new GetDocumentDocRequest.Builder()).build()); + } + + public CompletableFuture getDocumentSource( + GetDocumentSourceRequest request) throws IOException, OpenSearchException { + JsonEndpoint endpoint = + (JsonEndpoint) + GetDocumentSourceRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + public final CompletableFuture getDocumentSource( + Function> fn) + throws IOException, OpenSearchException { + return getDocumentSource(fn.apply(new GetDocumentSourceRequest.Builder()).build()); + } + + public CompletableFuture getSettingsIndex( + GetSettingsIndexRequest request) throws IOException, OpenSearchException { + JsonEndpoint endpoint = + (JsonEndpoint) + GetSettingsIndexRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + public final CompletableFuture getSettingsIndex( + Function> fn) + throws IOException, OpenSearchException { + return getSettingsIndex(fn.apply(new GetSettingsIndexRequest.Builder()).build()); + } + + public CompletableFuture getSettingsIndexSetting( + GetSettingsIndexSettingRequest request) throws IOException, OpenSearchException { + JsonEndpoint + endpoint = + (JsonEndpoint< + GetSettingsIndexSettingRequest, + GetSettingsIndexSettingResponse, + ErrorResponse>) + GetSettingsIndexSettingRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + public final CompletableFuture getSettingsIndexSetting( + Function< + GetSettingsIndexSettingRequest.Builder, + ObjectBuilder> + fn) + throws IOException, OpenSearchException { + return getSettingsIndexSetting( + fn.apply(new GetSettingsIndexSettingRequest.Builder()).build()); + } + + public CompletableFuture postAliases(PostAliasesRequest request) + throws IOException, OpenSearchException { + JsonEndpoint endpoint = + (JsonEndpoint) + PostAliasesRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + public final CompletableFuture postAliases( + Function> fn) + throws IOException, OpenSearchException { + return postAliases(fn.apply(new PostAliasesRequest.Builder()).build()); + } + + public CompletableFuture postRemoteStoreRestore( + PostRemoteStoreRestoreRequest request) throws IOException, OpenSearchException { + JsonEndpoint + endpoint = + (JsonEndpoint< + PostRemoteStoreRestoreRequest, + PostRemoteStoreRestoreResponse, + ErrorResponse>) + PostRemoteStoreRestoreRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + public final CompletableFuture postRemoteStoreRestore( + Function< + PostRemoteStoreRestoreRequest.Builder, + ObjectBuilder> + fn) + throws IOException, OpenSearchException { + return postRemoteStoreRestore( + fn.apply(new PostRemoteStoreRestoreRequest.Builder()).build()); + } + + public CompletableFuture postSearch(PostSearchRequest request) + throws IOException, OpenSearchException { + JsonEndpoint endpoint = + (JsonEndpoint) + PostSearchRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + public final CompletableFuture postSearch( + Function> fn) + throws IOException, OpenSearchException { + return postSearch(fn.apply(new PostSearchRequest.Builder()).build()); + } + + public CompletableFuture postSearchWithIndex( + PostSearchWithIndexRequest request) throws IOException, OpenSearchException { + JsonEndpoint + endpoint = + (JsonEndpoint< + PostSearchWithIndexRequest, + PostSearchWithIndexResponse, + ErrorResponse>) + PostSearchWithIndexRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + public final CompletableFuture postSearchWithIndex( + Function> + fn) + throws IOException, OpenSearchException { + return postSearchWithIndex(fn.apply(new PostSearchWithIndexRequest.Builder()).build()); + } + + public CompletableFuture putCreateIndex(PutCreateIndexRequest request) + throws IOException, OpenSearchException { + JsonEndpoint endpoint = + (JsonEndpoint) + PutCreateIndexRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + public final CompletableFuture putCreateIndex( + Function> fn) + throws IOException, OpenSearchException { + return putCreateIndex(fn.apply(new PutCreateIndexRequest.Builder()).build()); + } + + public CompletableFuture putIndexMappingWithIndex( + PutIndexMappingWithIndexRequest request) throws IOException, OpenSearchException { + JsonEndpoint< + PutIndexMappingWithIndexRequest, + PutIndexMappingWithIndexResponse, + ErrorResponse> + endpoint = + (JsonEndpoint< + PutIndexMappingWithIndexRequest, + PutIndexMappingWithIndexResponse, + ErrorResponse>) + PutIndexMappingWithIndexRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + public final CompletableFuture putIndexMappingWithIndex( + Function< + PutIndexMappingWithIndexRequest.Builder, + ObjectBuilder> + fn) + throws IOException, OpenSearchException { + return putIndexMappingWithIndex( + fn.apply(new PutIndexMappingWithIndexRequest.Builder()).build()); + } + + public CompletableFuture putUpdateClusterSettings( + PutUpdateClusterSettingsRequest request) throws IOException, OpenSearchException { + JsonEndpoint< + PutUpdateClusterSettingsRequest, + PutUpdateClusterSettingsResponse, + ErrorResponse> + endpoint = + (JsonEndpoint< + PutUpdateClusterSettingsRequest, + PutUpdateClusterSettingsResponse, + ErrorResponse>) + PutUpdateClusterSettingsRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + public final CompletableFuture putUpdateClusterSettings( + Function< + PutUpdateClusterSettingsRequest.Builder, + ObjectBuilder> + fn) + throws IOException, OpenSearchException { + return putUpdateClusterSettings( + fn.apply(new PutUpdateClusterSettingsRequest.Builder()).build()); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClient.java b/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClient.java new file mode 100644 index 0000000000..b48c574d2d --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClient.java @@ -0,0 +1,339 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.ApiClient; +import org.opensearch.client.opensearch._types.OpenSearchException; +import org.opensearch.client.opensearch._types.ErrorResponse; +import org.opensearch.client.transport.OpenSearchTransport; +import org.opensearch.client.transport.JsonEndpoint; +import org.opensearch.client.transport.TransportOptions; +import org.opensearch.client.util.ObjectBuilder; +import java.io.IOException; +import java.util.function.Function; +import javax.annotation.Nullable; + +public class OpenSearchClient extends ApiClient { + public OpenSearchClient(OpenSearchTransport transport) { + super(transport, null); + } + + public OpenSearchClient( + OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { + super(transport, transportOptions); + } + + @Override + public OpenSearchClient withTransportOptions(@Nullable TransportOptions transportOptions) { + return new OpenSearchClient(this.transport, transportOptions); + } + + public DeleteIndexResponse deleteIndex(DeleteIndexRequest request) + throws IOException, OpenSearchException { + JsonEndpoint endpoint = + (JsonEndpoint) + DeleteIndexRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + public final DeleteIndexResponse deleteIndex( + Function> fn) + throws IOException, OpenSearchException { + return deleteIndex(fn.apply(new DeleteIndexRequest.Builder()).build()); + } + + public GetCatIndicesResponse getCatIndices(GetCatIndicesRequest request) + throws IOException, OpenSearchException { + JsonEndpoint endpoint = + (JsonEndpoint) + GetCatIndicesRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + public final GetCatIndicesResponse getCatIndices( + Function> fn) + throws IOException, OpenSearchException { + return getCatIndices(fn.apply(new GetCatIndicesRequest.Builder()).build()); + } + + public GetCatIndicesWithIndexResponse getCatIndicesWithIndex( + GetCatIndicesWithIndexRequest request) throws IOException, OpenSearchException { + JsonEndpoint + endpoint = + (JsonEndpoint< + GetCatIndicesWithIndexRequest, + GetCatIndicesWithIndexResponse, + ErrorResponse>) + GetCatIndicesWithIndexRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + public final GetCatIndicesWithIndexResponse getCatIndicesWithIndex( + Function< + GetCatIndicesWithIndexRequest.Builder, + ObjectBuilder> + fn) + throws IOException, OpenSearchException { + return getCatIndicesWithIndex( + fn.apply(new GetCatIndicesWithIndexRequest.Builder()).build()); + } + + public GetCatNodesResponse getCatNodes(GetCatNodesRequest request) + throws IOException, OpenSearchException { + JsonEndpoint endpoint = + (JsonEndpoint) + GetCatNodesRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + public final GetCatNodesResponse getCatNodes( + Function> fn) + throws IOException, OpenSearchException { + return getCatNodes(fn.apply(new GetCatNodesRequest.Builder()).build()); + } + + public GetClusterInfoResponse getClusterInfo(GetClusterInfoRequest request) + throws IOException, OpenSearchException { + JsonEndpoint endpoint = + (JsonEndpoint) + GetClusterInfoRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + public final GetClusterInfoResponse getClusterInfo( + Function> fn) + throws IOException, OpenSearchException { + return getClusterInfo(fn.apply(new GetClusterInfoRequest.Builder()).build()); + } + + public GetClusterSettingsResponse getClusterSettings(GetClusterSettingsRequest request) + throws IOException, OpenSearchException { + JsonEndpoint + endpoint = + (JsonEndpoint< + GetClusterSettingsRequest, + GetClusterSettingsResponse, + ErrorResponse>) + GetClusterSettingsRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + public final GetClusterSettingsResponse getClusterSettings( + Function> + fn) + throws IOException, OpenSearchException { + return getClusterSettings(fn.apply(new GetClusterSettingsRequest.Builder()).build()); + } + + public GetDocumentDocResponse getDocumentDoc(GetDocumentDocRequest request) + throws IOException, OpenSearchException { + JsonEndpoint endpoint = + (JsonEndpoint) + GetDocumentDocRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + public final GetDocumentDocResponse getDocumentDoc( + Function> fn) + throws IOException, OpenSearchException { + return getDocumentDoc(fn.apply(new GetDocumentDocRequest.Builder()).build()); + } + + public GetDocumentSourceResponse getDocumentSource(GetDocumentSourceRequest request) + throws IOException, OpenSearchException { + JsonEndpoint endpoint = + (JsonEndpoint) + GetDocumentSourceRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + public final GetDocumentSourceResponse getDocumentSource( + Function> fn) + throws IOException, OpenSearchException { + return getDocumentSource(fn.apply(new GetDocumentSourceRequest.Builder()).build()); + } + + public GetSettingsIndexResponse getSettingsIndex(GetSettingsIndexRequest request) + throws IOException, OpenSearchException { + JsonEndpoint endpoint = + (JsonEndpoint) + GetSettingsIndexRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + public final GetSettingsIndexResponse getSettingsIndex( + Function> fn) + throws IOException, OpenSearchException { + return getSettingsIndex(fn.apply(new GetSettingsIndexRequest.Builder()).build()); + } + + public GetSettingsIndexSettingResponse getSettingsIndexSetting( + GetSettingsIndexSettingRequest request) throws IOException, OpenSearchException { + JsonEndpoint + endpoint = + (JsonEndpoint< + GetSettingsIndexSettingRequest, + GetSettingsIndexSettingResponse, + ErrorResponse>) + GetSettingsIndexSettingRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + public final GetSettingsIndexSettingResponse getSettingsIndexSetting( + Function< + GetSettingsIndexSettingRequest.Builder, + ObjectBuilder> + fn) + throws IOException, OpenSearchException { + return getSettingsIndexSetting( + fn.apply(new GetSettingsIndexSettingRequest.Builder()).build()); + } + + public PostAliasesResponse postAliases(PostAliasesRequest request) + throws IOException, OpenSearchException { + JsonEndpoint endpoint = + (JsonEndpoint) + PostAliasesRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + public final PostAliasesResponse postAliases( + Function> fn) + throws IOException, OpenSearchException { + return postAliases(fn.apply(new PostAliasesRequest.Builder()).build()); + } + + public PostRemoteStoreRestoreResponse postRemoteStoreRestore( + PostRemoteStoreRestoreRequest request) throws IOException, OpenSearchException { + JsonEndpoint + endpoint = + (JsonEndpoint< + PostRemoteStoreRestoreRequest, + PostRemoteStoreRestoreResponse, + ErrorResponse>) + PostRemoteStoreRestoreRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + public final PostRemoteStoreRestoreResponse postRemoteStoreRestore( + Function< + PostRemoteStoreRestoreRequest.Builder, + ObjectBuilder> + fn) + throws IOException, OpenSearchException { + return postRemoteStoreRestore( + fn.apply(new PostRemoteStoreRestoreRequest.Builder()).build()); + } + + public PostSearchResponse postSearch(PostSearchRequest request) + throws IOException, OpenSearchException { + JsonEndpoint endpoint = + (JsonEndpoint) + PostSearchRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + public final PostSearchResponse postSearch( + Function> fn) + throws IOException, OpenSearchException { + return postSearch(fn.apply(new PostSearchRequest.Builder()).build()); + } + + public PostSearchWithIndexResponse postSearchWithIndex(PostSearchWithIndexRequest request) + throws IOException, OpenSearchException { + JsonEndpoint + endpoint = + (JsonEndpoint< + PostSearchWithIndexRequest, + PostSearchWithIndexResponse, + ErrorResponse>) + PostSearchWithIndexRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + public final PostSearchWithIndexResponse postSearchWithIndex( + Function> + fn) + throws IOException, OpenSearchException { + return postSearchWithIndex(fn.apply(new PostSearchWithIndexRequest.Builder()).build()); + } + + public PutCreateIndexResponse putCreateIndex(PutCreateIndexRequest request) + throws IOException, OpenSearchException { + JsonEndpoint endpoint = + (JsonEndpoint) + PutCreateIndexRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + public final PutCreateIndexResponse putCreateIndex( + Function> fn) + throws IOException, OpenSearchException { + return putCreateIndex(fn.apply(new PutCreateIndexRequest.Builder()).build()); + } + + public PutIndexMappingWithIndexResponse putIndexMappingWithIndex( + PutIndexMappingWithIndexRequest request) throws IOException, OpenSearchException { + JsonEndpoint< + PutIndexMappingWithIndexRequest, + PutIndexMappingWithIndexResponse, + ErrorResponse> + endpoint = + (JsonEndpoint< + PutIndexMappingWithIndexRequest, + PutIndexMappingWithIndexResponse, + ErrorResponse>) + PutIndexMappingWithIndexRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + public final PutIndexMappingWithIndexResponse putIndexMappingWithIndex( + Function< + PutIndexMappingWithIndexRequest.Builder, + ObjectBuilder> + fn) + throws IOException, OpenSearchException { + return putIndexMappingWithIndex( + fn.apply(new PutIndexMappingWithIndexRequest.Builder()).build()); + } + + public PutUpdateClusterSettingsResponse putUpdateClusterSettings( + PutUpdateClusterSettingsRequest request) throws IOException, OpenSearchException { + JsonEndpoint< + PutUpdateClusterSettingsRequest, + PutUpdateClusterSettingsResponse, + ErrorResponse> + endpoint = + (JsonEndpoint< + PutUpdateClusterSettingsRequest, + PutUpdateClusterSettingsResponse, + ErrorResponse>) + PutUpdateClusterSettingsRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + public final PutUpdateClusterSettingsResponse putUpdateClusterSettings( + Function< + PutUpdateClusterSettingsRequest.Builder, + ObjectBuilder> + fn) + throws IOException, OpenSearchException { + return putUpdateClusterSettings( + fn.apply(new PutUpdateClusterSettingsRequest.Builder()).build()); + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java b/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java index 088a492a9a..be5220edae 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java @@ -12,7 +12,7 @@ import org.opensearch.client.codegen.model.EnumShape; import org.opensearch.client.codegen.model.Field; import org.opensearch.client.codegen.model.ObjectShape; -import org.opensearch.client.codegen.model.OperationRequest; +import org.opensearch.client.codegen.model.RequestShape; import org.opensearch.client.codegen.utils.Schemas; import java.io.File; @@ -24,7 +24,7 @@ public class ApiSpecification { private final OAIContext context; private final Set visitedReferencedSchemas; - private final List operationRequests; + private final List requestShapes; private final List objectShapes; private final List enumShapes; private final TypeMapper typeMapper; @@ -32,7 +32,7 @@ public class ApiSpecification { private ApiSpecification(OpenApi3 api) throws ApiSpecificationParseException { context = api.getContext(); visitedReferencedSchemas = new HashSet<>(); - operationRequests = new ArrayList<>(); + requestShapes = new ArrayList<>(); objectShapes = new ArrayList<>(); enumShapes = new ArrayList<>(); typeMapper = new TypeMapper(context, this::visitReferencedSchema); @@ -48,8 +48,8 @@ public static ApiSpecification parse(File schemaFile) throws ApiSpecificationPar } } - public List getOperationRequests() { - return Collections.unmodifiableList(operationRequests); + public List getRequestShapes() { + return Collections.unmodifiableList(requestShapes); } public List getObjectShapes() { @@ -73,7 +73,7 @@ private void visit(String httpPath, Path path) throws ApiSpecificationParseExcep } private void visit(String httpPath, Path path, String httpMethod, Operation operation) throws ApiSpecificationParseException { - OperationRequest operationRequest = new OperationRequest( + RequestShape requestShape = new RequestShape( operation.getOperationId(), operation.getDescription(), httpMethod, @@ -84,20 +84,20 @@ private void visit(String httpPath, Path path, String httpMethod, Operation oper if (requestBody != null) { Schema requestBodySchema = resolve(requestBody.getContentMediaType("application/json").getSchema()); - visitFields(requestBodySchema, operationRequest::addBodyField); + visitFields(requestBodySchema, requestShape::addBodyField); } Stream.of(path.getParametersIn(context, "query"), operation.getParametersIn(context, "query")) .flatMap(List::stream) .map(p -> new Field(p.getName(), typeMapper.mapType(p.getSchema()), p.isRequired())) - .forEach(operationRequest::addQueryParam); + .forEach(requestShape::addQueryParam); Stream.of(path.getParametersIn(context, "path"), operation.getParametersIn(context, "path")) .flatMap(List::stream) .map(p -> new Field(p.getName(), typeMapper.mapType(p.getSchema()), p.isRequired())) - .forEach(operationRequest::addPathParam); + .forEach(requestShape::addPathParam); - operationRequests.add(operationRequest); + requestShapes.add(requestShape); MediaType responseMediaType = operation.getResponse("200").getContentMediaType("application/json"); Schema responseSchema = responseMediaType != null ? resolve(responseMediaType.getSchema()) : new Schema(); diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java b/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java index 3cbed93c38..1f5b620413 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java @@ -2,9 +2,10 @@ import org.opensearch.client.codegen.exceptions.ApiSpecificationParseException; import org.opensearch.client.codegen.exceptions.RenderException; +import org.opensearch.client.codegen.model.Client; import org.opensearch.client.codegen.model.EnumShape; import org.opensearch.client.codegen.model.ObjectShape; -import org.opensearch.client.codegen.model.OperationRequest; +import org.opensearch.client.codegen.model.RequestShape; import java.io.File; import java.io.IOException; @@ -37,9 +38,13 @@ public void generate() throws RenderException { packageDir.mkdirs(); - for (OperationRequest operationRequest : apiSpecification.getOperationRequests()) { - File file = new File(packageDir, operationRequest.className() + ".java"); - renderer.render(operationRequest, file); + Client client = new Client(""); + + for (RequestShape requestShape : apiSpecification.getRequestShapes()) { + File file = new File(packageDir, requestShape.className() + ".java"); + renderer.render(requestShape, file); + + client.addOperation(requestShape.id()); } for (ObjectShape objectShape : apiSpecification.getObjectShapes()) { @@ -51,5 +56,13 @@ public void generate() throws RenderException { File file = new File(packageDir, enumShape.className() + ".java"); renderer.render(enumShape, file); } + + File clientFile = new File(packageDir, client.className() + ".java"); + renderer.render(client, clientFile); + + client.async(true); + + File asyncClientFile = new File(packageDir, client.className() + ".java"); + renderer.render(client, asyncClientFile); } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/NameSanitizer.java b/java-codegen/src/main/java/org/opensearch/client/codegen/NameSanitizer.java index 2e4421ae48..030ce9e7e9 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/NameSanitizer.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/NameSanitizer.java @@ -1,6 +1,6 @@ package org.opensearch.client.codegen; -import org.apache.commons.text.CaseUtils; +import org.opensearch.client.codegen.utils.Strings; import java.util.HashSet; import java.util.Set; @@ -11,7 +11,7 @@ public class NameSanitizer { }}; public static String wireNameToField(String wireName) { - String name = CaseUtils.toCamelCase(wireName, false, '_'); + String name = Strings.toCamelCase(wireName); if (reservedWords.contains(name)) { name += "_"; } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Client.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Client.java new file mode 100644 index 0000000000..11e4188308 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Client.java @@ -0,0 +1,41 @@ +package org.opensearch.client.codegen.model; + +import org.opensearch.client.codegen.utils.Strings; + +import java.util.Collection; +import java.util.Map; +import java.util.TreeMap; + +public class Client { + private final String namespace; + private boolean async; + private final Map operations = new TreeMap<>(); + + public Client(String namespace) { + this.namespace = namespace; + } + + public void addOperation(String id) { + operations.put(id, new ClientOperation(id)); + } + + public String className() { + return "OpenSearch" + Strings.toPascalCase(namespace) + (async ? "Async" : "") + "Client"; + } + + public String namespace() { + return namespace; + } + + public Collection operations() { + return operations.values(); + } + + public boolean async() { + return async; + } + + public void async(boolean async) { + this.async = async; + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ClientOperation.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ClientOperation.java new file mode 100644 index 0000000000..e570bb1f08 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ClientOperation.java @@ -0,0 +1,23 @@ +package org.opensearch.client.codegen.model; + +import org.opensearch.client.codegen.utils.Strings; + +public class ClientOperation { + private final String id; + + public ClientOperation(String id) { + this.id = id; + } + + public String name() { + return Strings.toCamelCase(id); + } + + public String requestType() { + return Strings.toPascalCase(id) + "Request"; + } + + public String responseType() { + return Strings.toPascalCase(id) + "Response"; + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java index 4ccc141d13..5beafd69b2 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java @@ -1,6 +1,6 @@ package org.opensearch.client.codegen.model; -import org.apache.commons.text.CaseUtils; +import org.opensearch.client.codegen.utils.Strings; import java.util.Collection; import java.util.List; @@ -25,7 +25,7 @@ public Variant(String wireName) { } public String name() { - return CaseUtils.toCamelCase(wireName, true, '_'); + return Strings.toPascalCase(wireName); } } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/OperationRequest.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java similarity index 51% rename from java-codegen/src/main/java/org/opensearch/client/codegen/model/OperationRequest.java rename to java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java index 251678a778..0011903908 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/OperationRequest.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java @@ -1,8 +1,10 @@ package org.opensearch.client.codegen.model; -import java.util.*; +import java.util.Collection; +import java.util.Map; +import java.util.TreeMap; -public class OperationRequest extends ObjectShape { +public class RequestShape extends ObjectShape { private final String id; private final String description; private final String httpMethod; @@ -11,7 +13,7 @@ public class OperationRequest extends ObjectShape { private final Map pathParams = new TreeMap<>(); private final Map fields = new TreeMap<>(); - public OperationRequest(String id, String description, String httpMethod, String httpPath) { + public RequestShape(String id, String description, String httpMethod, String httpPath) { super(id + "Request"); this.id = id; this.description = description; @@ -19,22 +21,42 @@ public OperationRequest(String id, String description, String httpMethod, String this.httpPath = httpPath; } - public String description() { return description; } + public String id() { + return id; + } - public String httpMethod() { return httpMethod; } + public String description() { + return description; + } - public String httpPath() { return '"' + httpPath.replace("{", "\" + request.").replace("}", " + \"") + '"'; } + public String httpMethod() { + return httpMethod; + } + + public String httpPath() { + return '"' + httpPath.replace("{", "\" + request.").replace("}", " + \"") + '"'; + } - public String responseType() { return id + "Response"; } + public String responseType() { + return id + "Response"; + } - public boolean hasRequestBody() { return !bodyFields().isEmpty(); } + public boolean hasRequestBody() { + return !bodyFields().isEmpty(); + } - public Collection queryParams() { return queryParams.values(); } + public Collection queryParams() { + return queryParams.values(); + } - public Collection pathParams() { return pathParams.values(); } + public Collection pathParams() { + return pathParams.values(); + } @Override - public Collection fields() { return fields.values(); } + public Collection fields() { + return fields.values(); + } @Override public void addBodyField(Field field) { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Strings.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Strings.java new file mode 100644 index 0000000000..553f8597e6 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Strings.java @@ -0,0 +1,29 @@ +package org.opensearch.client.codegen.utils; + +import org.apache.commons.text.CaseUtils; + +import java.util.Locale; + +public final class Strings { + private Strings() {} + + public static String toCamelCase(String str) { + return toCamelCase(str, false); + } + + public static String toPascalCase(String str) { + return toCamelCase(str, true); + } + + private static String toCamelCase(String str, boolean capitalizeFirstLetter) { + return CaseUtils.toCamelCase(toSnakeCase(str), capitalizeFirstLetter, '_'); + } + + public static String toSnakeCase(String str) { + return str.replaceAll("([A-Z]+)([A-Z][a-z])", "$1_$2") + .replaceAll("([a-z\\d])([A-Z])", "$1_$2") + .replaceAll("(\\s|-)", "_") + .toLowerCase(Locale.US); + } + +} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Client.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Client.mustache new file mode 100644 index 0000000000..0aae699919 --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Client.mustache @@ -0,0 +1,43 @@ +package org.opensearch.client.opensearch; + +import org.opensearch.client.ApiClient; +import org.opensearch.client.opensearch._types.OpenSearchException; +import org.opensearch.client.opensearch._types.ErrorResponse; +import org.opensearch.client.transport.OpenSearchTransport; +import org.opensearch.client.transport.JsonEndpoint; +import org.opensearch.client.transport.TransportOptions; +import org.opensearch.client.util.ObjectBuilder; +import java.io.IOException; +{{#async}} +import java.util.concurrent.CompletableFuture; +{{/async}} +import java.util.function.Function; +import javax.annotation.Nullable; + +public class {{className}} extends ApiClient { + public {{className}}(OpenSearchTransport transport) { + super(transport, null); + } + + public {{className}}(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { + super(transport, transportOptions); + } + + @Override + public {{className}} withTransportOptions(@Nullable TransportOptions transportOptions) { + return new {{className}}(this.transport, transportOptions); + } +{{#operations}} + + public {{#async}}CompletableFuture<{{/async}}{{responseType}}{{#async}}>{{/async}} {{name}}({{requestType}} request) throws IOException, OpenSearchException { + JsonEndpoint<{{requestType}}, {{responseType}}, ErrorResponse> endpoint = (JsonEndpoint<{{requestType}}, {{responseType}}, ErrorResponse>) {{requestType}}._ENDPOINT; + + return this.transport.performRequest{{#async}}Async{{/async}}(request, endpoint, this.transportOptions); + } + + public final {{#async}}CompletableFuture<{{/async}}{{responseType}}{{#async}}>{{/async}} {{name}}(Function<{{requestType}}.Builder, ObjectBuilder<{{requestType}}>> fn) + throws IOException, OpenSearchException { + return {{name}}(fn.apply(new {{requestType}}.Builder()).build()); + } +{{/operations}} +} \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache similarity index 100% rename from java-codegen/src/main/resources/org/opensearch/client/codegen/templates/OperationRequest.mustache rename to java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache From d0ef49e9b441e7345e07ed131f7a5b4c9d8e97b9 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Thu, 16 Feb 2023 16:32:08 +1300 Subject: [PATCH 09/50] Cleanup Signed-off-by: Thomas Farr --- .../opensearch/ActionObjectStructure.java | 124 -- .../client/opensearch/DefaultOperator.java | 30 - .../client/opensearch/DeleteIndexRequest.java | 167 --- .../opensearch/DeleteIndexResponse.java | 70 - .../client/opensearch/ExpandWildcards.java | 33 - .../opensearch/GetCatIndicesRequest.java | 211 --- .../opensearch/GetCatIndicesResponse.java | 50 - .../GetCatIndicesWithIndexRequest.java | 225 --- .../GetCatIndicesWithIndexResponse.java | 52 - .../client/opensearch/GetCatNodesRequest.java | 186 --- .../opensearch/GetCatNodesResponse.java | 49 - .../opensearch/GetClusterInfoRequest.java | 57 - .../opensearch/GetClusterInfoResponse.java | 151 -- .../opensearch/GetClusterSettingsRequest.java | 128 -- .../GetClusterSettingsResponse.java | 149 -- .../opensearch/GetDocumentDocRequest.java | 245 ---- .../opensearch/GetDocumentDocResponse.java | 262 ---- .../opensearch/GetDocumentSourceRequest.java | 245 ---- .../opensearch/GetDocumentSourceResponse.java | 51 - .../opensearch/GetSettingsIndexRequest.java | 208 --- .../opensearch/GetSettingsIndexResponse.java | 51 - .../GetSettingsIndexSettingRequest.java | 222 --- .../GetSettingsIndexSettingResponse.java | 52 - .../client/opensearch/HealthStatus.java | 31 - .../opensearch/client/opensearch/Hits.java | 162 --- .../client/opensearch/HitsMetadata.java | 124 -- .../opensearch/OpenSearchAsyncClient.java | 340 ----- .../client/opensearch/OpenSearchClient.java | 339 ----- .../client/opensearch/PostAliasesRequest.java | 147 -- .../opensearch/PostAliasesResponse.java | 69 - .../PostRemoteStoreRestoreRequest.java | 144 -- .../PostRemoteStoreRestoreResponse.java | 98 -- .../client/opensearch/PostSearchRequest.java | 961 ------------- .../client/opensearch/PostSearchResponse.java | 155 --- .../PostSearchWithIndexRequest.java | 994 ------------- .../PostSearchWithIndexResponse.java | 157 --- .../opensearch/PutCreateIndexRequest.java | 271 ---- .../opensearch/PutCreateIndexResponse.java | 109 -- .../PutIndexMappingWithIndexRequest.java | 254 ---- .../PutIndexMappingWithIndexResponse.java | 73 - .../PutUpdateClusterSettingsRequest.java | 213 --- .../PutUpdateClusterSettingsResponse.java | 137 -- .../client/opensearch/Relation.java | 30 - .../opensearch/RemoteStoreRestoreInfo.java | 129 -- .../RemoteStoreRestoreShardsInfo.java | 110 -- .../client/opensearch/SearchType.java | 30 - .../client/opensearch/ShardStatistics.java | 127 -- .../client/opensearch/SuggestMode.java | 31 - .../opensearch/client/opensearch/Total.java | 86 -- .../UserDefinedObjectStructure.java | 1229 ----------------- .../opensearch/UserDefinedStructure.java | 285 ---- .../opensearch/client/opensearch/Version.java | 225 --- .../client/opensearch/VersionType.java | 31 - .../client/codegen/ApiSpecification.java | 22 +- .../opensearch/client/codegen/Generator.java | 8 + .../org/opensearch/client/codegen/Main.java | 8 + .../client/codegen/NameSanitizer.java | 8 + .../opensearch/client/codegen/Renderer.java | 16 +- .../opensearch/client/codegen/TypeMapper.java | 8 + .../ApiSpecificationParseException.java | 8 + .../codegen/exceptions/RenderException.java | 8 + .../client/codegen/model/Client.java | 8 + .../client/codegen/model/ClientOperation.java | 8 + .../client/codegen/model/EnumShape.java | 8 + .../client/codegen/model/Field.java | 8 + .../client/codegen/model/ObjectShape.java | 8 + .../client/codegen/model/RequestShape.java | 8 + .../opensearch/client/codegen/model/Type.java | 9 +- .../client/codegen/utils/Schemas.java | 8 + .../client/codegen/utils/Strings.java | 8 + 70 files changed, 155 insertions(+), 10113 deletions(-) delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/ActionObjectStructure.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/DefaultOperator.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexResponse.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/ExpandWildcards.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesRequest.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesResponse.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexResponse.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesRequest.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesResponse.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoRequest.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoResponse.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsRequest.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsResponse.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocResponse.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceResponse.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexResponse.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingResponse.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/HealthStatus.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/Hits.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/HitsMetadata.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClient.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesRequest.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesResponse.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreRequest.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreResponse.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchRequest.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchResponse.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexResponse.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexResponse.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexResponse.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsRequest.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsResponse.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/Relation.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreInfo.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreShardsInfo.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/SearchType.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/ShardStatistics.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/SuggestMode.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/Total.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedObjectStructure.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedStructure.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/Version.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/VersionType.java diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ActionObjectStructure.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ActionObjectStructure.java deleted file mode 100644 index 584bf575ef..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ActionObjectStructure.java +++ /dev/null @@ -1,124 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class ActionObjectStructure implements JsonpSerializable { - - @Nullable private final UserDefinedStructure add; - - @Nullable private final UserDefinedStructure remove; - - @Nullable private final UserDefinedStructure removeIndex; - - public ActionObjectStructure(Builder builder) { - this.add = builder.add; - this.remove = builder.remove; - this.removeIndex = builder.removeIndex; - } - - public static ActionObjectStructure of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final UserDefinedStructure add() { - return this.add; - } - - public final UserDefinedStructure remove() { - return this.remove; - } - - public final UserDefinedStructure removeIndex() { - return this.removeIndex; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.add != null) { - generator.writeKey("add"); - this.add.serialize(generator, mapper); - } - - if (this.remove != null) { - generator.writeKey("remove"); - this.remove.serialize(generator, mapper); - } - - if (this.removeIndex != null) { - generator.writeKey("remove_index"); - this.removeIndex.serialize(generator, mapper); - } - } - - /** Builder for {@link ActionObjectStructure}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private UserDefinedStructure add; - private UserDefinedStructure remove; - private UserDefinedStructure removeIndex; - - public final Builder add(UserDefinedStructure value) { - this.add = value; - return this; - } - - public final Builder add( - Function> fn) { - return add(fn.apply(new UserDefinedStructure.Builder()).build()); - } - - public final Builder remove(UserDefinedStructure value) { - this.remove = value; - return this; - } - - public final Builder remove( - Function> fn) { - return remove(fn.apply(new UserDefinedStructure.Builder()).build()); - } - - public final Builder removeIndex(UserDefinedStructure value) { - this.removeIndex = value; - return this; - } - - public final Builder removeIndex( - Function> fn) { - return removeIndex(fn.apply(new UserDefinedStructure.Builder()).build()); - } - - /** - * Builds a {@link ActionObjectStructure}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public ActionObjectStructure build() { - _checkSingleUse(); - - return new ActionObjectStructure(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, ActionObjectStructure::setupActionObjectStructureDeserializer); - - protected static void setupActionObjectStructureDeserializer( - ObjectDeserializer op) { - op.add(Builder::add, UserDefinedStructure._DESERIALIZER, "add"); - op.add(Builder::remove, UserDefinedStructure._DESERIALIZER, "remove"); - op.add(Builder::removeIndex, UserDefinedStructure._DESERIALIZER, "remove_index"); - } -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/DefaultOperator.java b/java-client/src/generated/java/org/opensearch/client/opensearch/DefaultOperator.java deleted file mode 100644 index 33e8791920..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/DefaultOperator.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.JsonEnum; -import org.opensearch.client.json.JsonpDeserializable; - -@JsonpDeserializable -public enum DefaultOperator implements JsonEnum { - And("AND"), - Or("OR"), - ; - - private final String jsonValue; - private final String[] aliases; - - DefaultOperator(String jsonValue, String... aliases) { - this.jsonValue = jsonValue; - this.aliases = aliases; - } - - public String jsonValue() { - return this.jsonValue; - } - - public String[] aliases() { - return this.aliases; - } - - public static final JsonEnum.Deserializer _DESERIALIZER = - new JsonEnum.Deserializer<>(DefaultOperator.values()); -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java deleted file mode 100644 index 6d42fbd932..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexRequest.java +++ /dev/null @@ -1,167 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.opensearch._types.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; -import org.opensearch.client.util.*; -import java.util.*; -import java.util.function.Function; -import java.util.stream.*; -import javax.annotation.*; - -/** Removes a document from the index. */ -public class DeleteIndexRequest extends RequestBase { - - @Nullable private final Boolean allowNoIndices; - - @Nullable private final String clusterManagerTimeout; - - @Nullable private final ExpandWildcards expandWildcards; - - @Nullable private final Boolean ignoreUnavailable; - - private final String index; - - @Nullable private final String masterTimeout; - - @Nullable private final String timeout; - - public DeleteIndexRequest(Builder builder) { - this.allowNoIndices = builder.allowNoIndices; - this.clusterManagerTimeout = builder.clusterManagerTimeout; - this.expandWildcards = builder.expandWildcards; - this.ignoreUnavailable = builder.ignoreUnavailable; - this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); - this.masterTimeout = builder.masterTimeout; - this.timeout = builder.timeout; - } - - public static DeleteIndexRequest of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final Boolean allowNoIndices() { - return this.allowNoIndices; - } - - public final String clusterManagerTimeout() { - return this.clusterManagerTimeout; - } - - public final ExpandWildcards expandWildcards() { - return this.expandWildcards; - } - - public final Boolean ignoreUnavailable() { - return this.ignoreUnavailable; - } - - public final String index() { - return this.index; - } - - public final String masterTimeout() { - return this.masterTimeout; - } - - public final String timeout() { - return this.timeout; - } - - /** Builder for {@link DeleteIndexRequest}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private Boolean allowNoIndices; - private String clusterManagerTimeout; - private ExpandWildcards expandWildcards; - private Boolean ignoreUnavailable; - private String index; - private String masterTimeout; - private String timeout; - - public final Builder allowNoIndices(Boolean value) { - this.allowNoIndices = value; - return this; - } - - public final Builder clusterManagerTimeout(String value) { - this.clusterManagerTimeout = value; - return this; - } - - public final Builder expandWildcards(ExpandWildcards value) { - this.expandWildcards = value; - return this; - } - - public final Builder ignoreUnavailable(Boolean value) { - this.ignoreUnavailable = value; - return this; - } - - public final Builder index(String value) { - this.index = value; - return this; - } - - public final Builder masterTimeout(String value) { - this.masterTimeout = value; - return this; - } - - public final Builder timeout(String value) { - this.timeout = value; - return this; - } - - /** - * Builds a {@link DeleteIndexRequest}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public DeleteIndexRequest build() { - _checkSingleUse(); - - return new DeleteIndexRequest(this); - } - } - - public static final Endpoint _ENDPOINT = - new SimpleEndpoint<>( - // Request method - request -> { - return "delete"; - }, - // Request path - request -> { - return "/" + request.index + ""; - }, - // Request parameters - request -> { - Map params = new HashMap<>(); - if (request.allowNoIndices != null) { - params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); - } - if (request.clusterManagerTimeout != null) { - params.put("cluster_manager_timeout", request.clusterManagerTimeout); - } - if (request.expandWildcards != null) { - params.put("expand_wildcards", request.expandWildcards.jsonValue()); - } - if (request.ignoreUnavailable != null) { - params.put( - "ignore_unavailable", - String.valueOf(request.ignoreUnavailable)); - } - if (request.masterTimeout != null) { - params.put("master_timeout", request.masterTimeout); - } - if (request.timeout != null) { - params.put("timeout", request.timeout); - } - return params; - }, - SimpleEndpoint.emptyMap(), - false, - DeleteIndexResponse._DESERIALIZER); -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexResponse.java deleted file mode 100644 index 36af738b03..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/DeleteIndexResponse.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class DeleteIndexResponse implements JsonpSerializable { - - @Nullable private final Boolean acknowledged; - - public DeleteIndexResponse(Builder builder) { - this.acknowledged = builder.acknowledged; - } - - public static DeleteIndexResponse of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final Boolean acknowledged() { - return this.acknowledged; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.acknowledged != null) { - generator.writeKey("acknowledged"); - generator.write(this.acknowledged); - } - } - - /** Builder for {@link DeleteIndexResponse}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private Boolean acknowledged; - - public final Builder acknowledged(Boolean value) { - this.acknowledged = value; - return this; - } - - /** - * Builds a {@link DeleteIndexResponse}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public DeleteIndexResponse build() { - _checkSingleUse(); - - return new DeleteIndexResponse(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, DeleteIndexResponse::setupDeleteIndexResponseDeserializer); - - protected static void setupDeleteIndexResponseDeserializer( - ObjectDeserializer op) { - op.add(Builder::acknowledged, JsonpDeserializer.booleanDeserializer(), "acknowledged"); - } -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ExpandWildcards.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ExpandWildcards.java deleted file mode 100644 index 355c48c0c9..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ExpandWildcards.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.JsonEnum; -import org.opensearch.client.json.JsonpDeserializable; - -@JsonpDeserializable -public enum ExpandWildcards implements JsonEnum { - All("all"), - Open("open"), - Closed("closed"), - Hidden("hidden"), - None("none"), - ; - - private final String jsonValue; - private final String[] aliases; - - ExpandWildcards(String jsonValue, String... aliases) { - this.jsonValue = jsonValue; - this.aliases = aliases; - } - - public String jsonValue() { - return this.jsonValue; - } - - public String[] aliases() { - return this.aliases; - } - - public static final JsonEnum.Deserializer _DESERIALIZER = - new JsonEnum.Deserializer<>(ExpandWildcards.values()); -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesRequest.java deleted file mode 100644 index db7e69a89c..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesRequest.java +++ /dev/null @@ -1,211 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.opensearch._types.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; -import org.opensearch.client.util.*; -import java.util.*; -import java.util.function.Function; -import java.util.stream.*; -import javax.annotation.*; - -/** - * Returns information about indices: number of primaries and replicas, document counts, disk size, - * etc. - */ -public class GetCatIndicesRequest extends RequestBase { - - @Nullable private final Integer bytes; - - @Nullable private final String clusterManagerTimeout; - - @Nullable private final ExpandWildcards expandWildcards; - - @Nullable private final String format; - - @Nullable private final HealthStatus health; - - @Nullable private final Boolean includeUnloadedSegments; - - @Nullable private final String masterTimeout; - - @Nullable private final Boolean pri; - - @Nullable private final String time; - - public GetCatIndicesRequest(Builder builder) { - this.bytes = builder.bytes; - this.clusterManagerTimeout = builder.clusterManagerTimeout; - this.expandWildcards = builder.expandWildcards; - this.format = builder.format; - this.health = builder.health; - this.includeUnloadedSegments = builder.includeUnloadedSegments; - this.masterTimeout = builder.masterTimeout; - this.pri = builder.pri; - this.time = builder.time; - } - - public static GetCatIndicesRequest of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final Integer bytes() { - return this.bytes; - } - - public final String clusterManagerTimeout() { - return this.clusterManagerTimeout; - } - - public final ExpandWildcards expandWildcards() { - return this.expandWildcards; - } - - public final String format() { - return this.format; - } - - public final HealthStatus health() { - return this.health; - } - - public final Boolean includeUnloadedSegments() { - return this.includeUnloadedSegments; - } - - public final String masterTimeout() { - return this.masterTimeout; - } - - public final Boolean pri() { - return this.pri; - } - - public final String time() { - return this.time; - } - - /** Builder for {@link GetCatIndicesRequest}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private Integer bytes; - private String clusterManagerTimeout; - private ExpandWildcards expandWildcards; - private String format; - private HealthStatus health; - private Boolean includeUnloadedSegments; - private String masterTimeout; - private Boolean pri; - private String time; - - public final Builder bytes(Integer value) { - this.bytes = value; - return this; - } - - public final Builder clusterManagerTimeout(String value) { - this.clusterManagerTimeout = value; - return this; - } - - public final Builder expandWildcards(ExpandWildcards value) { - this.expandWildcards = value; - return this; - } - - public final Builder format(String value) { - this.format = value; - return this; - } - - public final Builder health(HealthStatus value) { - this.health = value; - return this; - } - - public final Builder includeUnloadedSegments(Boolean value) { - this.includeUnloadedSegments = value; - return this; - } - - public final Builder masterTimeout(String value) { - this.masterTimeout = value; - return this; - } - - public final Builder pri(Boolean value) { - this.pri = value; - return this; - } - - public final Builder time(String value) { - this.time = value; - return this; - } - - /** - * Builds a {@link GetCatIndicesRequest}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public GetCatIndicesRequest build() { - _checkSingleUse(); - - return new GetCatIndicesRequest(this); - } - } - - public static final Endpoint - _ENDPOINT = - new SimpleEndpoint<>( - // Request method - request -> { - return "get"; - }, - // Request path - request -> { - return "/_cat/indices"; - }, - // Request parameters - request -> { - Map params = new HashMap<>(); - if (request.bytes != null) { - params.put("bytes", String.valueOf(request.bytes)); - } - if (request.clusterManagerTimeout != null) { - params.put( - "cluster_manager_timeout", - request.clusterManagerTimeout); - } - if (request.expandWildcards != null) { - params.put( - "expand_wildcards", - request.expandWildcards.jsonValue()); - } - if (request.format != null) { - params.put("format", request.format); - } - if (request.health != null) { - params.put("health", request.health.jsonValue()); - } - if (request.includeUnloadedSegments != null) { - params.put( - "include_unloaded_segments", - String.valueOf(request.includeUnloadedSegments)); - } - if (request.masterTimeout != null) { - params.put("master_timeout", request.masterTimeout); - } - if (request.pri != null) { - params.put("pri", String.valueOf(request.pri)); - } - if (request.time != null) { - params.put("time", request.time); - } - return params; - }, - SimpleEndpoint.emptyMap(), - false, - GetCatIndicesResponse._DESERIALIZER); -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesResponse.java deleted file mode 100644 index b0770295ff..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesResponse.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class GetCatIndicesResponse implements JsonpSerializable { - - public GetCatIndicesResponse(Builder builder) {} - - public static GetCatIndicesResponse of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {} - - /** Builder for {@link GetCatIndicesResponse}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - - /** - * Builds a {@link GetCatIndicesResponse}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public GetCatIndicesResponse build() { - _checkSingleUse(); - - return new GetCatIndicesResponse(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, GetCatIndicesResponse::setupGetCatIndicesResponseDeserializer); - - protected static void setupGetCatIndicesResponseDeserializer( - ObjectDeserializer op) {} -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java deleted file mode 100644 index 862e33105e..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexRequest.java +++ /dev/null @@ -1,225 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.opensearch._types.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; -import org.opensearch.client.util.*; -import java.util.*; -import java.util.function.Function; -import java.util.stream.*; -import javax.annotation.*; - -/** - * Returns information about indices: number of primaries and replicas, document counts, disk size, - * etc. - */ -public class GetCatIndicesWithIndexRequest extends RequestBase { - - @Nullable private final Integer bytes; - - @Nullable private final String clusterManagerTimeout; - - @Nullable private final ExpandWildcards expandWildcards; - - @Nullable private final String format; - - @Nullable private final HealthStatus health; - - @Nullable private final Boolean includeUnloadedSegments; - - private final String index; - - @Nullable private final String masterTimeout; - - @Nullable private final Boolean pri; - - @Nullable private final String time; - - public GetCatIndicesWithIndexRequest(Builder builder) { - this.bytes = builder.bytes; - this.clusterManagerTimeout = builder.clusterManagerTimeout; - this.expandWildcards = builder.expandWildcards; - this.format = builder.format; - this.health = builder.health; - this.includeUnloadedSegments = builder.includeUnloadedSegments; - this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); - this.masterTimeout = builder.masterTimeout; - this.pri = builder.pri; - this.time = builder.time; - } - - public static GetCatIndicesWithIndexRequest of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final Integer bytes() { - return this.bytes; - } - - public final String clusterManagerTimeout() { - return this.clusterManagerTimeout; - } - - public final ExpandWildcards expandWildcards() { - return this.expandWildcards; - } - - public final String format() { - return this.format; - } - - public final HealthStatus health() { - return this.health; - } - - public final Boolean includeUnloadedSegments() { - return this.includeUnloadedSegments; - } - - public final String index() { - return this.index; - } - - public final String masterTimeout() { - return this.masterTimeout; - } - - public final Boolean pri() { - return this.pri; - } - - public final String time() { - return this.time; - } - - /** Builder for {@link GetCatIndicesWithIndexRequest}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private Integer bytes; - private String clusterManagerTimeout; - private ExpandWildcards expandWildcards; - private String format; - private HealthStatus health; - private Boolean includeUnloadedSegments; - private String index; - private String masterTimeout; - private Boolean pri; - private String time; - - public final Builder bytes(Integer value) { - this.bytes = value; - return this; - } - - public final Builder clusterManagerTimeout(String value) { - this.clusterManagerTimeout = value; - return this; - } - - public final Builder expandWildcards(ExpandWildcards value) { - this.expandWildcards = value; - return this; - } - - public final Builder format(String value) { - this.format = value; - return this; - } - - public final Builder health(HealthStatus value) { - this.health = value; - return this; - } - - public final Builder includeUnloadedSegments(Boolean value) { - this.includeUnloadedSegments = value; - return this; - } - - public final Builder index(String value) { - this.index = value; - return this; - } - - public final Builder masterTimeout(String value) { - this.masterTimeout = value; - return this; - } - - public final Builder pri(Boolean value) { - this.pri = value; - return this; - } - - public final Builder time(String value) { - this.time = value; - return this; - } - - /** - * Builds a {@link GetCatIndicesWithIndexRequest}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public GetCatIndicesWithIndexRequest build() { - _checkSingleUse(); - - return new GetCatIndicesWithIndexRequest(this); - } - } - - public static final Endpoint< - GetCatIndicesWithIndexRequest, GetCatIndicesWithIndexResponse, ErrorResponse> - _ENDPOINT = - new SimpleEndpoint<>( - // Request method - request -> { - return "get"; - }, - // Request path - request -> { - return "/_cat/indices/" + request.index + ""; - }, - // Request parameters - request -> { - Map params = new HashMap<>(); - if (request.bytes != null) { - params.put("bytes", String.valueOf(request.bytes)); - } - if (request.clusterManagerTimeout != null) { - params.put( - "cluster_manager_timeout", - request.clusterManagerTimeout); - } - if (request.expandWildcards != null) { - params.put( - "expand_wildcards", - request.expandWildcards.jsonValue()); - } - if (request.format != null) { - params.put("format", request.format); - } - if (request.health != null) { - params.put("health", request.health.jsonValue()); - } - if (request.includeUnloadedSegments != null) { - params.put( - "include_unloaded_segments", - String.valueOf(request.includeUnloadedSegments)); - } - if (request.masterTimeout != null) { - params.put("master_timeout", request.masterTimeout); - } - if (request.pri != null) { - params.put("pri", String.valueOf(request.pri)); - } - if (request.time != null) { - params.put("time", request.time); - } - return params; - }, - SimpleEndpoint.emptyMap(), - false, - GetCatIndicesWithIndexResponse._DESERIALIZER); -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexResponse.java deleted file mode 100644 index 8aad3408f1..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatIndicesWithIndexResponse.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class GetCatIndicesWithIndexResponse implements JsonpSerializable { - - public GetCatIndicesWithIndexResponse(Builder builder) {} - - public static GetCatIndicesWithIndexResponse of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {} - - /** Builder for {@link GetCatIndicesWithIndexResponse}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - - /** - * Builds a {@link GetCatIndicesWithIndexResponse}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public GetCatIndicesWithIndexResponse build() { - _checkSingleUse(); - - return new GetCatIndicesWithIndexResponse(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, - GetCatIndicesWithIndexResponse - ::setupGetCatIndicesWithIndexResponseDeserializer); - - protected static void setupGetCatIndicesWithIndexResponseDeserializer( - ObjectDeserializer op) {} -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesRequest.java deleted file mode 100644 index 9e236ca1f6..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesRequest.java +++ /dev/null @@ -1,186 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.opensearch._types.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; -import org.opensearch.client.util.*; -import java.util.*; -import java.util.function.Function; -import java.util.stream.*; -import javax.annotation.*; - -/** Returns basic statistics about performance of cluster nodes. */ -public class GetCatNodesRequest extends RequestBase { - - @Nullable private final Integer bytes; - - @Nullable private final String clusterManagerTimeout; - - @Nullable private final String format; - - @Nullable private final Boolean fullId; - - @Nullable private final Boolean includeUnloadedSegments; - - @Nullable private final Boolean local; - - @Nullable private final String masterTimeout; - - @Nullable private final String time; - - public GetCatNodesRequest(Builder builder) { - this.bytes = builder.bytes; - this.clusterManagerTimeout = builder.clusterManagerTimeout; - this.format = builder.format; - this.fullId = builder.fullId; - this.includeUnloadedSegments = builder.includeUnloadedSegments; - this.local = builder.local; - this.masterTimeout = builder.masterTimeout; - this.time = builder.time; - } - - public static GetCatNodesRequest of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final Integer bytes() { - return this.bytes; - } - - public final String clusterManagerTimeout() { - return this.clusterManagerTimeout; - } - - public final String format() { - return this.format; - } - - public final Boolean fullId() { - return this.fullId; - } - - public final Boolean includeUnloadedSegments() { - return this.includeUnloadedSegments; - } - - public final Boolean local() { - return this.local; - } - - public final String masterTimeout() { - return this.masterTimeout; - } - - public final String time() { - return this.time; - } - - /** Builder for {@link GetCatNodesRequest}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private Integer bytes; - private String clusterManagerTimeout; - private String format; - private Boolean fullId; - private Boolean includeUnloadedSegments; - private Boolean local; - private String masterTimeout; - private String time; - - public final Builder bytes(Integer value) { - this.bytes = value; - return this; - } - - public final Builder clusterManagerTimeout(String value) { - this.clusterManagerTimeout = value; - return this; - } - - public final Builder format(String value) { - this.format = value; - return this; - } - - public final Builder fullId(Boolean value) { - this.fullId = value; - return this; - } - - public final Builder includeUnloadedSegments(Boolean value) { - this.includeUnloadedSegments = value; - return this; - } - - public final Builder local(Boolean value) { - this.local = value; - return this; - } - - public final Builder masterTimeout(String value) { - this.masterTimeout = value; - return this; - } - - public final Builder time(String value) { - this.time = value; - return this; - } - - /** - * Builds a {@link GetCatNodesRequest}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public GetCatNodesRequest build() { - _checkSingleUse(); - - return new GetCatNodesRequest(this); - } - } - - public static final Endpoint _ENDPOINT = - new SimpleEndpoint<>( - // Request method - request -> { - return "get"; - }, - // Request path - request -> { - return "/_cat/nodes"; - }, - // Request parameters - request -> { - Map params = new HashMap<>(); - if (request.bytes != null) { - params.put("bytes", String.valueOf(request.bytes)); - } - if (request.clusterManagerTimeout != null) { - params.put("cluster_manager_timeout", request.clusterManagerTimeout); - } - if (request.format != null) { - params.put("format", request.format); - } - if (request.fullId != null) { - params.put("full_id", String.valueOf(request.fullId)); - } - if (request.includeUnloadedSegments != null) { - params.put( - "include_unloaded_segments", - String.valueOf(request.includeUnloadedSegments)); - } - if (request.local != null) { - params.put("local", String.valueOf(request.local)); - } - if (request.masterTimeout != null) { - params.put("master_timeout", request.masterTimeout); - } - if (request.time != null) { - params.put("time", request.time); - } - return params; - }, - SimpleEndpoint.emptyMap(), - false, - GetCatNodesResponse._DESERIALIZER); -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesResponse.java deleted file mode 100644 index 692abbaf60..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetCatNodesResponse.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class GetCatNodesResponse implements JsonpSerializable { - - public GetCatNodesResponse(Builder builder) {} - - public static GetCatNodesResponse of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {} - - /** Builder for {@link GetCatNodesResponse}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - - /** - * Builds a {@link GetCatNodesResponse}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public GetCatNodesResponse build() { - _checkSingleUse(); - - return new GetCatNodesResponse(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, GetCatNodesResponse::setupGetCatNodesResponseDeserializer); - - protected static void setupGetCatNodesResponseDeserializer( - ObjectDeserializer op) {} -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoRequest.java deleted file mode 100644 index 15d740edcc..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoRequest.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.opensearch._types.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; -import org.opensearch.client.util.*; -import java.util.*; -import java.util.function.Function; -import java.util.stream.*; -import javax.annotation.*; - -/** Returns whether the cluster is running. */ -public class GetClusterInfoRequest extends RequestBase { - - public GetClusterInfoRequest(Builder builder) {} - - public static GetClusterInfoRequest of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** Builder for {@link GetClusterInfoRequest}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - - /** - * Builds a {@link GetClusterInfoRequest}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public GetClusterInfoRequest build() { - _checkSingleUse(); - - return new GetClusterInfoRequest(this); - } - } - - public static final Endpoint - _ENDPOINT = - new SimpleEndpoint<>( - // Request method - request -> { - return "get"; - }, - // Request path - request -> { - return "/"; - }, - // Request parameters - request -> { - Map params = new HashMap<>(); - return params; - }, - SimpleEndpoint.emptyMap(), - false, - GetClusterInfoResponse._DESERIALIZER); -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoResponse.java deleted file mode 100644 index 65215b64b2..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterInfoResponse.java +++ /dev/null @@ -1,151 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class GetClusterInfoResponse implements JsonpSerializable { - - @Nullable private final String clusterName; - - @Nullable private final String clusterUuid; - - @Nullable private final String name; - - @Nullable private final String tagline; - - @Nullable private final Version version; - - public GetClusterInfoResponse(Builder builder) { - this.clusterName = builder.clusterName; - this.clusterUuid = builder.clusterUuid; - this.name = builder.name; - this.tagline = builder.tagline; - this.version = builder.version; - } - - public static GetClusterInfoResponse of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final String clusterName() { - return this.clusterName; - } - - public final String clusterUuid() { - return this.clusterUuid; - } - - public final String name() { - return this.name; - } - - public final String tagline() { - return this.tagline; - } - - public final Version version() { - return this.version; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.clusterName != null) { - generator.writeKey("cluster_name"); - generator.write(this.clusterName); - } - - if (this.clusterUuid != null) { - generator.writeKey("cluster_uuid"); - generator.write(this.clusterUuid); - } - - if (this.name != null) { - generator.writeKey("name"); - generator.write(this.name); - } - - if (this.tagline != null) { - generator.writeKey("tagline"); - generator.write(this.tagline); - } - - if (this.version != null) { - generator.writeKey("version"); - this.version.serialize(generator, mapper); - } - } - - /** Builder for {@link GetClusterInfoResponse}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private String clusterName; - private String clusterUuid; - private String name; - private String tagline; - private Version version; - - public final Builder clusterName(String value) { - this.clusterName = value; - return this; - } - - public final Builder clusterUuid(String value) { - this.clusterUuid = value; - return this; - } - - public final Builder name(String value) { - this.name = value; - return this; - } - - public final Builder tagline(String value) { - this.tagline = value; - return this; - } - - public final Builder version(Version value) { - this.version = value; - return this; - } - - public final Builder version(Function> fn) { - return version(fn.apply(new Version.Builder()).build()); - } - - /** - * Builds a {@link GetClusterInfoResponse}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public GetClusterInfoResponse build() { - _checkSingleUse(); - - return new GetClusterInfoResponse(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, GetClusterInfoResponse::setupGetClusterInfoResponseDeserializer); - - protected static void setupGetClusterInfoResponseDeserializer( - ObjectDeserializer op) { - op.add(Builder::clusterName, JsonpDeserializer.stringDeserializer(), "cluster_name"); - op.add(Builder::clusterUuid, JsonpDeserializer.stringDeserializer(), "cluster_uuid"); - op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); - op.add(Builder::tagline, JsonpDeserializer.stringDeserializer(), "tagline"); - op.add(Builder::version, Version._DESERIALIZER, "version"); - } -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsRequest.java deleted file mode 100644 index 6f237a27e0..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsRequest.java +++ /dev/null @@ -1,128 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.opensearch._types.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; -import org.opensearch.client.util.*; -import java.util.*; -import java.util.function.Function; -import java.util.stream.*; -import javax.annotation.*; - -/** Returns cluster settings. */ -public class GetClusterSettingsRequest extends RequestBase { - - @Nullable private final String clusterManagerTimeout; - - @Nullable private final Boolean flatSettings; - - @Nullable private final Boolean includeDefaults; - - @Nullable private final String masterTimeout; - - public GetClusterSettingsRequest(Builder builder) { - this.clusterManagerTimeout = builder.clusterManagerTimeout; - this.flatSettings = builder.flatSettings; - this.includeDefaults = builder.includeDefaults; - this.masterTimeout = builder.masterTimeout; - } - - public static GetClusterSettingsRequest of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final String clusterManagerTimeout() { - return this.clusterManagerTimeout; - } - - public final Boolean flatSettings() { - return this.flatSettings; - } - - public final Boolean includeDefaults() { - return this.includeDefaults; - } - - public final String masterTimeout() { - return this.masterTimeout; - } - - /** Builder for {@link GetClusterSettingsRequest}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private String clusterManagerTimeout; - private Boolean flatSettings; - private Boolean includeDefaults; - private String masterTimeout; - - public final Builder clusterManagerTimeout(String value) { - this.clusterManagerTimeout = value; - return this; - } - - public final Builder flatSettings(Boolean value) { - this.flatSettings = value; - return this; - } - - public final Builder includeDefaults(Boolean value) { - this.includeDefaults = value; - return this; - } - - public final Builder masterTimeout(String value) { - this.masterTimeout = value; - return this; - } - - /** - * Builds a {@link GetClusterSettingsRequest}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public GetClusterSettingsRequest build() { - _checkSingleUse(); - - return new GetClusterSettingsRequest(this); - } - } - - public static final Endpoint< - GetClusterSettingsRequest, GetClusterSettingsResponse, ErrorResponse> - _ENDPOINT = - new SimpleEndpoint<>( - // Request method - request -> { - return "get"; - }, - // Request path - request -> { - return "/_cluster/settings"; - }, - // Request parameters - request -> { - Map params = new HashMap<>(); - if (request.clusterManagerTimeout != null) { - params.put( - "cluster_manager_timeout", - request.clusterManagerTimeout); - } - if (request.flatSettings != null) { - params.put( - "flat_settings", String.valueOf(request.flatSettings)); - } - if (request.includeDefaults != null) { - params.put( - "include_defaults", - String.valueOf(request.includeDefaults)); - } - if (request.masterTimeout != null) { - params.put("master_timeout", request.masterTimeout); - } - return params; - }, - SimpleEndpoint.emptyMap(), - false, - GetClusterSettingsResponse._DESERIALIZER); -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsResponse.java deleted file mode 100644 index b4056e2214..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetClusterSettingsResponse.java +++ /dev/null @@ -1,149 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class GetClusterSettingsResponse implements JsonpSerializable { - - @Nullable private final Map defaults; - - @Nullable private final Map persistent; - - @Nullable private final Map transient_; - - public GetClusterSettingsResponse(Builder builder) { - this.defaults = ApiTypeHelper.unmodifiable(builder.defaults); - this.persistent = ApiTypeHelper.unmodifiable(builder.persistent); - this.transient_ = ApiTypeHelper.unmodifiable(builder.transient_); - } - - public static GetClusterSettingsResponse of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final Map defaults() { - return this.defaults; - } - - public final Map persistent() { - return this.persistent; - } - - public final Map transient_() { - return this.transient_; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (ApiTypeHelper.isDefined(this.defaults)) { - generator.writeKey("defaults"); - generator.writeStartObject(); - for (Map.Entry item0 : this.defaults.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - - if (ApiTypeHelper.isDefined(this.persistent)) { - generator.writeKey("persistent"); - generator.writeStartObject(); - for (Map.Entry item0 : this.persistent.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - - if (ApiTypeHelper.isDefined(this.transient_)) { - generator.writeKey("transient"); - generator.writeStartObject(); - for (Map.Entry item0 : this.transient_.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - } - - /** Builder for {@link GetClusterSettingsResponse}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private Map defaults; - private Map persistent; - private Map transient_; - - public final Builder defaults(Map map) { - this.defaults = _mapPutAll(this.defaults, map); - return this; - } - - public final Builder defaults(String key, JsonData value) { - this.defaults = _mapPut(this.defaults, key, value); - return this; - } - - public final Builder persistent(Map map) { - this.persistent = _mapPutAll(this.persistent, map); - return this; - } - - public final Builder persistent(String key, JsonData value) { - this.persistent = _mapPut(this.persistent, key, value); - return this; - } - - public final Builder transient_(Map map) { - this.transient_ = _mapPutAll(this.transient_, map); - return this; - } - - public final Builder transient_(String key, JsonData value) { - this.transient_ = _mapPut(this.transient_, key, value); - return this; - } - - /** - * Builds a {@link GetClusterSettingsResponse}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public GetClusterSettingsResponse build() { - _checkSingleUse(); - - return new GetClusterSettingsResponse(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, - GetClusterSettingsResponse::setupGetClusterSettingsResponseDeserializer); - - protected static void setupGetClusterSettingsResponseDeserializer( - ObjectDeserializer op) { - op.add( - Builder::defaults, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "defaults"); - op.add( - Builder::persistent, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "persistent"); - op.add( - Builder::transient_, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "transient"); - } -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java deleted file mode 100644 index 4b7e30786e..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocRequest.java +++ /dev/null @@ -1,245 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.opensearch._types.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; -import org.opensearch.client.util.*; -import java.util.*; -import java.util.function.Function; -import java.util.stream.*; -import javax.annotation.*; - -/** Returns a document */ -public class GetDocumentDocRequest extends RequestBase { - - private final String id; - - private final String index; - - @Nullable private final String preference; - - @Nullable private final Boolean realtime; - - @Nullable private final Boolean refresh; - - @Nullable private final String routing; - - @Nullable private final String source; - - @Nullable private final String sourceExcludes; - - @Nullable private final String sourceIncludes; - - @Nullable private final Boolean storedFields; - - @Nullable private final Integer version; - - @Nullable private final VersionType versionType; - - public GetDocumentDocRequest(Builder builder) { - this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); - this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); - this.preference = builder.preference; - this.realtime = builder.realtime; - this.refresh = builder.refresh; - this.routing = builder.routing; - this.source = builder.source; - this.sourceExcludes = builder.sourceExcludes; - this.sourceIncludes = builder.sourceIncludes; - this.storedFields = builder.storedFields; - this.version = builder.version; - this.versionType = builder.versionType; - } - - public static GetDocumentDocRequest of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final String id() { - return this.id; - } - - public final String index() { - return this.index; - } - - public final String preference() { - return this.preference; - } - - public final Boolean realtime() { - return this.realtime; - } - - public final Boolean refresh() { - return this.refresh; - } - - public final String routing() { - return this.routing; - } - - public final String source() { - return this.source; - } - - public final String sourceExcludes() { - return this.sourceExcludes; - } - - public final String sourceIncludes() { - return this.sourceIncludes; - } - - public final Boolean storedFields() { - return this.storedFields; - } - - public final Integer version() { - return this.version; - } - - public final VersionType versionType() { - return this.versionType; - } - - /** Builder for {@link GetDocumentDocRequest}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private String id; - private String index; - private String preference; - private Boolean realtime; - private Boolean refresh; - private String routing; - private String source; - private String sourceExcludes; - private String sourceIncludes; - private Boolean storedFields; - private Integer version; - private VersionType versionType; - - public final Builder id(String value) { - this.id = value; - return this; - } - - public final Builder index(String value) { - this.index = value; - return this; - } - - public final Builder preference(String value) { - this.preference = value; - return this; - } - - public final Builder realtime(Boolean value) { - this.realtime = value; - return this; - } - - public final Builder refresh(Boolean value) { - this.refresh = value; - return this; - } - - public final Builder routing(String value) { - this.routing = value; - return this; - } - - public final Builder source(String value) { - this.source = value; - return this; - } - - public final Builder sourceExcludes(String value) { - this.sourceExcludes = value; - return this; - } - - public final Builder sourceIncludes(String value) { - this.sourceIncludes = value; - return this; - } - - public final Builder storedFields(Boolean value) { - this.storedFields = value; - return this; - } - - public final Builder version(Integer value) { - this.version = value; - return this; - } - - public final Builder versionType(VersionType value) { - this.versionType = value; - return this; - } - - /** - * Builds a {@link GetDocumentDocRequest}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public GetDocumentDocRequest build() { - _checkSingleUse(); - - return new GetDocumentDocRequest(this); - } - } - - public static final Endpoint - _ENDPOINT = - new SimpleEndpoint<>( - // Request method - request -> { - return "get"; - }, - // Request path - request -> { - return "/" + request.index + "/_doc/" + request.id + ""; - }, - // Request parameters - request -> { - Map params = new HashMap<>(); - if (request.preference != null) { - params.put("preference", request.preference); - } - if (request.realtime != null) { - params.put("realtime", String.valueOf(request.realtime)); - } - if (request.refresh != null) { - params.put("refresh", String.valueOf(request.refresh)); - } - if (request.routing != null) { - params.put("routing", request.routing); - } - if (request.source != null) { - params.put("_source", request.source); - } - if (request.sourceExcludes != null) { - params.put("_source_excludes", request.sourceExcludes); - } - if (request.sourceIncludes != null) { - params.put("_source_includes", request.sourceIncludes); - } - if (request.storedFields != null) { - params.put( - "stored_fields", String.valueOf(request.storedFields)); - } - if (request.version != null) { - params.put("version", String.valueOf(request.version)); - } - if (request.versionType != null) { - params.put("version_type", request.versionType.jsonValue()); - } - return params; - }, - SimpleEndpoint.emptyMap(), - false, - GetDocumentDocResponse._DESERIALIZER); -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocResponse.java deleted file mode 100644 index ac03241abe..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentDocResponse.java +++ /dev/null @@ -1,262 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class GetDocumentDocResponse implements JsonpSerializable { - - @Nullable private final Map fields; - - private final boolean found; - - private final String id; - - private final String index; - - @Nullable private final Long primaryTerm; - - @Nullable private final String routing; - - @Nullable private final Long seqNo; - - @Nullable private final Map source; - - @Nullable private final String type; - - @Nullable private final Integer version; - - public GetDocumentDocResponse(Builder builder) { - this.fields = ApiTypeHelper.unmodifiable(builder.fields); - this.found = ApiTypeHelper.requireNonNull(builder.found, this, "found"); - this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); - this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); - this.primaryTerm = builder.primaryTerm; - this.routing = builder.routing; - this.seqNo = builder.seqNo; - this.source = ApiTypeHelper.unmodifiable(builder.source); - this.type = builder.type; - this.version = builder.version; - } - - public static GetDocumentDocResponse of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final Map fields() { - return this.fields; - } - - public final boolean found() { - return this.found; - } - - public final String id() { - return this.id; - } - - public final String index() { - return this.index; - } - - public final Long primaryTerm() { - return this.primaryTerm; - } - - public final String routing() { - return this.routing; - } - - public final Long seqNo() { - return this.seqNo; - } - - public final Map source() { - return this.source; - } - - public final String type() { - return this.type; - } - - public final Integer version() { - return this.version; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (ApiTypeHelper.isDefined(this.fields)) { - generator.writeKey("_fields"); - generator.writeStartObject(); - for (Map.Entry item0 : this.fields.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - - generator.writeKey("found"); - generator.write(this.found); - - generator.writeKey("_id"); - generator.write(this.id); - - generator.writeKey("_index"); - generator.write(this.index); - - if (this.primaryTerm != null) { - generator.writeKey("primary_term"); - generator.write(this.primaryTerm); - } - - if (this.routing != null) { - generator.writeKey("_routing"); - generator.write(this.routing); - } - - if (this.seqNo != null) { - generator.writeKey("seq_no"); - generator.write(this.seqNo); - } - - if (ApiTypeHelper.isDefined(this.source)) { - generator.writeKey("_source"); - generator.writeStartObject(); - for (Map.Entry item0 : this.source.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - - if (this.type != null) { - generator.writeKey("_type"); - generator.write(this.type); - } - - if (this.version != null) { - generator.writeKey("version"); - generator.write(this.version); - } - } - - /** Builder for {@link GetDocumentDocResponse}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private Map fields; - private Boolean found; - private String id; - private String index; - private Long primaryTerm; - private String routing; - private Long seqNo; - private Map source; - private String type; - private Integer version; - - public final Builder fields(Map map) { - this.fields = _mapPutAll(this.fields, map); - return this; - } - - public final Builder fields(String key, JsonData value) { - this.fields = _mapPut(this.fields, key, value); - return this; - } - - public final Builder found(boolean value) { - this.found = value; - return this; - } - - public final Builder id(String value) { - this.id = value; - return this; - } - - public final Builder index(String value) { - this.index = value; - return this; - } - - public final Builder primaryTerm(Long value) { - this.primaryTerm = value; - return this; - } - - public final Builder routing(String value) { - this.routing = value; - return this; - } - - public final Builder seqNo(Long value) { - this.seqNo = value; - return this; - } - - public final Builder source(Map map) { - this.source = _mapPutAll(this.source, map); - return this; - } - - public final Builder source(String key, JsonData value) { - this.source = _mapPut(this.source, key, value); - return this; - } - - public final Builder type(String value) { - this.type = value; - return this; - } - - public final Builder version(Integer value) { - this.version = value; - return this; - } - - /** - * Builds a {@link GetDocumentDocResponse}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public GetDocumentDocResponse build() { - _checkSingleUse(); - - return new GetDocumentDocResponse(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, GetDocumentDocResponse::setupGetDocumentDocResponseDeserializer); - - protected static void setupGetDocumentDocResponseDeserializer( - ObjectDeserializer op) { - op.add( - Builder::fields, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "_fields"); - op.add(Builder::found, JsonpDeserializer.booleanDeserializer(), "found"); - op.add(Builder::id, JsonpDeserializer.stringDeserializer(), "_id"); - op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "_index"); - op.add(Builder::primaryTerm, JsonpDeserializer.longDeserializer(), "primary_term"); - op.add(Builder::routing, JsonpDeserializer.stringDeserializer(), "_routing"); - op.add(Builder::seqNo, JsonpDeserializer.longDeserializer(), "seq_no"); - op.add( - Builder::source, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "_source"); - op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "_type"); - op.add(Builder::version, JsonpDeserializer.integerDeserializer(), "version"); - } -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java deleted file mode 100644 index 27763382f0..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceRequest.java +++ /dev/null @@ -1,245 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.opensearch._types.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; -import org.opensearch.client.util.*; -import java.util.*; -import java.util.function.Function; -import java.util.stream.*; -import javax.annotation.*; - -/** Returns a document. */ -public class GetDocumentSourceRequest extends RequestBase { - - private final String id; - - private final String index; - - @Nullable private final String preference; - - @Nullable private final Boolean realtime; - - @Nullable private final Boolean refresh; - - @Nullable private final String routing; - - @Nullable private final String source; - - @Nullable private final String sourceExcludes; - - @Nullable private final String sourceIncludes; - - @Nullable private final Boolean storedFields; - - @Nullable private final Integer version; - - @Nullable private final VersionType versionType; - - public GetDocumentSourceRequest(Builder builder) { - this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); - this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); - this.preference = builder.preference; - this.realtime = builder.realtime; - this.refresh = builder.refresh; - this.routing = builder.routing; - this.source = builder.source; - this.sourceExcludes = builder.sourceExcludes; - this.sourceIncludes = builder.sourceIncludes; - this.storedFields = builder.storedFields; - this.version = builder.version; - this.versionType = builder.versionType; - } - - public static GetDocumentSourceRequest of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final String id() { - return this.id; - } - - public final String index() { - return this.index; - } - - public final String preference() { - return this.preference; - } - - public final Boolean realtime() { - return this.realtime; - } - - public final Boolean refresh() { - return this.refresh; - } - - public final String routing() { - return this.routing; - } - - public final String source() { - return this.source; - } - - public final String sourceExcludes() { - return this.sourceExcludes; - } - - public final String sourceIncludes() { - return this.sourceIncludes; - } - - public final Boolean storedFields() { - return this.storedFields; - } - - public final Integer version() { - return this.version; - } - - public final VersionType versionType() { - return this.versionType; - } - - /** Builder for {@link GetDocumentSourceRequest}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private String id; - private String index; - private String preference; - private Boolean realtime; - private Boolean refresh; - private String routing; - private String source; - private String sourceExcludes; - private String sourceIncludes; - private Boolean storedFields; - private Integer version; - private VersionType versionType; - - public final Builder id(String value) { - this.id = value; - return this; - } - - public final Builder index(String value) { - this.index = value; - return this; - } - - public final Builder preference(String value) { - this.preference = value; - return this; - } - - public final Builder realtime(Boolean value) { - this.realtime = value; - return this; - } - - public final Builder refresh(Boolean value) { - this.refresh = value; - return this; - } - - public final Builder routing(String value) { - this.routing = value; - return this; - } - - public final Builder source(String value) { - this.source = value; - return this; - } - - public final Builder sourceExcludes(String value) { - this.sourceExcludes = value; - return this; - } - - public final Builder sourceIncludes(String value) { - this.sourceIncludes = value; - return this; - } - - public final Builder storedFields(Boolean value) { - this.storedFields = value; - return this; - } - - public final Builder version(Integer value) { - this.version = value; - return this; - } - - public final Builder versionType(VersionType value) { - this.versionType = value; - return this; - } - - /** - * Builds a {@link GetDocumentSourceRequest}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public GetDocumentSourceRequest build() { - _checkSingleUse(); - - return new GetDocumentSourceRequest(this); - } - } - - public static final Endpoint - _ENDPOINT = - new SimpleEndpoint<>( - // Request method - request -> { - return "get"; - }, - // Request path - request -> { - return "/" + request.index + "/_source/" + request.id + ""; - }, - // Request parameters - request -> { - Map params = new HashMap<>(); - if (request.preference != null) { - params.put("preference", request.preference); - } - if (request.realtime != null) { - params.put("realtime", String.valueOf(request.realtime)); - } - if (request.refresh != null) { - params.put("refresh", String.valueOf(request.refresh)); - } - if (request.routing != null) { - params.put("routing", request.routing); - } - if (request.source != null) { - params.put("_source", request.source); - } - if (request.sourceExcludes != null) { - params.put("_source_excludes", request.sourceExcludes); - } - if (request.sourceIncludes != null) { - params.put("_source_includes", request.sourceIncludes); - } - if (request.storedFields != null) { - params.put( - "stored_fields", String.valueOf(request.storedFields)); - } - if (request.version != null) { - params.put("version", String.valueOf(request.version)); - } - if (request.versionType != null) { - params.put("version_type", request.versionType.jsonValue()); - } - return params; - }, - SimpleEndpoint.emptyMap(), - false, - GetDocumentSourceResponse._DESERIALIZER); -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceResponse.java deleted file mode 100644 index 4152aef63c..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetDocumentSourceResponse.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class GetDocumentSourceResponse implements JsonpSerializable { - - public GetDocumentSourceResponse(Builder builder) {} - - public static GetDocumentSourceResponse of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {} - - /** Builder for {@link GetDocumentSourceResponse}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - - /** - * Builds a {@link GetDocumentSourceResponse}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public GetDocumentSourceResponse build() { - _checkSingleUse(); - - return new GetDocumentSourceResponse(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, - GetDocumentSourceResponse::setupGetDocumentSourceResponseDeserializer); - - protected static void setupGetDocumentSourceResponseDeserializer( - ObjectDeserializer op) {} -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java deleted file mode 100644 index d31a44b253..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexRequest.java +++ /dev/null @@ -1,208 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.opensearch._types.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; -import org.opensearch.client.util.*; -import java.util.*; -import java.util.function.Function; -import java.util.stream.*; -import javax.annotation.*; - -/** The get settings API operation returns all the settings in your index. */ -public class GetSettingsIndexRequest extends RequestBase { - - @Nullable private final Boolean allowNoIndices; - - @Nullable private final String clusterManagerTimeout; - - @Nullable private final ExpandWildcards expandWildcards; - - @Nullable private final Boolean flatSettings; - - @Nullable private final Boolean ignoreUnavailable; - - @Nullable private final String includeDefaults; - - private final String index; - - @Nullable private final Boolean local; - - @Nullable private final String masterTimeout; - - public GetSettingsIndexRequest(Builder builder) { - this.allowNoIndices = builder.allowNoIndices; - this.clusterManagerTimeout = builder.clusterManagerTimeout; - this.expandWildcards = builder.expandWildcards; - this.flatSettings = builder.flatSettings; - this.ignoreUnavailable = builder.ignoreUnavailable; - this.includeDefaults = builder.includeDefaults; - this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); - this.local = builder.local; - this.masterTimeout = builder.masterTimeout; - } - - public static GetSettingsIndexRequest of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final Boolean allowNoIndices() { - return this.allowNoIndices; - } - - public final String clusterManagerTimeout() { - return this.clusterManagerTimeout; - } - - public final ExpandWildcards expandWildcards() { - return this.expandWildcards; - } - - public final Boolean flatSettings() { - return this.flatSettings; - } - - public final Boolean ignoreUnavailable() { - return this.ignoreUnavailable; - } - - public final String includeDefaults() { - return this.includeDefaults; - } - - public final String index() { - return this.index; - } - - public final Boolean local() { - return this.local; - } - - public final String masterTimeout() { - return this.masterTimeout; - } - - /** Builder for {@link GetSettingsIndexRequest}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private Boolean allowNoIndices; - private String clusterManagerTimeout; - private ExpandWildcards expandWildcards; - private Boolean flatSettings; - private Boolean ignoreUnavailable; - private String includeDefaults; - private String index; - private Boolean local; - private String masterTimeout; - - public final Builder allowNoIndices(Boolean value) { - this.allowNoIndices = value; - return this; - } - - public final Builder clusterManagerTimeout(String value) { - this.clusterManagerTimeout = value; - return this; - } - - public final Builder expandWildcards(ExpandWildcards value) { - this.expandWildcards = value; - return this; - } - - public final Builder flatSettings(Boolean value) { - this.flatSettings = value; - return this; - } - - public final Builder ignoreUnavailable(Boolean value) { - this.ignoreUnavailable = value; - return this; - } - - public final Builder includeDefaults(String value) { - this.includeDefaults = value; - return this; - } - - public final Builder index(String value) { - this.index = value; - return this; - } - - public final Builder local(Boolean value) { - this.local = value; - return this; - } - - public final Builder masterTimeout(String value) { - this.masterTimeout = value; - return this; - } - - /** - * Builds a {@link GetSettingsIndexRequest}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public GetSettingsIndexRequest build() { - _checkSingleUse(); - - return new GetSettingsIndexRequest(this); - } - } - - public static final Endpoint - _ENDPOINT = - new SimpleEndpoint<>( - // Request method - request -> { - return "get"; - }, - // Request path - request -> { - return "/" + request.index + "/_settings"; - }, - // Request parameters - request -> { - Map params = new HashMap<>(); - if (request.allowNoIndices != null) { - params.put( - "allow_no_indices", - String.valueOf(request.allowNoIndices)); - } - if (request.clusterManagerTimeout != null) { - params.put( - "cluster_manager_timeout", - request.clusterManagerTimeout); - } - if (request.expandWildcards != null) { - params.put( - "expand_wildcards", - request.expandWildcards.jsonValue()); - } - if (request.flatSettings != null) { - params.put( - "flat_settings", String.valueOf(request.flatSettings)); - } - if (request.ignoreUnavailable != null) { - params.put( - "ignore_unavailable", - String.valueOf(request.ignoreUnavailable)); - } - if (request.includeDefaults != null) { - params.put("include_defaults", request.includeDefaults); - } - if (request.local != null) { - params.put("local", String.valueOf(request.local)); - } - if (request.masterTimeout != null) { - params.put("master_timeout", request.masterTimeout); - } - return params; - }, - SimpleEndpoint.emptyMap(), - false, - GetSettingsIndexResponse._DESERIALIZER); -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexResponse.java deleted file mode 100644 index 34c05cbdc6..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexResponse.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class GetSettingsIndexResponse implements JsonpSerializable { - - public GetSettingsIndexResponse(Builder builder) {} - - public static GetSettingsIndexResponse of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {} - - /** Builder for {@link GetSettingsIndexResponse}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - - /** - * Builds a {@link GetSettingsIndexResponse}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public GetSettingsIndexResponse build() { - _checkSingleUse(); - - return new GetSettingsIndexResponse(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, - GetSettingsIndexResponse::setupGetSettingsIndexResponseDeserializer); - - protected static void setupGetSettingsIndexResponseDeserializer( - ObjectDeserializer op) {} -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java deleted file mode 100644 index 2e47d66451..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingRequest.java +++ /dev/null @@ -1,222 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.opensearch._types.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; -import org.opensearch.client.util.*; -import java.util.*; -import java.util.function.Function; -import java.util.stream.*; -import javax.annotation.*; - -/** The get settings API operation returns all the settings in your index. */ -public class GetSettingsIndexSettingRequest extends RequestBase { - - @Nullable private final Boolean allowNoIndices; - - @Nullable private final String clusterManagerTimeout; - - @Nullable private final ExpandWildcards expandWildcards; - - @Nullable private final Boolean flatSettings; - - @Nullable private final Boolean ignoreUnavailable; - - @Nullable private final String includeDefaults; - - private final String index; - - @Nullable private final Boolean local; - - @Nullable private final String masterTimeout; - - private final String setting; - - public GetSettingsIndexSettingRequest(Builder builder) { - this.allowNoIndices = builder.allowNoIndices; - this.clusterManagerTimeout = builder.clusterManagerTimeout; - this.expandWildcards = builder.expandWildcards; - this.flatSettings = builder.flatSettings; - this.ignoreUnavailable = builder.ignoreUnavailable; - this.includeDefaults = builder.includeDefaults; - this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); - this.local = builder.local; - this.masterTimeout = builder.masterTimeout; - this.setting = ApiTypeHelper.requireNonNull(builder.setting, this, "setting"); - } - - public static GetSettingsIndexSettingRequest of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final Boolean allowNoIndices() { - return this.allowNoIndices; - } - - public final String clusterManagerTimeout() { - return this.clusterManagerTimeout; - } - - public final ExpandWildcards expandWildcards() { - return this.expandWildcards; - } - - public final Boolean flatSettings() { - return this.flatSettings; - } - - public final Boolean ignoreUnavailable() { - return this.ignoreUnavailable; - } - - public final String includeDefaults() { - return this.includeDefaults; - } - - public final String index() { - return this.index; - } - - public final Boolean local() { - return this.local; - } - - public final String masterTimeout() { - return this.masterTimeout; - } - - public final String setting() { - return this.setting; - } - - /** Builder for {@link GetSettingsIndexSettingRequest}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private Boolean allowNoIndices; - private String clusterManagerTimeout; - private ExpandWildcards expandWildcards; - private Boolean flatSettings; - private Boolean ignoreUnavailable; - private String includeDefaults; - private String index; - private Boolean local; - private String masterTimeout; - private String setting; - - public final Builder allowNoIndices(Boolean value) { - this.allowNoIndices = value; - return this; - } - - public final Builder clusterManagerTimeout(String value) { - this.clusterManagerTimeout = value; - return this; - } - - public final Builder expandWildcards(ExpandWildcards value) { - this.expandWildcards = value; - return this; - } - - public final Builder flatSettings(Boolean value) { - this.flatSettings = value; - return this; - } - - public final Builder ignoreUnavailable(Boolean value) { - this.ignoreUnavailable = value; - return this; - } - - public final Builder includeDefaults(String value) { - this.includeDefaults = value; - return this; - } - - public final Builder index(String value) { - this.index = value; - return this; - } - - public final Builder local(Boolean value) { - this.local = value; - return this; - } - - public final Builder masterTimeout(String value) { - this.masterTimeout = value; - return this; - } - - public final Builder setting(String value) { - this.setting = value; - return this; - } - - /** - * Builds a {@link GetSettingsIndexSettingRequest}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public GetSettingsIndexSettingRequest build() { - _checkSingleUse(); - - return new GetSettingsIndexSettingRequest(this); - } - } - - public static final Endpoint< - GetSettingsIndexSettingRequest, GetSettingsIndexSettingResponse, ErrorResponse> - _ENDPOINT = - new SimpleEndpoint<>( - // Request method - request -> { - return "get"; - }, - // Request path - request -> { - return "/" + request.index + "/_settings/" + request.setting + ""; - }, - // Request parameters - request -> { - Map params = new HashMap<>(); - if (request.allowNoIndices != null) { - params.put( - "allow_no_indices", - String.valueOf(request.allowNoIndices)); - } - if (request.clusterManagerTimeout != null) { - params.put( - "cluster_manager_timeout", - request.clusterManagerTimeout); - } - if (request.expandWildcards != null) { - params.put( - "expand_wildcards", - request.expandWildcards.jsonValue()); - } - if (request.flatSettings != null) { - params.put( - "flat_settings", String.valueOf(request.flatSettings)); - } - if (request.ignoreUnavailable != null) { - params.put( - "ignore_unavailable", - String.valueOf(request.ignoreUnavailable)); - } - if (request.includeDefaults != null) { - params.put("include_defaults", request.includeDefaults); - } - if (request.local != null) { - params.put("local", String.valueOf(request.local)); - } - if (request.masterTimeout != null) { - params.put("master_timeout", request.masterTimeout); - } - return params; - }, - SimpleEndpoint.emptyMap(), - false, - GetSettingsIndexSettingResponse._DESERIALIZER); -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingResponse.java deleted file mode 100644 index 48f11fc6a4..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/GetSettingsIndexSettingResponse.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class GetSettingsIndexSettingResponse implements JsonpSerializable { - - public GetSettingsIndexSettingResponse(Builder builder) {} - - public static GetSettingsIndexSettingResponse of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {} - - /** Builder for {@link GetSettingsIndexSettingResponse}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - - /** - * Builds a {@link GetSettingsIndexSettingResponse}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public GetSettingsIndexSettingResponse build() { - _checkSingleUse(); - - return new GetSettingsIndexSettingResponse(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, - GetSettingsIndexSettingResponse - ::setupGetSettingsIndexSettingResponseDeserializer); - - protected static void setupGetSettingsIndexSettingResponseDeserializer( - ObjectDeserializer op) {} -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/HealthStatus.java b/java-client/src/generated/java/org/opensearch/client/opensearch/HealthStatus.java deleted file mode 100644 index 6bea21054d..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/HealthStatus.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.JsonEnum; -import org.opensearch.client.json.JsonpDeserializable; - -@JsonpDeserializable -public enum HealthStatus implements JsonEnum { - Green("green"), - Yellow("yellow"), - Red("red"), - ; - - private final String jsonValue; - private final String[] aliases; - - HealthStatus(String jsonValue, String... aliases) { - this.jsonValue = jsonValue; - this.aliases = aliases; - } - - public String jsonValue() { - return this.jsonValue; - } - - public String[] aliases() { - return this.aliases; - } - - public static final JsonEnum.Deserializer _DESERIALIZER = - new JsonEnum.Deserializer<>(HealthStatus.values()); -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/Hits.java b/java-client/src/generated/java/org/opensearch/client/opensearch/Hits.java deleted file mode 100644 index 5c5ea165f6..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/Hits.java +++ /dev/null @@ -1,162 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class Hits implements JsonpSerializable { - - @Nullable private final JsonData fields; - - @Nullable private final String id; - - @Nullable private final String index; - - @Nullable private final Float score; - - @Nullable private final JsonData source; - - @Nullable private final String type; - - public Hits(Builder builder) { - this.fields = builder.fields; - this.id = builder.id; - this.index = builder.index; - this.score = builder.score; - this.source = builder.source; - this.type = builder.type; - } - - public static Hits of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final JsonData fields() { - return this.fields; - } - - public final String id() { - return this.id; - } - - public final String index() { - return this.index; - } - - public final Float score() { - return this.score; - } - - public final JsonData source() { - return this.source; - } - - public final String type() { - return this.type; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.fields != null) { - generator.writeKey("fields"); - this.fields.serialize(generator, mapper); - } - - if (this.id != null) { - generator.writeKey("_id"); - generator.write(this.id); - } - - if (this.index != null) { - generator.writeKey("_index"); - generator.write(this.index); - } - - if (this.score != null) { - generator.writeKey("_score"); - generator.write(this.score); - } - - if (this.source != null) { - generator.writeKey("_source"); - this.source.serialize(generator, mapper); - } - - if (this.type != null) { - generator.writeKey("_type"); - generator.write(this.type); - } - } - - /** Builder for {@link Hits}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private JsonData fields; - private String id; - private String index; - private Float score; - private JsonData source; - private String type; - - public final Builder fields(JsonData value) { - this.fields = value; - return this; - } - - public final Builder id(String value) { - this.id = value; - return this; - } - - public final Builder index(String value) { - this.index = value; - return this; - } - - public final Builder score(Float value) { - this.score = value; - return this; - } - - public final Builder source(JsonData value) { - this.source = value; - return this; - } - - public final Builder type(String value) { - this.type = value; - return this; - } - - /** - * Builds a {@link Hits}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public Hits build() { - _checkSingleUse(); - - return new Hits(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy(Builder::new, Hits::setupHitsDeserializer); - - protected static void setupHitsDeserializer(ObjectDeserializer op) { - op.add(Builder::fields, JsonData._DESERIALIZER, "fields"); - op.add(Builder::id, JsonpDeserializer.stringDeserializer(), "_id"); - op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "_index"); - op.add(Builder::score, JsonpDeserializer.floatDeserializer(), "_score"); - op.add(Builder::source, JsonData._DESERIALIZER, "_source"); - op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "_type"); - } -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/HitsMetadata.java b/java-client/src/generated/java/org/opensearch/client/opensearch/HitsMetadata.java deleted file mode 100644 index 9ec65d9054..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/HitsMetadata.java +++ /dev/null @@ -1,124 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class HitsMetadata implements JsonpSerializable { - - @Nullable private final List hits; - - @Nullable private final Double maxScore; - - @Nullable private final Total total; - - public HitsMetadata(Builder builder) { - this.hits = ApiTypeHelper.unmodifiable(builder.hits); - this.maxScore = builder.maxScore; - this.total = builder.total; - } - - public static HitsMetadata of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final List hits() { - return this.hits; - } - - public final Double maxScore() { - return this.maxScore; - } - - public final Total total() { - return this.total; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (ApiTypeHelper.isDefined(this.hits)) { - generator.writeKey("hits"); - generator.writeStartArray(); - for (Hits item0 : this.hits) { - item0.serialize(generator, mapper); - } - generator.writeEnd(); - } - - if (this.maxScore != null) { - generator.writeKey("max_score"); - generator.write(this.maxScore); - } - - if (this.total != null) { - generator.writeKey("total"); - this.total.serialize(generator, mapper); - } - } - - /** Builder for {@link HitsMetadata}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private List hits; - private Double maxScore; - private Total total; - - public final Builder hits(List list) { - this.hits = _listAddAll(this.hits, list); - return this; - } - - public final Builder hits(Hits value, Hits... values) { - this.hits = _listAdd(this.hits, value, values); - return this; - } - - public final Builder hits(Function> fn) { - return hits(fn.apply(new Hits.Builder()).build()); - } - - public final Builder maxScore(Double value) { - this.maxScore = value; - return this; - } - - public final Builder total(Total value) { - this.total = value; - return this; - } - - public final Builder total(Function> fn) { - return total(fn.apply(new Total.Builder()).build()); - } - - /** - * Builds a {@link HitsMetadata}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public HitsMetadata build() { - _checkSingleUse(); - - return new HitsMetadata(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, HitsMetadata::setupHitsMetadataDeserializer); - - protected static void setupHitsMetadataDeserializer( - ObjectDeserializer op) { - op.add(Builder::hits, JsonpDeserializer.arrayDeserializer(Hits._DESERIALIZER), "hits"); - op.add(Builder::maxScore, JsonpDeserializer.doubleDeserializer(), "max_score"); - op.add(Builder::total, Total._DESERIALIZER, "total"); - } -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java b/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java deleted file mode 100644 index 25b20708ea..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java +++ /dev/null @@ -1,340 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.ApiClient; -import org.opensearch.client.opensearch._types.OpenSearchException; -import org.opensearch.client.opensearch._types.ErrorResponse; -import org.opensearch.client.transport.OpenSearchTransport; -import org.opensearch.client.transport.JsonEndpoint; -import org.opensearch.client.transport.TransportOptions; -import org.opensearch.client.util.ObjectBuilder; -import java.io.IOException; -import java.util.concurrent.CompletableFuture; -import java.util.function.Function; -import javax.annotation.Nullable; - -public class OpenSearchAsyncClient extends ApiClient { - public OpenSearchAsyncClient(OpenSearchTransport transport) { - super(transport, null); - } - - public OpenSearchAsyncClient( - OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { - super(transport, transportOptions); - } - - @Override - public OpenSearchAsyncClient withTransportOptions(@Nullable TransportOptions transportOptions) { - return new OpenSearchAsyncClient(this.transport, transportOptions); - } - - public CompletableFuture deleteIndex(DeleteIndexRequest request) - throws IOException, OpenSearchException { - JsonEndpoint endpoint = - (JsonEndpoint) - DeleteIndexRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - public final CompletableFuture deleteIndex( - Function> fn) - throws IOException, OpenSearchException { - return deleteIndex(fn.apply(new DeleteIndexRequest.Builder()).build()); - } - - public CompletableFuture getCatIndices(GetCatIndicesRequest request) - throws IOException, OpenSearchException { - JsonEndpoint endpoint = - (JsonEndpoint) - GetCatIndicesRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - public final CompletableFuture getCatIndices( - Function> fn) - throws IOException, OpenSearchException { - return getCatIndices(fn.apply(new GetCatIndicesRequest.Builder()).build()); - } - - public CompletableFuture getCatIndicesWithIndex( - GetCatIndicesWithIndexRequest request) throws IOException, OpenSearchException { - JsonEndpoint - endpoint = - (JsonEndpoint< - GetCatIndicesWithIndexRequest, - GetCatIndicesWithIndexResponse, - ErrorResponse>) - GetCatIndicesWithIndexRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - public final CompletableFuture getCatIndicesWithIndex( - Function< - GetCatIndicesWithIndexRequest.Builder, - ObjectBuilder> - fn) - throws IOException, OpenSearchException { - return getCatIndicesWithIndex( - fn.apply(new GetCatIndicesWithIndexRequest.Builder()).build()); - } - - public CompletableFuture getCatNodes(GetCatNodesRequest request) - throws IOException, OpenSearchException { - JsonEndpoint endpoint = - (JsonEndpoint) - GetCatNodesRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - public final CompletableFuture getCatNodes( - Function> fn) - throws IOException, OpenSearchException { - return getCatNodes(fn.apply(new GetCatNodesRequest.Builder()).build()); - } - - public CompletableFuture getClusterInfo(GetClusterInfoRequest request) - throws IOException, OpenSearchException { - JsonEndpoint endpoint = - (JsonEndpoint) - GetClusterInfoRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - public final CompletableFuture getClusterInfo( - Function> fn) - throws IOException, OpenSearchException { - return getClusterInfo(fn.apply(new GetClusterInfoRequest.Builder()).build()); - } - - public CompletableFuture getClusterSettings( - GetClusterSettingsRequest request) throws IOException, OpenSearchException { - JsonEndpoint - endpoint = - (JsonEndpoint< - GetClusterSettingsRequest, - GetClusterSettingsResponse, - ErrorResponse>) - GetClusterSettingsRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - public final CompletableFuture getClusterSettings( - Function> - fn) - throws IOException, OpenSearchException { - return getClusterSettings(fn.apply(new GetClusterSettingsRequest.Builder()).build()); - } - - public CompletableFuture getDocumentDoc(GetDocumentDocRequest request) - throws IOException, OpenSearchException { - JsonEndpoint endpoint = - (JsonEndpoint) - GetDocumentDocRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - public final CompletableFuture getDocumentDoc( - Function> fn) - throws IOException, OpenSearchException { - return getDocumentDoc(fn.apply(new GetDocumentDocRequest.Builder()).build()); - } - - public CompletableFuture getDocumentSource( - GetDocumentSourceRequest request) throws IOException, OpenSearchException { - JsonEndpoint endpoint = - (JsonEndpoint) - GetDocumentSourceRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - public final CompletableFuture getDocumentSource( - Function> fn) - throws IOException, OpenSearchException { - return getDocumentSource(fn.apply(new GetDocumentSourceRequest.Builder()).build()); - } - - public CompletableFuture getSettingsIndex( - GetSettingsIndexRequest request) throws IOException, OpenSearchException { - JsonEndpoint endpoint = - (JsonEndpoint) - GetSettingsIndexRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - public final CompletableFuture getSettingsIndex( - Function> fn) - throws IOException, OpenSearchException { - return getSettingsIndex(fn.apply(new GetSettingsIndexRequest.Builder()).build()); - } - - public CompletableFuture getSettingsIndexSetting( - GetSettingsIndexSettingRequest request) throws IOException, OpenSearchException { - JsonEndpoint - endpoint = - (JsonEndpoint< - GetSettingsIndexSettingRequest, - GetSettingsIndexSettingResponse, - ErrorResponse>) - GetSettingsIndexSettingRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - public final CompletableFuture getSettingsIndexSetting( - Function< - GetSettingsIndexSettingRequest.Builder, - ObjectBuilder> - fn) - throws IOException, OpenSearchException { - return getSettingsIndexSetting( - fn.apply(new GetSettingsIndexSettingRequest.Builder()).build()); - } - - public CompletableFuture postAliases(PostAliasesRequest request) - throws IOException, OpenSearchException { - JsonEndpoint endpoint = - (JsonEndpoint) - PostAliasesRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - public final CompletableFuture postAliases( - Function> fn) - throws IOException, OpenSearchException { - return postAliases(fn.apply(new PostAliasesRequest.Builder()).build()); - } - - public CompletableFuture postRemoteStoreRestore( - PostRemoteStoreRestoreRequest request) throws IOException, OpenSearchException { - JsonEndpoint - endpoint = - (JsonEndpoint< - PostRemoteStoreRestoreRequest, - PostRemoteStoreRestoreResponse, - ErrorResponse>) - PostRemoteStoreRestoreRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - public final CompletableFuture postRemoteStoreRestore( - Function< - PostRemoteStoreRestoreRequest.Builder, - ObjectBuilder> - fn) - throws IOException, OpenSearchException { - return postRemoteStoreRestore( - fn.apply(new PostRemoteStoreRestoreRequest.Builder()).build()); - } - - public CompletableFuture postSearch(PostSearchRequest request) - throws IOException, OpenSearchException { - JsonEndpoint endpoint = - (JsonEndpoint) - PostSearchRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - public final CompletableFuture postSearch( - Function> fn) - throws IOException, OpenSearchException { - return postSearch(fn.apply(new PostSearchRequest.Builder()).build()); - } - - public CompletableFuture postSearchWithIndex( - PostSearchWithIndexRequest request) throws IOException, OpenSearchException { - JsonEndpoint - endpoint = - (JsonEndpoint< - PostSearchWithIndexRequest, - PostSearchWithIndexResponse, - ErrorResponse>) - PostSearchWithIndexRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - public final CompletableFuture postSearchWithIndex( - Function> - fn) - throws IOException, OpenSearchException { - return postSearchWithIndex(fn.apply(new PostSearchWithIndexRequest.Builder()).build()); - } - - public CompletableFuture putCreateIndex(PutCreateIndexRequest request) - throws IOException, OpenSearchException { - JsonEndpoint endpoint = - (JsonEndpoint) - PutCreateIndexRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - public final CompletableFuture putCreateIndex( - Function> fn) - throws IOException, OpenSearchException { - return putCreateIndex(fn.apply(new PutCreateIndexRequest.Builder()).build()); - } - - public CompletableFuture putIndexMappingWithIndex( - PutIndexMappingWithIndexRequest request) throws IOException, OpenSearchException { - JsonEndpoint< - PutIndexMappingWithIndexRequest, - PutIndexMappingWithIndexResponse, - ErrorResponse> - endpoint = - (JsonEndpoint< - PutIndexMappingWithIndexRequest, - PutIndexMappingWithIndexResponse, - ErrorResponse>) - PutIndexMappingWithIndexRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - public final CompletableFuture putIndexMappingWithIndex( - Function< - PutIndexMappingWithIndexRequest.Builder, - ObjectBuilder> - fn) - throws IOException, OpenSearchException { - return putIndexMappingWithIndex( - fn.apply(new PutIndexMappingWithIndexRequest.Builder()).build()); - } - - public CompletableFuture putUpdateClusterSettings( - PutUpdateClusterSettingsRequest request) throws IOException, OpenSearchException { - JsonEndpoint< - PutUpdateClusterSettingsRequest, - PutUpdateClusterSettingsResponse, - ErrorResponse> - endpoint = - (JsonEndpoint< - PutUpdateClusterSettingsRequest, - PutUpdateClusterSettingsResponse, - ErrorResponse>) - PutUpdateClusterSettingsRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - public final CompletableFuture putUpdateClusterSettings( - Function< - PutUpdateClusterSettingsRequest.Builder, - ObjectBuilder> - fn) - throws IOException, OpenSearchException { - return putUpdateClusterSettings( - fn.apply(new PutUpdateClusterSettingsRequest.Builder()).build()); - } -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClient.java b/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClient.java deleted file mode 100644 index b48c574d2d..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClient.java +++ /dev/null @@ -1,339 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.ApiClient; -import org.opensearch.client.opensearch._types.OpenSearchException; -import org.opensearch.client.opensearch._types.ErrorResponse; -import org.opensearch.client.transport.OpenSearchTransport; -import org.opensearch.client.transport.JsonEndpoint; -import org.opensearch.client.transport.TransportOptions; -import org.opensearch.client.util.ObjectBuilder; -import java.io.IOException; -import java.util.function.Function; -import javax.annotation.Nullable; - -public class OpenSearchClient extends ApiClient { - public OpenSearchClient(OpenSearchTransport transport) { - super(transport, null); - } - - public OpenSearchClient( - OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { - super(transport, transportOptions); - } - - @Override - public OpenSearchClient withTransportOptions(@Nullable TransportOptions transportOptions) { - return new OpenSearchClient(this.transport, transportOptions); - } - - public DeleteIndexResponse deleteIndex(DeleteIndexRequest request) - throws IOException, OpenSearchException { - JsonEndpoint endpoint = - (JsonEndpoint) - DeleteIndexRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - public final DeleteIndexResponse deleteIndex( - Function> fn) - throws IOException, OpenSearchException { - return deleteIndex(fn.apply(new DeleteIndexRequest.Builder()).build()); - } - - public GetCatIndicesResponse getCatIndices(GetCatIndicesRequest request) - throws IOException, OpenSearchException { - JsonEndpoint endpoint = - (JsonEndpoint) - GetCatIndicesRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - public final GetCatIndicesResponse getCatIndices( - Function> fn) - throws IOException, OpenSearchException { - return getCatIndices(fn.apply(new GetCatIndicesRequest.Builder()).build()); - } - - public GetCatIndicesWithIndexResponse getCatIndicesWithIndex( - GetCatIndicesWithIndexRequest request) throws IOException, OpenSearchException { - JsonEndpoint - endpoint = - (JsonEndpoint< - GetCatIndicesWithIndexRequest, - GetCatIndicesWithIndexResponse, - ErrorResponse>) - GetCatIndicesWithIndexRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - public final GetCatIndicesWithIndexResponse getCatIndicesWithIndex( - Function< - GetCatIndicesWithIndexRequest.Builder, - ObjectBuilder> - fn) - throws IOException, OpenSearchException { - return getCatIndicesWithIndex( - fn.apply(new GetCatIndicesWithIndexRequest.Builder()).build()); - } - - public GetCatNodesResponse getCatNodes(GetCatNodesRequest request) - throws IOException, OpenSearchException { - JsonEndpoint endpoint = - (JsonEndpoint) - GetCatNodesRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - public final GetCatNodesResponse getCatNodes( - Function> fn) - throws IOException, OpenSearchException { - return getCatNodes(fn.apply(new GetCatNodesRequest.Builder()).build()); - } - - public GetClusterInfoResponse getClusterInfo(GetClusterInfoRequest request) - throws IOException, OpenSearchException { - JsonEndpoint endpoint = - (JsonEndpoint) - GetClusterInfoRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - public final GetClusterInfoResponse getClusterInfo( - Function> fn) - throws IOException, OpenSearchException { - return getClusterInfo(fn.apply(new GetClusterInfoRequest.Builder()).build()); - } - - public GetClusterSettingsResponse getClusterSettings(GetClusterSettingsRequest request) - throws IOException, OpenSearchException { - JsonEndpoint - endpoint = - (JsonEndpoint< - GetClusterSettingsRequest, - GetClusterSettingsResponse, - ErrorResponse>) - GetClusterSettingsRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - public final GetClusterSettingsResponse getClusterSettings( - Function> - fn) - throws IOException, OpenSearchException { - return getClusterSettings(fn.apply(new GetClusterSettingsRequest.Builder()).build()); - } - - public GetDocumentDocResponse getDocumentDoc(GetDocumentDocRequest request) - throws IOException, OpenSearchException { - JsonEndpoint endpoint = - (JsonEndpoint) - GetDocumentDocRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - public final GetDocumentDocResponse getDocumentDoc( - Function> fn) - throws IOException, OpenSearchException { - return getDocumentDoc(fn.apply(new GetDocumentDocRequest.Builder()).build()); - } - - public GetDocumentSourceResponse getDocumentSource(GetDocumentSourceRequest request) - throws IOException, OpenSearchException { - JsonEndpoint endpoint = - (JsonEndpoint) - GetDocumentSourceRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - public final GetDocumentSourceResponse getDocumentSource( - Function> fn) - throws IOException, OpenSearchException { - return getDocumentSource(fn.apply(new GetDocumentSourceRequest.Builder()).build()); - } - - public GetSettingsIndexResponse getSettingsIndex(GetSettingsIndexRequest request) - throws IOException, OpenSearchException { - JsonEndpoint endpoint = - (JsonEndpoint) - GetSettingsIndexRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - public final GetSettingsIndexResponse getSettingsIndex( - Function> fn) - throws IOException, OpenSearchException { - return getSettingsIndex(fn.apply(new GetSettingsIndexRequest.Builder()).build()); - } - - public GetSettingsIndexSettingResponse getSettingsIndexSetting( - GetSettingsIndexSettingRequest request) throws IOException, OpenSearchException { - JsonEndpoint - endpoint = - (JsonEndpoint< - GetSettingsIndexSettingRequest, - GetSettingsIndexSettingResponse, - ErrorResponse>) - GetSettingsIndexSettingRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - public final GetSettingsIndexSettingResponse getSettingsIndexSetting( - Function< - GetSettingsIndexSettingRequest.Builder, - ObjectBuilder> - fn) - throws IOException, OpenSearchException { - return getSettingsIndexSetting( - fn.apply(new GetSettingsIndexSettingRequest.Builder()).build()); - } - - public PostAliasesResponse postAliases(PostAliasesRequest request) - throws IOException, OpenSearchException { - JsonEndpoint endpoint = - (JsonEndpoint) - PostAliasesRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - public final PostAliasesResponse postAliases( - Function> fn) - throws IOException, OpenSearchException { - return postAliases(fn.apply(new PostAliasesRequest.Builder()).build()); - } - - public PostRemoteStoreRestoreResponse postRemoteStoreRestore( - PostRemoteStoreRestoreRequest request) throws IOException, OpenSearchException { - JsonEndpoint - endpoint = - (JsonEndpoint< - PostRemoteStoreRestoreRequest, - PostRemoteStoreRestoreResponse, - ErrorResponse>) - PostRemoteStoreRestoreRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - public final PostRemoteStoreRestoreResponse postRemoteStoreRestore( - Function< - PostRemoteStoreRestoreRequest.Builder, - ObjectBuilder> - fn) - throws IOException, OpenSearchException { - return postRemoteStoreRestore( - fn.apply(new PostRemoteStoreRestoreRequest.Builder()).build()); - } - - public PostSearchResponse postSearch(PostSearchRequest request) - throws IOException, OpenSearchException { - JsonEndpoint endpoint = - (JsonEndpoint) - PostSearchRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - public final PostSearchResponse postSearch( - Function> fn) - throws IOException, OpenSearchException { - return postSearch(fn.apply(new PostSearchRequest.Builder()).build()); - } - - public PostSearchWithIndexResponse postSearchWithIndex(PostSearchWithIndexRequest request) - throws IOException, OpenSearchException { - JsonEndpoint - endpoint = - (JsonEndpoint< - PostSearchWithIndexRequest, - PostSearchWithIndexResponse, - ErrorResponse>) - PostSearchWithIndexRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - public final PostSearchWithIndexResponse postSearchWithIndex( - Function> - fn) - throws IOException, OpenSearchException { - return postSearchWithIndex(fn.apply(new PostSearchWithIndexRequest.Builder()).build()); - } - - public PutCreateIndexResponse putCreateIndex(PutCreateIndexRequest request) - throws IOException, OpenSearchException { - JsonEndpoint endpoint = - (JsonEndpoint) - PutCreateIndexRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - public final PutCreateIndexResponse putCreateIndex( - Function> fn) - throws IOException, OpenSearchException { - return putCreateIndex(fn.apply(new PutCreateIndexRequest.Builder()).build()); - } - - public PutIndexMappingWithIndexResponse putIndexMappingWithIndex( - PutIndexMappingWithIndexRequest request) throws IOException, OpenSearchException { - JsonEndpoint< - PutIndexMappingWithIndexRequest, - PutIndexMappingWithIndexResponse, - ErrorResponse> - endpoint = - (JsonEndpoint< - PutIndexMappingWithIndexRequest, - PutIndexMappingWithIndexResponse, - ErrorResponse>) - PutIndexMappingWithIndexRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - public final PutIndexMappingWithIndexResponse putIndexMappingWithIndex( - Function< - PutIndexMappingWithIndexRequest.Builder, - ObjectBuilder> - fn) - throws IOException, OpenSearchException { - return putIndexMappingWithIndex( - fn.apply(new PutIndexMappingWithIndexRequest.Builder()).build()); - } - - public PutUpdateClusterSettingsResponse putUpdateClusterSettings( - PutUpdateClusterSettingsRequest request) throws IOException, OpenSearchException { - JsonEndpoint< - PutUpdateClusterSettingsRequest, - PutUpdateClusterSettingsResponse, - ErrorResponse> - endpoint = - (JsonEndpoint< - PutUpdateClusterSettingsRequest, - PutUpdateClusterSettingsResponse, - ErrorResponse>) - PutUpdateClusterSettingsRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - public final PutUpdateClusterSettingsResponse putUpdateClusterSettings( - Function< - PutUpdateClusterSettingsRequest.Builder, - ObjectBuilder> - fn) - throws IOException, OpenSearchException { - return putUpdateClusterSettings( - fn.apply(new PutUpdateClusterSettingsRequest.Builder()).build()); - } -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesRequest.java deleted file mode 100644 index 03ed4eecba..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesRequest.java +++ /dev/null @@ -1,147 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.opensearch._types.*; -import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import java.util.stream.*; -import javax.annotation.*; - -/** Adds or removes index aliases. */ -@JsonpDeserializable -public class PostAliasesRequest extends RequestBase implements JsonpSerializable { - - @Nullable private final ActionObjectStructure actions; - - @Nullable private final String clusterManagerTimeout; - - @Nullable private final String masterTimeout; - - @Nullable private final String timeout; - - public PostAliasesRequest(Builder builder) { - this.actions = builder.actions; - this.clusterManagerTimeout = builder.clusterManagerTimeout; - this.masterTimeout = builder.masterTimeout; - this.timeout = builder.timeout; - } - - public static PostAliasesRequest of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final ActionObjectStructure actions() { - return this.actions; - } - - public final String clusterManagerTimeout() { - return this.clusterManagerTimeout; - } - - public final String masterTimeout() { - return this.masterTimeout; - } - - public final String timeout() { - return this.timeout; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.actions != null) { - generator.writeKey("actions"); - this.actions.serialize(generator, mapper); - } - } - - /** Builder for {@link PostAliasesRequest}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private ActionObjectStructure actions; - private String clusterManagerTimeout; - private String masterTimeout; - private String timeout; - - public final Builder actions(ActionObjectStructure value) { - this.actions = value; - return this; - } - - public final Builder actions( - Function> fn) { - return actions(fn.apply(new ActionObjectStructure.Builder()).build()); - } - - public final Builder clusterManagerTimeout(String value) { - this.clusterManagerTimeout = value; - return this; - } - - public final Builder masterTimeout(String value) { - this.masterTimeout = value; - return this; - } - - public final Builder timeout(String value) { - this.timeout = value; - return this; - } - - /** - * Builds a {@link PostAliasesRequest}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public PostAliasesRequest build() { - _checkSingleUse(); - - return new PostAliasesRequest(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, PostAliasesRequest::setupPostAliasesRequestDeserializer); - - protected static void setupPostAliasesRequestDeserializer( - ObjectDeserializer op) { - op.add(Builder::actions, ActionObjectStructure._DESERIALIZER, "actions"); - } - - public static final Endpoint _ENDPOINT = - new SimpleEndpoint<>( - // Request method - request -> { - return "post"; - }, - // Request path - request -> { - return "/_aliases"; - }, - // Request parameters - request -> { - Map params = new HashMap<>(); - if (request.clusterManagerTimeout != null) { - params.put("cluster_manager_timeout", request.clusterManagerTimeout); - } - if (request.masterTimeout != null) { - params.put("master_timeout", request.masterTimeout); - } - if (request.timeout != null) { - params.put("timeout", request.timeout); - } - return params; - }, - SimpleEndpoint.emptyMap(), - true, - PostAliasesResponse._DESERIALIZER); -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesResponse.java deleted file mode 100644 index 205b356d63..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostAliasesResponse.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class PostAliasesResponse implements JsonpSerializable { - - private final boolean acknowledged; - - public PostAliasesResponse(Builder builder) { - this.acknowledged = - ApiTypeHelper.requireNonNull(builder.acknowledged, this, "acknowledged"); - } - - public static PostAliasesResponse of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final boolean acknowledged() { - return this.acknowledged; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("acknowledged"); - generator.write(this.acknowledged); - } - - /** Builder for {@link PostAliasesResponse}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private Boolean acknowledged; - - public final Builder acknowledged(boolean value) { - this.acknowledged = value; - return this; - } - - /** - * Builds a {@link PostAliasesResponse}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public PostAliasesResponse build() { - _checkSingleUse(); - - return new PostAliasesResponse(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, PostAliasesResponse::setupPostAliasesResponseDeserializer); - - protected static void setupPostAliasesResponseDeserializer( - ObjectDeserializer op) { - op.add(Builder::acknowledged, JsonpDeserializer.booleanDeserializer(), "acknowledged"); - } -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreRequest.java deleted file mode 100644 index ec57ef737a..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreRequest.java +++ /dev/null @@ -1,144 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.opensearch._types.*; -import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import java.util.stream.*; -import javax.annotation.*; - -/** Restore one or more indices from a remote backup. */ -@JsonpDeserializable -public class PostRemoteStoreRestoreRequest extends RequestBase implements JsonpSerializable { - - @Nullable private final String clusterManagerTimeout; - - private final List indices; - - @Nullable private final Boolean waitForCompletion; - - public PostRemoteStoreRestoreRequest(Builder builder) { - this.clusterManagerTimeout = builder.clusterManagerTimeout; - this.indices = ApiTypeHelper.unmodifiableRequired(builder.indices, this, "indices"); - this.waitForCompletion = builder.waitForCompletion; - } - - public static PostRemoteStoreRestoreRequest of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final String clusterManagerTimeout() { - return this.clusterManagerTimeout; - } - - public final List indices() { - return this.indices; - } - - public final Boolean waitForCompletion() { - return this.waitForCompletion; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("indices"); - generator.writeStartArray(); - for (String item0 : this.indices) { - generator.write(item0); - } - generator.writeEnd(); - } - - /** Builder for {@link PostRemoteStoreRestoreRequest}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private String clusterManagerTimeout; - private List indices; - private Boolean waitForCompletion; - - public final Builder clusterManagerTimeout(String value) { - this.clusterManagerTimeout = value; - return this; - } - - public final Builder indices(List list) { - this.indices = _listAddAll(this.indices, list); - return this; - } - - public final Builder indices(String value, String... values) { - this.indices = _listAdd(this.indices, value, values); - return this; - } - - public final Builder waitForCompletion(Boolean value) { - this.waitForCompletion = value; - return this; - } - - /** - * Builds a {@link PostRemoteStoreRestoreRequest}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public PostRemoteStoreRestoreRequest build() { - _checkSingleUse(); - - return new PostRemoteStoreRestoreRequest(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, - PostRemoteStoreRestoreRequest::setupPostRemoteStoreRestoreRequestDeserializer); - - protected static void setupPostRemoteStoreRestoreRequestDeserializer( - ObjectDeserializer op) { - op.add( - Builder::indices, - JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), - "indices"); - } - - public static final Endpoint< - PostRemoteStoreRestoreRequest, PostRemoteStoreRestoreResponse, ErrorResponse> - _ENDPOINT = - new SimpleEndpoint<>( - // Request method - request -> { - return "post"; - }, - // Request path - request -> { - return "/_remotestore/_restore"; - }, - // Request parameters - request -> { - Map params = new HashMap<>(); - if (request.clusterManagerTimeout != null) { - params.put( - "cluster_manager_timeout", - request.clusterManagerTimeout); - } - if (request.waitForCompletion != null) { - params.put( - "wait_for_completion", - String.valueOf(request.waitForCompletion)); - } - return params; - }, - SimpleEndpoint.emptyMap(), - true, - PostRemoteStoreRestoreResponse._DESERIALIZER); -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreResponse.java deleted file mode 100644 index fdf61e2d5d..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostRemoteStoreRestoreResponse.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class PostRemoteStoreRestoreResponse implements JsonpSerializable { - - @Nullable private final Boolean accepted; - - @Nullable private final RemoteStoreRestoreInfo remoteStore; - - public PostRemoteStoreRestoreResponse(Builder builder) { - this.accepted = builder.accepted; - this.remoteStore = builder.remoteStore; - } - - public static PostRemoteStoreRestoreResponse of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final Boolean accepted() { - return this.accepted; - } - - public final RemoteStoreRestoreInfo remoteStore() { - return this.remoteStore; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.accepted != null) { - generator.writeKey("accepted"); - generator.write(this.accepted); - } - - if (this.remoteStore != null) { - generator.writeKey("remote_store"); - this.remoteStore.serialize(generator, mapper); - } - } - - /** Builder for {@link PostRemoteStoreRestoreResponse}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private Boolean accepted; - private RemoteStoreRestoreInfo remoteStore; - - public final Builder accepted(Boolean value) { - this.accepted = value; - return this; - } - - public final Builder remoteStore(RemoteStoreRestoreInfo value) { - this.remoteStore = value; - return this; - } - - public final Builder remoteStore( - Function> - fn) { - return remoteStore(fn.apply(new RemoteStoreRestoreInfo.Builder()).build()); - } - - /** - * Builds a {@link PostRemoteStoreRestoreResponse}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public PostRemoteStoreRestoreResponse build() { - _checkSingleUse(); - - return new PostRemoteStoreRestoreResponse(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, - PostRemoteStoreRestoreResponse - ::setupPostRemoteStoreRestoreResponseDeserializer); - - protected static void setupPostRemoteStoreRestoreResponseDeserializer( - ObjectDeserializer op) { - op.add(Builder::accepted, JsonpDeserializer.booleanDeserializer(), "accepted"); - op.add(Builder::remoteStore, RemoteStoreRestoreInfo._DESERIALIZER, "remote_store"); - } -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchRequest.java deleted file mode 100644 index 396bd648a1..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchRequest.java +++ /dev/null @@ -1,961 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.opensearch._types.*; -import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import java.util.stream.*; -import javax.annotation.*; - -/** Returns results matching a query. */ -@JsonpDeserializable -public class PostSearchRequest extends RequestBase implements JsonpSerializable { - - @Nullable private final Boolean allowNoIndices; - - @Nullable private final Boolean allowPartialSearchResults; - - @Nullable private final Boolean analyzeWildcard; - - @Nullable private final String analyzer; - - @Nullable private final Integer batchedReduceSize; - - @Nullable private final Boolean ccsMinimizeRoundtrips; - - @Nullable private final DefaultOperator defaultOperator; - - @Nullable private final String df; - - @Nullable private final String docvalueFields; - - @Nullable private final ExpandWildcards expandWildcards; - - @Nullable private final Boolean explain; - - @Nullable private final List fields; - - @Nullable private final Integer from; - - @Nullable private final Boolean ignoreThrottled; - - @Nullable private final Boolean ignoreUnavailable; - - @Nullable private final List indicesBoost; - - @Nullable private final Boolean lenient; - - @Nullable private final Long maxConcurrentShardRequests; - - @Nullable private final Integer minScore; - - @Nullable private final Long preFilterShardSize; - - @Nullable private final String preference; - - @Nullable private final String q; - - @Nullable private final UserDefinedObjectStructure query; - - @Nullable private final Boolean requestCache; - - @Nullable private final Boolean restTotalHitsAsInt; - - @Nullable private final String routing; - - @Nullable private final String scroll; - - @Nullable private final SearchType searchType; - - @Nullable private final Boolean seqNoPrimaryTerm; - - @Nullable private final Integer size; - - @Nullable private final List sort; - - @Nullable private final String source; - - @Nullable private final List sourceExcludes; - - @Nullable private final List sourceIncludes; - - @Nullable private final String stats; - - @Nullable private final Boolean storedFields; - - @Nullable private final String suggestField; - - @Nullable private final SuggestMode suggestMode; - - @Nullable private final Long suggestSize; - - @Nullable private final String suggestText; - - @Nullable private final Integer terminateAfter; - - @Nullable private final String timeout; - - @Nullable private final Boolean trackScores; - - @Nullable private final Integer trackTotalHits; - - @Nullable private final Boolean typedKeys; - - @Nullable private final Boolean version; - - public PostSearchRequest(Builder builder) { - this.allowNoIndices = builder.allowNoIndices; - this.allowPartialSearchResults = builder.allowPartialSearchResults; - this.analyzeWildcard = builder.analyzeWildcard; - this.analyzer = builder.analyzer; - this.batchedReduceSize = builder.batchedReduceSize; - this.ccsMinimizeRoundtrips = builder.ccsMinimizeRoundtrips; - this.defaultOperator = builder.defaultOperator; - this.df = builder.df; - this.docvalueFields = builder.docvalueFields; - this.expandWildcards = builder.expandWildcards; - this.explain = builder.explain; - this.fields = ApiTypeHelper.unmodifiable(builder.fields); - this.from = builder.from; - this.ignoreThrottled = builder.ignoreThrottled; - this.ignoreUnavailable = builder.ignoreUnavailable; - this.indicesBoost = ApiTypeHelper.unmodifiable(builder.indicesBoost); - this.lenient = builder.lenient; - this.maxConcurrentShardRequests = builder.maxConcurrentShardRequests; - this.minScore = builder.minScore; - this.preFilterShardSize = builder.preFilterShardSize; - this.preference = builder.preference; - this.q = builder.q; - this.query = builder.query; - this.requestCache = builder.requestCache; - this.restTotalHitsAsInt = builder.restTotalHitsAsInt; - this.routing = builder.routing; - this.scroll = builder.scroll; - this.searchType = builder.searchType; - this.seqNoPrimaryTerm = builder.seqNoPrimaryTerm; - this.size = builder.size; - this.sort = ApiTypeHelper.unmodifiable(builder.sort); - this.source = builder.source; - this.sourceExcludes = ApiTypeHelper.unmodifiable(builder.sourceExcludes); - this.sourceIncludes = ApiTypeHelper.unmodifiable(builder.sourceIncludes); - this.stats = builder.stats; - this.storedFields = builder.storedFields; - this.suggestField = builder.suggestField; - this.suggestMode = builder.suggestMode; - this.suggestSize = builder.suggestSize; - this.suggestText = builder.suggestText; - this.terminateAfter = builder.terminateAfter; - this.timeout = builder.timeout; - this.trackScores = builder.trackScores; - this.trackTotalHits = builder.trackTotalHits; - this.typedKeys = builder.typedKeys; - this.version = builder.version; - } - - public static PostSearchRequest of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final Boolean allowNoIndices() { - return this.allowNoIndices; - } - - public final Boolean allowPartialSearchResults() { - return this.allowPartialSearchResults; - } - - public final Boolean analyzeWildcard() { - return this.analyzeWildcard; - } - - public final String analyzer() { - return this.analyzer; - } - - public final Integer batchedReduceSize() { - return this.batchedReduceSize; - } - - public final Boolean ccsMinimizeRoundtrips() { - return this.ccsMinimizeRoundtrips; - } - - public final DefaultOperator defaultOperator() { - return this.defaultOperator; - } - - public final String df() { - return this.df; - } - - public final String docvalueFields() { - return this.docvalueFields; - } - - public final ExpandWildcards expandWildcards() { - return this.expandWildcards; - } - - public final Boolean explain() { - return this.explain; - } - - public final List fields() { - return this.fields; - } - - public final Integer from() { - return this.from; - } - - public final Boolean ignoreThrottled() { - return this.ignoreThrottled; - } - - public final Boolean ignoreUnavailable() { - return this.ignoreUnavailable; - } - - public final List indicesBoost() { - return this.indicesBoost; - } - - public final Boolean lenient() { - return this.lenient; - } - - public final Long maxConcurrentShardRequests() { - return this.maxConcurrentShardRequests; - } - - public final Integer minScore() { - return this.minScore; - } - - public final Long preFilterShardSize() { - return this.preFilterShardSize; - } - - public final String preference() { - return this.preference; - } - - public final String q() { - return this.q; - } - - public final UserDefinedObjectStructure query() { - return this.query; - } - - public final Boolean requestCache() { - return this.requestCache; - } - - public final Boolean restTotalHitsAsInt() { - return this.restTotalHitsAsInt; - } - - public final String routing() { - return this.routing; - } - - public final String scroll() { - return this.scroll; - } - - public final SearchType searchType() { - return this.searchType; - } - - public final Boolean seqNoPrimaryTerm() { - return this.seqNoPrimaryTerm; - } - - public final Integer size() { - return this.size; - } - - public final List sort() { - return this.sort; - } - - public final String source() { - return this.source; - } - - public final List sourceExcludes() { - return this.sourceExcludes; - } - - public final List sourceIncludes() { - return this.sourceIncludes; - } - - public final String stats() { - return this.stats; - } - - public final Boolean storedFields() { - return this.storedFields; - } - - public final String suggestField() { - return this.suggestField; - } - - public final SuggestMode suggestMode() { - return this.suggestMode; - } - - public final Long suggestSize() { - return this.suggestSize; - } - - public final String suggestText() { - return this.suggestText; - } - - public final Integer terminateAfter() { - return this.terminateAfter; - } - - public final String timeout() { - return this.timeout; - } - - public final Boolean trackScores() { - return this.trackScores; - } - - public final Integer trackTotalHits() { - return this.trackTotalHits; - } - - public final Boolean typedKeys() { - return this.typedKeys; - } - - public final Boolean version() { - return this.version; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.docvalueFields != null) { - generator.writeKey("docvalue_fields"); - generator.write(this.docvalueFields); - } - - if (this.explain != null) { - generator.writeKey("explain"); - generator.write(this.explain); - } - - if (ApiTypeHelper.isDefined(this.fields)) { - generator.writeKey("fields"); - generator.writeStartArray(); - for (String item0 : this.fields) { - generator.write(item0); - } - generator.writeEnd(); - } - - if (this.from != null) { - generator.writeKey("from"); - generator.write(this.from); - } - - if (ApiTypeHelper.isDefined(this.indicesBoost)) { - generator.writeKey("indices_boost"); - generator.writeStartArray(); - for (JsonData item0 : this.indicesBoost) { - item0.serialize(generator, mapper); - } - generator.writeEnd(); - } - - if (this.minScore != null) { - generator.writeKey("min_score"); - generator.write(this.minScore); - } - - if (this.query != null) { - generator.writeKey("query"); - this.query.serialize(generator, mapper); - } - - if (this.seqNoPrimaryTerm != null) { - generator.writeKey("seq_no_primary_term"); - generator.write(this.seqNoPrimaryTerm); - } - - if (this.size != null) { - generator.writeKey("size"); - generator.write(this.size); - } - - if (this.source != null) { - generator.writeKey("source"); - generator.write(this.source); - } - - if (this.stats != null) { - generator.writeKey("stats"); - generator.write(this.stats); - } - - if (this.terminateAfter != null) { - generator.writeKey("terminate_after"); - generator.write(this.terminateAfter); - } - - if (this.timeout != null) { - generator.writeKey("timeout"); - generator.write(this.timeout); - } - - if (this.version != null) { - generator.writeKey("version"); - generator.write(this.version); - } - } - - /** Builder for {@link PostSearchRequest}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private Boolean allowNoIndices; - private Boolean allowPartialSearchResults; - private Boolean analyzeWildcard; - private String analyzer; - private Integer batchedReduceSize; - private Boolean ccsMinimizeRoundtrips; - private DefaultOperator defaultOperator; - private String df; - private String docvalueFields; - private ExpandWildcards expandWildcards; - private Boolean explain; - private List fields; - private Integer from; - private Boolean ignoreThrottled; - private Boolean ignoreUnavailable; - private List indicesBoost; - private Boolean lenient; - private Long maxConcurrentShardRequests; - private Integer minScore; - private Long preFilterShardSize; - private String preference; - private String q; - private UserDefinedObjectStructure query; - private Boolean requestCache; - private Boolean restTotalHitsAsInt; - private String routing; - private String scroll; - private SearchType searchType; - private Boolean seqNoPrimaryTerm; - private Integer size; - private List sort; - private String source; - private List sourceExcludes; - private List sourceIncludes; - private String stats; - private Boolean storedFields; - private String suggestField; - private SuggestMode suggestMode; - private Long suggestSize; - private String suggestText; - private Integer terminateAfter; - private String timeout; - private Boolean trackScores; - private Integer trackTotalHits; - private Boolean typedKeys; - private Boolean version; - - public final Builder allowNoIndices(Boolean value) { - this.allowNoIndices = value; - return this; - } - - public final Builder allowPartialSearchResults(Boolean value) { - this.allowPartialSearchResults = value; - return this; - } - - public final Builder analyzeWildcard(Boolean value) { - this.analyzeWildcard = value; - return this; - } - - public final Builder analyzer(String value) { - this.analyzer = value; - return this; - } - - public final Builder batchedReduceSize(Integer value) { - this.batchedReduceSize = value; - return this; - } - - public final Builder ccsMinimizeRoundtrips(Boolean value) { - this.ccsMinimizeRoundtrips = value; - return this; - } - - public final Builder defaultOperator(DefaultOperator value) { - this.defaultOperator = value; - return this; - } - - public final Builder df(String value) { - this.df = value; - return this; - } - - public final Builder docvalueFields(String value) { - this.docvalueFields = value; - return this; - } - - public final Builder expandWildcards(ExpandWildcards value) { - this.expandWildcards = value; - return this; - } - - public final Builder explain(Boolean value) { - this.explain = value; - return this; - } - - public final Builder fields(List list) { - this.fields = _listAddAll(this.fields, list); - return this; - } - - public final Builder fields(String value, String... values) { - this.fields = _listAdd(this.fields, value, values); - return this; - } - - public final Builder from(Integer value) { - this.from = value; - return this; - } - - public final Builder ignoreThrottled(Boolean value) { - this.ignoreThrottled = value; - return this; - } - - public final Builder ignoreUnavailable(Boolean value) { - this.ignoreUnavailable = value; - return this; - } - - public final Builder indicesBoost(List list) { - this.indicesBoost = _listAddAll(this.indicesBoost, list); - return this; - } - - public final Builder indicesBoost(JsonData value, JsonData... values) { - this.indicesBoost = _listAdd(this.indicesBoost, value, values); - return this; - } - - public final Builder lenient(Boolean value) { - this.lenient = value; - return this; - } - - public final Builder maxConcurrentShardRequests(Long value) { - this.maxConcurrentShardRequests = value; - return this; - } - - public final Builder minScore(Integer value) { - this.minScore = value; - return this; - } - - public final Builder preFilterShardSize(Long value) { - this.preFilterShardSize = value; - return this; - } - - public final Builder preference(String value) { - this.preference = value; - return this; - } - - public final Builder q(String value) { - this.q = value; - return this; - } - - public final Builder query(UserDefinedObjectStructure value) { - this.query = value; - return this; - } - - public final Builder query( - Function< - UserDefinedObjectStructure.Builder, - ObjectBuilder> - fn) { - return query(fn.apply(new UserDefinedObjectStructure.Builder()).build()); - } - - public final Builder requestCache(Boolean value) { - this.requestCache = value; - return this; - } - - public final Builder restTotalHitsAsInt(Boolean value) { - this.restTotalHitsAsInt = value; - return this; - } - - public final Builder routing(String value) { - this.routing = value; - return this; - } - - public final Builder scroll(String value) { - this.scroll = value; - return this; - } - - public final Builder searchType(SearchType value) { - this.searchType = value; - return this; - } - - public final Builder seqNoPrimaryTerm(Boolean value) { - this.seqNoPrimaryTerm = value; - return this; - } - - public final Builder size(Integer value) { - this.size = value; - return this; - } - - public final Builder sort(List list) { - this.sort = _listAddAll(this.sort, list); - return this; - } - - public final Builder sort(String value, String... values) { - this.sort = _listAdd(this.sort, value, values); - return this; - } - - public final Builder source(String value) { - this.source = value; - return this; - } - - public final Builder sourceExcludes(List list) { - this.sourceExcludes = _listAddAll(this.sourceExcludes, list); - return this; - } - - public final Builder sourceExcludes(String value, String... values) { - this.sourceExcludes = _listAdd(this.sourceExcludes, value, values); - return this; - } - - public final Builder sourceIncludes(List list) { - this.sourceIncludes = _listAddAll(this.sourceIncludes, list); - return this; - } - - public final Builder sourceIncludes(String value, String... values) { - this.sourceIncludes = _listAdd(this.sourceIncludes, value, values); - return this; - } - - public final Builder stats(String value) { - this.stats = value; - return this; - } - - public final Builder storedFields(Boolean value) { - this.storedFields = value; - return this; - } - - public final Builder suggestField(String value) { - this.suggestField = value; - return this; - } - - public final Builder suggestMode(SuggestMode value) { - this.suggestMode = value; - return this; - } - - public final Builder suggestSize(Long value) { - this.suggestSize = value; - return this; - } - - public final Builder suggestText(String value) { - this.suggestText = value; - return this; - } - - public final Builder terminateAfter(Integer value) { - this.terminateAfter = value; - return this; - } - - public final Builder timeout(String value) { - this.timeout = value; - return this; - } - - public final Builder trackScores(Boolean value) { - this.trackScores = value; - return this; - } - - public final Builder trackTotalHits(Integer value) { - this.trackTotalHits = value; - return this; - } - - public final Builder typedKeys(Boolean value) { - this.typedKeys = value; - return this; - } - - public final Builder version(Boolean value) { - this.version = value; - return this; - } - - /** - * Builds a {@link PostSearchRequest}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public PostSearchRequest build() { - _checkSingleUse(); - - return new PostSearchRequest(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, PostSearchRequest::setupPostSearchRequestDeserializer); - - protected static void setupPostSearchRequestDeserializer( - ObjectDeserializer op) { - op.add(Builder::docvalueFields, JsonpDeserializer.stringDeserializer(), "docvalue_fields"); - op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); - op.add( - Builder::fields, - JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), - "fields"); - op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); - op.add( - Builder::indicesBoost, - JsonpDeserializer.arrayDeserializer(JsonData._DESERIALIZER), - "indices_boost"); - op.add(Builder::minScore, JsonpDeserializer.integerDeserializer(), "min_score"); - op.add(Builder::query, UserDefinedObjectStructure._DESERIALIZER, "query"); - op.add( - Builder::seqNoPrimaryTerm, - JsonpDeserializer.booleanDeserializer(), - "seq_no_primary_term"); - op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); - op.add(Builder::source, JsonpDeserializer.stringDeserializer(), "source"); - op.add(Builder::stats, JsonpDeserializer.stringDeserializer(), "stats"); - op.add(Builder::terminateAfter, JsonpDeserializer.integerDeserializer(), "terminate_after"); - op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); - op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); - } - - public static final Endpoint _ENDPOINT = - new SimpleEndpoint<>( - // Request method - request -> { - return "post"; - }, - // Request path - request -> { - return "/_search"; - }, - // Request parameters - request -> { - Map params = new HashMap<>(); - if (request.allowNoIndices != null) { - params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); - } - if (request.allowPartialSearchResults != null) { - params.put( - "allow_partial_search_results", - String.valueOf(request.allowPartialSearchResults)); - } - if (request.analyzeWildcard != null) { - params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); - } - if (request.analyzer != null) { - params.put("analyzer", request.analyzer); - } - if (request.batchedReduceSize != null) { - params.put( - "batched_reduce_size", - String.valueOf(request.batchedReduceSize)); - } - if (request.ccsMinimizeRoundtrips != null) { - params.put( - "ccs_minimize_roundtrips", - String.valueOf(request.ccsMinimizeRoundtrips)); - } - if (request.defaultOperator != null) { - params.put("default_operator", request.defaultOperator.jsonValue()); - } - if (request.df != null) { - params.put("df", request.df); - } - if (request.docvalueFields != null) { - params.put("docvalue_fields", request.docvalueFields); - } - if (request.expandWildcards != null) { - params.put("expand_wildcards", request.expandWildcards.jsonValue()); - } - if (request.explain != null) { - params.put("explain", String.valueOf(request.explain)); - } - if (request.from != null) { - params.put("from", String.valueOf(request.from)); - } - if (request.ignoreThrottled != null) { - params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); - } - if (request.ignoreUnavailable != null) { - params.put( - "ignore_unavailable", - String.valueOf(request.ignoreUnavailable)); - } - if (request.lenient != null) { - params.put("lenient", String.valueOf(request.lenient)); - } - if (request.maxConcurrentShardRequests != null) { - params.put( - "max_concurrent_shard_requests", - String.valueOf(request.maxConcurrentShardRequests)); - } - if (request.preFilterShardSize != null) { - params.put( - "pre_filter_shard_size", - String.valueOf(request.preFilterShardSize)); - } - if (request.preference != null) { - params.put("preference", request.preference); - } - if (request.q != null) { - params.put("q", request.q); - } - if (request.requestCache != null) { - params.put("request_cache", String.valueOf(request.requestCache)); - } - if (request.restTotalHitsAsInt != null) { - params.put( - "rest_total_hits_as_int", - String.valueOf(request.restTotalHitsAsInt)); - } - if (request.routing != null) { - params.put("routing", request.routing); - } - if (request.scroll != null) { - params.put("scroll", request.scroll); - } - if (request.searchType != null) { - params.put("search_type", request.searchType.jsonValue()); - } - if (request.seqNoPrimaryTerm != null) { - params.put( - "seq_no_primary_term", - String.valueOf(request.seqNoPrimaryTerm)); - } - if (request.size != null) { - params.put("size", String.valueOf(request.size)); - } - if (ApiTypeHelper.isDefined(request.sort)) { - params.put( - "sort", - request.sort.stream() - .map(v -> v) - .collect(Collectors.joining(","))); - } - if (request.source != null) { - params.put("source", request.source); - } - if (ApiTypeHelper.isDefined(request.sourceExcludes)) { - params.put( - "source_excludes", - request.sourceExcludes.stream() - .map(v -> v) - .collect(Collectors.joining(","))); - } - if (ApiTypeHelper.isDefined(request.sourceIncludes)) { - params.put( - "source_includes", - request.sourceIncludes.stream() - .map(v -> v) - .collect(Collectors.joining(","))); - } - if (request.stats != null) { - params.put("stats", request.stats); - } - if (request.storedFields != null) { - params.put("stored_fields", String.valueOf(request.storedFields)); - } - if (request.suggestField != null) { - params.put("suggest_field", request.suggestField); - } - if (request.suggestMode != null) { - params.put("suggest_mode", request.suggestMode.jsonValue()); - } - if (request.suggestSize != null) { - params.put("suggest_size", String.valueOf(request.suggestSize)); - } - if (request.suggestText != null) { - params.put("suggest_text", request.suggestText); - } - if (request.terminateAfter != null) { - params.put("terminate_after", String.valueOf(request.terminateAfter)); - } - if (request.timeout != null) { - params.put("timeout", request.timeout); - } - if (request.trackScores != null) { - params.put("track_scores", String.valueOf(request.trackScores)); - } - if (request.trackTotalHits != null) { - params.put("track_total_hits", String.valueOf(request.trackTotalHits)); - } - if (request.typedKeys != null) { - params.put("typed_keys", String.valueOf(request.typedKeys)); - } - if (request.version != null) { - params.put("version", String.valueOf(request.version)); - } - return params; - }, - SimpleEndpoint.emptyMap(), - true, - PostSearchResponse._DESERIALIZER); -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchResponse.java deleted file mode 100644 index 6f73a0b038..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchResponse.java +++ /dev/null @@ -1,155 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class PostSearchResponse implements JsonpSerializable { - - @Nullable private final HitsMetadata hits; - - @Nullable private final String scrollId; - - @Nullable private final ShardStatistics shards; - - @Nullable private final Boolean timedOut; - - @Nullable private final Long took; - - public PostSearchResponse(Builder builder) { - this.hits = builder.hits; - this.scrollId = builder.scrollId; - this.shards = builder.shards; - this.timedOut = builder.timedOut; - this.took = builder.took; - } - - public static PostSearchResponse of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final HitsMetadata hits() { - return this.hits; - } - - public final String scrollId() { - return this.scrollId; - } - - public final ShardStatistics shards() { - return this.shards; - } - - public final Boolean timedOut() { - return this.timedOut; - } - - public final Long took() { - return this.took; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.hits != null) { - generator.writeKey("hits"); - this.hits.serialize(generator, mapper); - } - - if (this.scrollId != null) { - generator.writeKey("_scroll_id"); - generator.write(this.scrollId); - } - - if (this.shards != null) { - generator.writeKey("_shards"); - this.shards.serialize(generator, mapper); - } - - if (this.timedOut != null) { - generator.writeKey("timed_out"); - generator.write(this.timedOut); - } - - if (this.took != null) { - generator.writeKey("took"); - generator.write(this.took); - } - } - - /** Builder for {@link PostSearchResponse}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private HitsMetadata hits; - private String scrollId; - private ShardStatistics shards; - private Boolean timedOut; - private Long took; - - public final Builder hits(HitsMetadata value) { - this.hits = value; - return this; - } - - public final Builder hits(Function> fn) { - return hits(fn.apply(new HitsMetadata.Builder()).build()); - } - - public final Builder scrollId(String value) { - this.scrollId = value; - return this; - } - - public final Builder shards(ShardStatistics value) { - this.shards = value; - return this; - } - - public final Builder shards( - Function> fn) { - return shards(fn.apply(new ShardStatistics.Builder()).build()); - } - - public final Builder timedOut(Boolean value) { - this.timedOut = value; - return this; - } - - public final Builder took(Long value) { - this.took = value; - return this; - } - - /** - * Builds a {@link PostSearchResponse}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public PostSearchResponse build() { - _checkSingleUse(); - - return new PostSearchResponse(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, PostSearchResponse::setupPostSearchResponseDeserializer); - - protected static void setupPostSearchResponseDeserializer( - ObjectDeserializer op) { - op.add(Builder::hits, HitsMetadata._DESERIALIZER, "hits"); - op.add(Builder::scrollId, JsonpDeserializer.stringDeserializer(), "_scroll_id"); - op.add(Builder::shards, ShardStatistics._DESERIALIZER, "_shards"); - op.add(Builder::timedOut, JsonpDeserializer.booleanDeserializer(), "timed_out"); - op.add(Builder::took, JsonpDeserializer.longDeserializer(), "took"); - } -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java deleted file mode 100644 index 8a8a438727..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexRequest.java +++ /dev/null @@ -1,994 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.opensearch._types.*; -import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import java.util.stream.*; -import javax.annotation.*; - -/** Returns results matching a query. */ -@JsonpDeserializable -public class PostSearchWithIndexRequest extends RequestBase implements JsonpSerializable { - - @Nullable private final Boolean allowNoIndices; - - @Nullable private final Boolean allowPartialSearchResults; - - @Nullable private final Boolean analyzeWildcard; - - @Nullable private final String analyzer; - - @Nullable private final Integer batchedReduceSize; - - @Nullable private final Boolean ccsMinimizeRoundtrips; - - @Nullable private final DefaultOperator defaultOperator; - - @Nullable private final String df; - - @Nullable private final String docvalueFields; - - @Nullable private final ExpandWildcards expandWildcards; - - @Nullable private final Boolean explain; - - @Nullable private final List fields; - - @Nullable private final Integer from; - - @Nullable private final Boolean ignoreThrottled; - - @Nullable private final Boolean ignoreUnavailable; - - private final String index; - - @Nullable private final List indicesBoost; - - @Nullable private final Boolean lenient; - - @Nullable private final Long maxConcurrentShardRequests; - - @Nullable private final Integer minScore; - - @Nullable private final Long preFilterShardSize; - - @Nullable private final String preference; - - @Nullable private final String q; - - @Nullable private final UserDefinedObjectStructure query; - - @Nullable private final Boolean requestCache; - - @Nullable private final Boolean restTotalHitsAsInt; - - @Nullable private final String routing; - - @Nullable private final String scroll; - - @Nullable private final SearchType searchType; - - @Nullable private final Boolean seqNoPrimaryTerm; - - @Nullable private final Integer size; - - @Nullable private final List sort; - - @Nullable private final String source; - - @Nullable private final List sourceExcludes; - - @Nullable private final List sourceIncludes; - - @Nullable private final String stats; - - @Nullable private final Boolean storedFields; - - @Nullable private final String suggestField; - - @Nullable private final SuggestMode suggestMode; - - @Nullable private final Long suggestSize; - - @Nullable private final String suggestText; - - @Nullable private final Integer terminateAfter; - - @Nullable private final String timeout; - - @Nullable private final Boolean trackScores; - - @Nullable private final Integer trackTotalHits; - - @Nullable private final Boolean typedKeys; - - @Nullable private final Boolean version; - - public PostSearchWithIndexRequest(Builder builder) { - this.allowNoIndices = builder.allowNoIndices; - this.allowPartialSearchResults = builder.allowPartialSearchResults; - this.analyzeWildcard = builder.analyzeWildcard; - this.analyzer = builder.analyzer; - this.batchedReduceSize = builder.batchedReduceSize; - this.ccsMinimizeRoundtrips = builder.ccsMinimizeRoundtrips; - this.defaultOperator = builder.defaultOperator; - this.df = builder.df; - this.docvalueFields = builder.docvalueFields; - this.expandWildcards = builder.expandWildcards; - this.explain = builder.explain; - this.fields = ApiTypeHelper.unmodifiable(builder.fields); - this.from = builder.from; - this.ignoreThrottled = builder.ignoreThrottled; - this.ignoreUnavailable = builder.ignoreUnavailable; - this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); - this.indicesBoost = ApiTypeHelper.unmodifiable(builder.indicesBoost); - this.lenient = builder.lenient; - this.maxConcurrentShardRequests = builder.maxConcurrentShardRequests; - this.minScore = builder.minScore; - this.preFilterShardSize = builder.preFilterShardSize; - this.preference = builder.preference; - this.q = builder.q; - this.query = builder.query; - this.requestCache = builder.requestCache; - this.restTotalHitsAsInt = builder.restTotalHitsAsInt; - this.routing = builder.routing; - this.scroll = builder.scroll; - this.searchType = builder.searchType; - this.seqNoPrimaryTerm = builder.seqNoPrimaryTerm; - this.size = builder.size; - this.sort = ApiTypeHelper.unmodifiable(builder.sort); - this.source = builder.source; - this.sourceExcludes = ApiTypeHelper.unmodifiable(builder.sourceExcludes); - this.sourceIncludes = ApiTypeHelper.unmodifiable(builder.sourceIncludes); - this.stats = builder.stats; - this.storedFields = builder.storedFields; - this.suggestField = builder.suggestField; - this.suggestMode = builder.suggestMode; - this.suggestSize = builder.suggestSize; - this.suggestText = builder.suggestText; - this.terminateAfter = builder.terminateAfter; - this.timeout = builder.timeout; - this.trackScores = builder.trackScores; - this.trackTotalHits = builder.trackTotalHits; - this.typedKeys = builder.typedKeys; - this.version = builder.version; - } - - public static PostSearchWithIndexRequest of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final Boolean allowNoIndices() { - return this.allowNoIndices; - } - - public final Boolean allowPartialSearchResults() { - return this.allowPartialSearchResults; - } - - public final Boolean analyzeWildcard() { - return this.analyzeWildcard; - } - - public final String analyzer() { - return this.analyzer; - } - - public final Integer batchedReduceSize() { - return this.batchedReduceSize; - } - - public final Boolean ccsMinimizeRoundtrips() { - return this.ccsMinimizeRoundtrips; - } - - public final DefaultOperator defaultOperator() { - return this.defaultOperator; - } - - public final String df() { - return this.df; - } - - public final String docvalueFields() { - return this.docvalueFields; - } - - public final ExpandWildcards expandWildcards() { - return this.expandWildcards; - } - - public final Boolean explain() { - return this.explain; - } - - public final List fields() { - return this.fields; - } - - public final Integer from() { - return this.from; - } - - public final Boolean ignoreThrottled() { - return this.ignoreThrottled; - } - - public final Boolean ignoreUnavailable() { - return this.ignoreUnavailable; - } - - public final String index() { - return this.index; - } - - public final List indicesBoost() { - return this.indicesBoost; - } - - public final Boolean lenient() { - return this.lenient; - } - - public final Long maxConcurrentShardRequests() { - return this.maxConcurrentShardRequests; - } - - public final Integer minScore() { - return this.minScore; - } - - public final Long preFilterShardSize() { - return this.preFilterShardSize; - } - - public final String preference() { - return this.preference; - } - - public final String q() { - return this.q; - } - - public final UserDefinedObjectStructure query() { - return this.query; - } - - public final Boolean requestCache() { - return this.requestCache; - } - - public final Boolean restTotalHitsAsInt() { - return this.restTotalHitsAsInt; - } - - public final String routing() { - return this.routing; - } - - public final String scroll() { - return this.scroll; - } - - public final SearchType searchType() { - return this.searchType; - } - - public final Boolean seqNoPrimaryTerm() { - return this.seqNoPrimaryTerm; - } - - public final Integer size() { - return this.size; - } - - public final List sort() { - return this.sort; - } - - public final String source() { - return this.source; - } - - public final List sourceExcludes() { - return this.sourceExcludes; - } - - public final List sourceIncludes() { - return this.sourceIncludes; - } - - public final String stats() { - return this.stats; - } - - public final Boolean storedFields() { - return this.storedFields; - } - - public final String suggestField() { - return this.suggestField; - } - - public final SuggestMode suggestMode() { - return this.suggestMode; - } - - public final Long suggestSize() { - return this.suggestSize; - } - - public final String suggestText() { - return this.suggestText; - } - - public final Integer terminateAfter() { - return this.terminateAfter; - } - - public final String timeout() { - return this.timeout; - } - - public final Boolean trackScores() { - return this.trackScores; - } - - public final Integer trackTotalHits() { - return this.trackTotalHits; - } - - public final Boolean typedKeys() { - return this.typedKeys; - } - - public final Boolean version() { - return this.version; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.docvalueFields != null) { - generator.writeKey("docvalue_fields"); - generator.write(this.docvalueFields); - } - - if (this.explain != null) { - generator.writeKey("explain"); - generator.write(this.explain); - } - - if (ApiTypeHelper.isDefined(this.fields)) { - generator.writeKey("fields"); - generator.writeStartArray(); - for (String item0 : this.fields) { - generator.write(item0); - } - generator.writeEnd(); - } - - if (this.from != null) { - generator.writeKey("from"); - generator.write(this.from); - } - - if (ApiTypeHelper.isDefined(this.indicesBoost)) { - generator.writeKey("indices_boost"); - generator.writeStartArray(); - for (JsonData item0 : this.indicesBoost) { - item0.serialize(generator, mapper); - } - generator.writeEnd(); - } - - if (this.minScore != null) { - generator.writeKey("min_score"); - generator.write(this.minScore); - } - - if (this.query != null) { - generator.writeKey("query"); - this.query.serialize(generator, mapper); - } - - if (this.seqNoPrimaryTerm != null) { - generator.writeKey("seq_no_primary_term"); - generator.write(this.seqNoPrimaryTerm); - } - - if (this.size != null) { - generator.writeKey("size"); - generator.write(this.size); - } - - if (this.source != null) { - generator.writeKey("source"); - generator.write(this.source); - } - - if (this.stats != null) { - generator.writeKey("stats"); - generator.write(this.stats); - } - - if (this.terminateAfter != null) { - generator.writeKey("terminate_after"); - generator.write(this.terminateAfter); - } - - if (this.timeout != null) { - generator.writeKey("timeout"); - generator.write(this.timeout); - } - - if (this.version != null) { - generator.writeKey("version"); - generator.write(this.version); - } - } - - /** Builder for {@link PostSearchWithIndexRequest}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private Boolean allowNoIndices; - private Boolean allowPartialSearchResults; - private Boolean analyzeWildcard; - private String analyzer; - private Integer batchedReduceSize; - private Boolean ccsMinimizeRoundtrips; - private DefaultOperator defaultOperator; - private String df; - private String docvalueFields; - private ExpandWildcards expandWildcards; - private Boolean explain; - private List fields; - private Integer from; - private Boolean ignoreThrottled; - private Boolean ignoreUnavailable; - private String index; - private List indicesBoost; - private Boolean lenient; - private Long maxConcurrentShardRequests; - private Integer minScore; - private Long preFilterShardSize; - private String preference; - private String q; - private UserDefinedObjectStructure query; - private Boolean requestCache; - private Boolean restTotalHitsAsInt; - private String routing; - private String scroll; - private SearchType searchType; - private Boolean seqNoPrimaryTerm; - private Integer size; - private List sort; - private String source; - private List sourceExcludes; - private List sourceIncludes; - private String stats; - private Boolean storedFields; - private String suggestField; - private SuggestMode suggestMode; - private Long suggestSize; - private String suggestText; - private Integer terminateAfter; - private String timeout; - private Boolean trackScores; - private Integer trackTotalHits; - private Boolean typedKeys; - private Boolean version; - - public final Builder allowNoIndices(Boolean value) { - this.allowNoIndices = value; - return this; - } - - public final Builder allowPartialSearchResults(Boolean value) { - this.allowPartialSearchResults = value; - return this; - } - - public final Builder analyzeWildcard(Boolean value) { - this.analyzeWildcard = value; - return this; - } - - public final Builder analyzer(String value) { - this.analyzer = value; - return this; - } - - public final Builder batchedReduceSize(Integer value) { - this.batchedReduceSize = value; - return this; - } - - public final Builder ccsMinimizeRoundtrips(Boolean value) { - this.ccsMinimizeRoundtrips = value; - return this; - } - - public final Builder defaultOperator(DefaultOperator value) { - this.defaultOperator = value; - return this; - } - - public final Builder df(String value) { - this.df = value; - return this; - } - - public final Builder docvalueFields(String value) { - this.docvalueFields = value; - return this; - } - - public final Builder expandWildcards(ExpandWildcards value) { - this.expandWildcards = value; - return this; - } - - public final Builder explain(Boolean value) { - this.explain = value; - return this; - } - - public final Builder fields(List list) { - this.fields = _listAddAll(this.fields, list); - return this; - } - - public final Builder fields(String value, String... values) { - this.fields = _listAdd(this.fields, value, values); - return this; - } - - public final Builder from(Integer value) { - this.from = value; - return this; - } - - public final Builder ignoreThrottled(Boolean value) { - this.ignoreThrottled = value; - return this; - } - - public final Builder ignoreUnavailable(Boolean value) { - this.ignoreUnavailable = value; - return this; - } - - public final Builder index(String value) { - this.index = value; - return this; - } - - public final Builder indicesBoost(List list) { - this.indicesBoost = _listAddAll(this.indicesBoost, list); - return this; - } - - public final Builder indicesBoost(JsonData value, JsonData... values) { - this.indicesBoost = _listAdd(this.indicesBoost, value, values); - return this; - } - - public final Builder lenient(Boolean value) { - this.lenient = value; - return this; - } - - public final Builder maxConcurrentShardRequests(Long value) { - this.maxConcurrentShardRequests = value; - return this; - } - - public final Builder minScore(Integer value) { - this.minScore = value; - return this; - } - - public final Builder preFilterShardSize(Long value) { - this.preFilterShardSize = value; - return this; - } - - public final Builder preference(String value) { - this.preference = value; - return this; - } - - public final Builder q(String value) { - this.q = value; - return this; - } - - public final Builder query(UserDefinedObjectStructure value) { - this.query = value; - return this; - } - - public final Builder query( - Function< - UserDefinedObjectStructure.Builder, - ObjectBuilder> - fn) { - return query(fn.apply(new UserDefinedObjectStructure.Builder()).build()); - } - - public final Builder requestCache(Boolean value) { - this.requestCache = value; - return this; - } - - public final Builder restTotalHitsAsInt(Boolean value) { - this.restTotalHitsAsInt = value; - return this; - } - - public final Builder routing(String value) { - this.routing = value; - return this; - } - - public final Builder scroll(String value) { - this.scroll = value; - return this; - } - - public final Builder searchType(SearchType value) { - this.searchType = value; - return this; - } - - public final Builder seqNoPrimaryTerm(Boolean value) { - this.seqNoPrimaryTerm = value; - return this; - } - - public final Builder size(Integer value) { - this.size = value; - return this; - } - - public final Builder sort(List list) { - this.sort = _listAddAll(this.sort, list); - return this; - } - - public final Builder sort(String value, String... values) { - this.sort = _listAdd(this.sort, value, values); - return this; - } - - public final Builder source(String value) { - this.source = value; - return this; - } - - public final Builder sourceExcludes(List list) { - this.sourceExcludes = _listAddAll(this.sourceExcludes, list); - return this; - } - - public final Builder sourceExcludes(String value, String... values) { - this.sourceExcludes = _listAdd(this.sourceExcludes, value, values); - return this; - } - - public final Builder sourceIncludes(List list) { - this.sourceIncludes = _listAddAll(this.sourceIncludes, list); - return this; - } - - public final Builder sourceIncludes(String value, String... values) { - this.sourceIncludes = _listAdd(this.sourceIncludes, value, values); - return this; - } - - public final Builder stats(String value) { - this.stats = value; - return this; - } - - public final Builder storedFields(Boolean value) { - this.storedFields = value; - return this; - } - - public final Builder suggestField(String value) { - this.suggestField = value; - return this; - } - - public final Builder suggestMode(SuggestMode value) { - this.suggestMode = value; - return this; - } - - public final Builder suggestSize(Long value) { - this.suggestSize = value; - return this; - } - - public final Builder suggestText(String value) { - this.suggestText = value; - return this; - } - - public final Builder terminateAfter(Integer value) { - this.terminateAfter = value; - return this; - } - - public final Builder timeout(String value) { - this.timeout = value; - return this; - } - - public final Builder trackScores(Boolean value) { - this.trackScores = value; - return this; - } - - public final Builder trackTotalHits(Integer value) { - this.trackTotalHits = value; - return this; - } - - public final Builder typedKeys(Boolean value) { - this.typedKeys = value; - return this; - } - - public final Builder version(Boolean value) { - this.version = value; - return this; - } - - /** - * Builds a {@link PostSearchWithIndexRequest}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public PostSearchWithIndexRequest build() { - _checkSingleUse(); - - return new PostSearchWithIndexRequest(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, - PostSearchWithIndexRequest::setupPostSearchWithIndexRequestDeserializer); - - protected static void setupPostSearchWithIndexRequestDeserializer( - ObjectDeserializer op) { - op.add(Builder::docvalueFields, JsonpDeserializer.stringDeserializer(), "docvalue_fields"); - op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); - op.add( - Builder::fields, - JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), - "fields"); - op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); - op.add( - Builder::indicesBoost, - JsonpDeserializer.arrayDeserializer(JsonData._DESERIALIZER), - "indices_boost"); - op.add(Builder::minScore, JsonpDeserializer.integerDeserializer(), "min_score"); - op.add(Builder::query, UserDefinedObjectStructure._DESERIALIZER, "query"); - op.add( - Builder::seqNoPrimaryTerm, - JsonpDeserializer.booleanDeserializer(), - "seq_no_primary_term"); - op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); - op.add(Builder::source, JsonpDeserializer.stringDeserializer(), "source"); - op.add(Builder::stats, JsonpDeserializer.stringDeserializer(), "stats"); - op.add(Builder::terminateAfter, JsonpDeserializer.integerDeserializer(), "terminate_after"); - op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); - op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); - } - - public static final Endpoint< - PostSearchWithIndexRequest, PostSearchWithIndexResponse, ErrorResponse> - _ENDPOINT = - new SimpleEndpoint<>( - // Request method - request -> { - return "post"; - }, - // Request path - request -> { - return "/" + request.index + "/_search"; - }, - // Request parameters - request -> { - Map params = new HashMap<>(); - if (request.allowNoIndices != null) { - params.put( - "allow_no_indices", - String.valueOf(request.allowNoIndices)); - } - if (request.allowPartialSearchResults != null) { - params.put( - "allow_partial_search_results", - String.valueOf(request.allowPartialSearchResults)); - } - if (request.analyzeWildcard != null) { - params.put( - "analyze_wildcard", - String.valueOf(request.analyzeWildcard)); - } - if (request.analyzer != null) { - params.put("analyzer", request.analyzer); - } - if (request.batchedReduceSize != null) { - params.put( - "batched_reduce_size", - String.valueOf(request.batchedReduceSize)); - } - if (request.ccsMinimizeRoundtrips != null) { - params.put( - "ccs_minimize_roundtrips", - String.valueOf(request.ccsMinimizeRoundtrips)); - } - if (request.defaultOperator != null) { - params.put( - "default_operator", - request.defaultOperator.jsonValue()); - } - if (request.df != null) { - params.put("df", request.df); - } - if (request.docvalueFields != null) { - params.put("docvalue_fields", request.docvalueFields); - } - if (request.expandWildcards != null) { - params.put( - "expand_wildcards", - request.expandWildcards.jsonValue()); - } - if (request.explain != null) { - params.put("explain", String.valueOf(request.explain)); - } - if (request.from != null) { - params.put("from", String.valueOf(request.from)); - } - if (request.ignoreThrottled != null) { - params.put( - "ignore_throttled", - String.valueOf(request.ignoreThrottled)); - } - if (request.ignoreUnavailable != null) { - params.put( - "ignore_unavailable", - String.valueOf(request.ignoreUnavailable)); - } - if (request.lenient != null) { - params.put("lenient", String.valueOf(request.lenient)); - } - if (request.maxConcurrentShardRequests != null) { - params.put( - "max_concurrent_shard_requests", - String.valueOf(request.maxConcurrentShardRequests)); - } - if (request.preFilterShardSize != null) { - params.put( - "pre_filter_shard_size", - String.valueOf(request.preFilterShardSize)); - } - if (request.preference != null) { - params.put("preference", request.preference); - } - if (request.q != null) { - params.put("q", request.q); - } - if (request.requestCache != null) { - params.put( - "request_cache", String.valueOf(request.requestCache)); - } - if (request.restTotalHitsAsInt != null) { - params.put( - "rest_total_hits_as_int", - String.valueOf(request.restTotalHitsAsInt)); - } - if (request.routing != null) { - params.put("routing", request.routing); - } - if (request.scroll != null) { - params.put("scroll", request.scroll); - } - if (request.searchType != null) { - params.put("search_type", request.searchType.jsonValue()); - } - if (request.seqNoPrimaryTerm != null) { - params.put( - "seq_no_primary_term", - String.valueOf(request.seqNoPrimaryTerm)); - } - if (request.size != null) { - params.put("size", String.valueOf(request.size)); - } - if (ApiTypeHelper.isDefined(request.sort)) { - params.put( - "sort", - request.sort.stream() - .map(v -> v) - .collect(Collectors.joining(","))); - } - if (request.source != null) { - params.put("source", request.source); - } - if (ApiTypeHelper.isDefined(request.sourceExcludes)) { - params.put( - "source_excludes", - request.sourceExcludes.stream() - .map(v -> v) - .collect(Collectors.joining(","))); - } - if (ApiTypeHelper.isDefined(request.sourceIncludes)) { - params.put( - "source_includes", - request.sourceIncludes.stream() - .map(v -> v) - .collect(Collectors.joining(","))); - } - if (request.stats != null) { - params.put("stats", request.stats); - } - if (request.storedFields != null) { - params.put( - "stored_fields", String.valueOf(request.storedFields)); - } - if (request.suggestField != null) { - params.put("suggest_field", request.suggestField); - } - if (request.suggestMode != null) { - params.put("suggest_mode", request.suggestMode.jsonValue()); - } - if (request.suggestSize != null) { - params.put("suggest_size", String.valueOf(request.suggestSize)); - } - if (request.suggestText != null) { - params.put("suggest_text", request.suggestText); - } - if (request.terminateAfter != null) { - params.put( - "terminate_after", - String.valueOf(request.terminateAfter)); - } - if (request.timeout != null) { - params.put("timeout", request.timeout); - } - if (request.trackScores != null) { - params.put("track_scores", String.valueOf(request.trackScores)); - } - if (request.trackTotalHits != null) { - params.put( - "track_total_hits", - String.valueOf(request.trackTotalHits)); - } - if (request.typedKeys != null) { - params.put("typed_keys", String.valueOf(request.typedKeys)); - } - if (request.version != null) { - params.put("version", String.valueOf(request.version)); - } - return params; - }, - SimpleEndpoint.emptyMap(), - true, - PostSearchWithIndexResponse._DESERIALIZER); -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexResponse.java deleted file mode 100644 index 812600c33e..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PostSearchWithIndexResponse.java +++ /dev/null @@ -1,157 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class PostSearchWithIndexResponse implements JsonpSerializable { - - @Nullable private final HitsMetadata hits; - - @Nullable private final String scrollId; - - @Nullable private final ShardStatistics shards; - - @Nullable private final Boolean timedOut; - - @Nullable private final Long took; - - public PostSearchWithIndexResponse(Builder builder) { - this.hits = builder.hits; - this.scrollId = builder.scrollId; - this.shards = builder.shards; - this.timedOut = builder.timedOut; - this.took = builder.took; - } - - public static PostSearchWithIndexResponse of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final HitsMetadata hits() { - return this.hits; - } - - public final String scrollId() { - return this.scrollId; - } - - public final ShardStatistics shards() { - return this.shards; - } - - public final Boolean timedOut() { - return this.timedOut; - } - - public final Long took() { - return this.took; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.hits != null) { - generator.writeKey("hits"); - this.hits.serialize(generator, mapper); - } - - if (this.scrollId != null) { - generator.writeKey("_scroll_id"); - generator.write(this.scrollId); - } - - if (this.shards != null) { - generator.writeKey("_shards"); - this.shards.serialize(generator, mapper); - } - - if (this.timedOut != null) { - generator.writeKey("timed_out"); - generator.write(this.timedOut); - } - - if (this.took != null) { - generator.writeKey("took"); - generator.write(this.took); - } - } - - /** Builder for {@link PostSearchWithIndexResponse}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private HitsMetadata hits; - private String scrollId; - private ShardStatistics shards; - private Boolean timedOut; - private Long took; - - public final Builder hits(HitsMetadata value) { - this.hits = value; - return this; - } - - public final Builder hits(Function> fn) { - return hits(fn.apply(new HitsMetadata.Builder()).build()); - } - - public final Builder scrollId(String value) { - this.scrollId = value; - return this; - } - - public final Builder shards(ShardStatistics value) { - this.shards = value; - return this; - } - - public final Builder shards( - Function> fn) { - return shards(fn.apply(new ShardStatistics.Builder()).build()); - } - - public final Builder timedOut(Boolean value) { - this.timedOut = value; - return this; - } - - public final Builder took(Long value) { - this.took = value; - return this; - } - - /** - * Builds a {@link PostSearchWithIndexResponse}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public PostSearchWithIndexResponse build() { - _checkSingleUse(); - - return new PostSearchWithIndexResponse(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, - PostSearchWithIndexResponse::setupPostSearchWithIndexResponseDeserializer); - - protected static void setupPostSearchWithIndexResponseDeserializer( - ObjectDeserializer op) { - op.add(Builder::hits, HitsMetadata._DESERIALIZER, "hits"); - op.add(Builder::scrollId, JsonpDeserializer.stringDeserializer(), "_scroll_id"); - op.add(Builder::shards, ShardStatistics._DESERIALIZER, "_shards"); - op.add(Builder::timedOut, JsonpDeserializer.booleanDeserializer(), "timed_out"); - op.add(Builder::took, JsonpDeserializer.longDeserializer(), "took"); - } -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java deleted file mode 100644 index fdc88ded9d..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexRequest.java +++ /dev/null @@ -1,271 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.opensearch._types.*; -import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import java.util.stream.*; -import javax.annotation.*; - -/** Creates index mappings. */ -@JsonpDeserializable -public class PutCreateIndexRequest extends RequestBase implements JsonpSerializable { - - @Nullable private final Map aliases; - - @Nullable private final String clusterManagerTimeout; - - @Nullable private final Boolean includeTypeName; - - private final String index; - - @Nullable private final Map mapping; - - @Nullable private final String masterTimeout; - - @Nullable private final Map settings; - - @Nullable private final String timeout; - - @Nullable private final String waitForActiveShards; - - public PutCreateIndexRequest(Builder builder) { - this.aliases = ApiTypeHelper.unmodifiable(builder.aliases); - this.clusterManagerTimeout = builder.clusterManagerTimeout; - this.includeTypeName = builder.includeTypeName; - this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); - this.mapping = ApiTypeHelper.unmodifiable(builder.mapping); - this.masterTimeout = builder.masterTimeout; - this.settings = ApiTypeHelper.unmodifiable(builder.settings); - this.timeout = builder.timeout; - this.waitForActiveShards = builder.waitForActiveShards; - } - - public static PutCreateIndexRequest of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final Map aliases() { - return this.aliases; - } - - public final String clusterManagerTimeout() { - return this.clusterManagerTimeout; - } - - public final Boolean includeTypeName() { - return this.includeTypeName; - } - - public final String index() { - return this.index; - } - - public final Map mapping() { - return this.mapping; - } - - public final String masterTimeout() { - return this.masterTimeout; - } - - public final Map settings() { - return this.settings; - } - - public final String timeout() { - return this.timeout; - } - - public final String waitForActiveShards() { - return this.waitForActiveShards; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (ApiTypeHelper.isDefined(this.aliases)) { - generator.writeKey("aliases"); - generator.writeStartObject(); - for (Map.Entry item0 : this.aliases.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - - if (ApiTypeHelper.isDefined(this.mapping)) { - generator.writeKey("mapping"); - generator.writeStartObject(); - for (Map.Entry item0 : this.mapping.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - - if (ApiTypeHelper.isDefined(this.settings)) { - generator.writeKey("settings"); - generator.writeStartObject(); - for (Map.Entry item0 : this.settings.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - } - - /** Builder for {@link PutCreateIndexRequest}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private Map aliases; - private String clusterManagerTimeout; - private Boolean includeTypeName; - private String index; - private Map mapping; - private String masterTimeout; - private Map settings; - private String timeout; - private String waitForActiveShards; - - public final Builder aliases(Map map) { - this.aliases = _mapPutAll(this.aliases, map); - return this; - } - - public final Builder aliases(String key, JsonData value) { - this.aliases = _mapPut(this.aliases, key, value); - return this; - } - - public final Builder clusterManagerTimeout(String value) { - this.clusterManagerTimeout = value; - return this; - } - - public final Builder includeTypeName(Boolean value) { - this.includeTypeName = value; - return this; - } - - public final Builder index(String value) { - this.index = value; - return this; - } - - public final Builder mapping(Map map) { - this.mapping = _mapPutAll(this.mapping, map); - return this; - } - - public final Builder mapping(String key, JsonData value) { - this.mapping = _mapPut(this.mapping, key, value); - return this; - } - - public final Builder masterTimeout(String value) { - this.masterTimeout = value; - return this; - } - - public final Builder settings(Map map) { - this.settings = _mapPutAll(this.settings, map); - return this; - } - - public final Builder settings(String key, JsonData value) { - this.settings = _mapPut(this.settings, key, value); - return this; - } - - public final Builder timeout(String value) { - this.timeout = value; - return this; - } - - public final Builder waitForActiveShards(String value) { - this.waitForActiveShards = value; - return this; - } - - /** - * Builds a {@link PutCreateIndexRequest}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public PutCreateIndexRequest build() { - _checkSingleUse(); - - return new PutCreateIndexRequest(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, PutCreateIndexRequest::setupPutCreateIndexRequestDeserializer); - - protected static void setupPutCreateIndexRequestDeserializer( - ObjectDeserializer op) { - op.add( - Builder::aliases, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "aliases"); - op.add( - Builder::mapping, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "mapping"); - op.add( - Builder::settings, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "settings"); - } - - public static final Endpoint - _ENDPOINT = - new SimpleEndpoint<>( - // Request method - request -> { - return "put"; - }, - // Request path - request -> { - return "/" + request.index + ""; - }, - // Request parameters - request -> { - Map params = new HashMap<>(); - if (request.clusterManagerTimeout != null) { - params.put( - "cluster_manager_timeout", - request.clusterManagerTimeout); - } - if (request.includeTypeName != null) { - params.put( - "include_type_name", - String.valueOf(request.includeTypeName)); - } - if (request.masterTimeout != null) { - params.put("master_timeout", request.masterTimeout); - } - if (request.timeout != null) { - params.put("timeout", request.timeout); - } - if (request.waitForActiveShards != null) { - params.put( - "wait_for_active_shards", request.waitForActiveShards); - } - return params; - }, - SimpleEndpoint.emptyMap(), - true, - PutCreateIndexResponse._DESERIALIZER); -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexResponse.java deleted file mode 100644 index a6d18ea208..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PutCreateIndexResponse.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class PutCreateIndexResponse implements JsonpSerializable { - - private final boolean acknowledged; - - private final String index; - - private final boolean shardsAcknowledged; - - public PutCreateIndexResponse(Builder builder) { - this.acknowledged = - ApiTypeHelper.requireNonNull(builder.acknowledged, this, "acknowledged"); - this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); - this.shardsAcknowledged = - ApiTypeHelper.requireNonNull( - builder.shardsAcknowledged, this, "shardsAcknowledged"); - } - - public static PutCreateIndexResponse of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final boolean acknowledged() { - return this.acknowledged; - } - - public final String index() { - return this.index; - } - - public final boolean shardsAcknowledged() { - return this.shardsAcknowledged; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("acknowledged"); - generator.write(this.acknowledged); - - generator.writeKey("index"); - generator.write(this.index); - - generator.writeKey("shards_acknowledged"); - generator.write(this.shardsAcknowledged); - } - - /** Builder for {@link PutCreateIndexResponse}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private Boolean acknowledged; - private String index; - private Boolean shardsAcknowledged; - - public final Builder acknowledged(boolean value) { - this.acknowledged = value; - return this; - } - - public final Builder index(String value) { - this.index = value; - return this; - } - - public final Builder shardsAcknowledged(boolean value) { - this.shardsAcknowledged = value; - return this; - } - - /** - * Builds a {@link PutCreateIndexResponse}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public PutCreateIndexResponse build() { - _checkSingleUse(); - - return new PutCreateIndexResponse(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, PutCreateIndexResponse::setupPutCreateIndexResponseDeserializer); - - protected static void setupPutCreateIndexResponseDeserializer( - ObjectDeserializer op) { - op.add(Builder::acknowledged, JsonpDeserializer.booleanDeserializer(), "acknowledged"); - op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "index"); - op.add( - Builder::shardsAcknowledged, - JsonpDeserializer.booleanDeserializer(), - "shards_acknowledged"); - } -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java deleted file mode 100644 index 21b54a78ab..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexRequest.java +++ /dev/null @@ -1,254 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.opensearch._types.*; -import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import java.util.stream.*; -import javax.annotation.*; - -/** The put mapping API operation lets you add new mappings and fields to an index. */ -@JsonpDeserializable -public class PutIndexMappingWithIndexRequest extends RequestBase implements JsonpSerializable { - - @Nullable private final Boolean allowNoIndices; - - @Nullable private final String clusterManagerTimeout; - - @Nullable private final ExpandWildcards expandWildcards; - - @Nullable private final Boolean ignoreUnavailable; - - @Nullable private final Boolean includeTypeName; - - private final String index; - - @Nullable private final String masterTimeout; - - @Nullable private final JsonData properties; - - @Nullable private final String timeout; - - @Nullable private final Boolean writeIndexOnly; - - public PutIndexMappingWithIndexRequest(Builder builder) { - this.allowNoIndices = builder.allowNoIndices; - this.clusterManagerTimeout = builder.clusterManagerTimeout; - this.expandWildcards = builder.expandWildcards; - this.ignoreUnavailable = builder.ignoreUnavailable; - this.includeTypeName = builder.includeTypeName; - this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); - this.masterTimeout = builder.masterTimeout; - this.properties = builder.properties; - this.timeout = builder.timeout; - this.writeIndexOnly = builder.writeIndexOnly; - } - - public static PutIndexMappingWithIndexRequest of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final Boolean allowNoIndices() { - return this.allowNoIndices; - } - - public final String clusterManagerTimeout() { - return this.clusterManagerTimeout; - } - - public final ExpandWildcards expandWildcards() { - return this.expandWildcards; - } - - public final Boolean ignoreUnavailable() { - return this.ignoreUnavailable; - } - - public final Boolean includeTypeName() { - return this.includeTypeName; - } - - public final String index() { - return this.index; - } - - public final String masterTimeout() { - return this.masterTimeout; - } - - public final JsonData properties() { - return this.properties; - } - - public final String timeout() { - return this.timeout; - } - - public final Boolean writeIndexOnly() { - return this.writeIndexOnly; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.properties != null) { - generator.writeKey("properties"); - this.properties.serialize(generator, mapper); - } - } - - /** Builder for {@link PutIndexMappingWithIndexRequest}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private Boolean allowNoIndices; - private String clusterManagerTimeout; - private ExpandWildcards expandWildcards; - private Boolean ignoreUnavailable; - private Boolean includeTypeName; - private String index; - private String masterTimeout; - private JsonData properties; - private String timeout; - private Boolean writeIndexOnly; - - public final Builder allowNoIndices(Boolean value) { - this.allowNoIndices = value; - return this; - } - - public final Builder clusterManagerTimeout(String value) { - this.clusterManagerTimeout = value; - return this; - } - - public final Builder expandWildcards(ExpandWildcards value) { - this.expandWildcards = value; - return this; - } - - public final Builder ignoreUnavailable(Boolean value) { - this.ignoreUnavailable = value; - return this; - } - - public final Builder includeTypeName(Boolean value) { - this.includeTypeName = value; - return this; - } - - public final Builder index(String value) { - this.index = value; - return this; - } - - public final Builder masterTimeout(String value) { - this.masterTimeout = value; - return this; - } - - public final Builder properties(JsonData value) { - this.properties = value; - return this; - } - - public final Builder timeout(String value) { - this.timeout = value; - return this; - } - - public final Builder writeIndexOnly(Boolean value) { - this.writeIndexOnly = value; - return this; - } - - /** - * Builds a {@link PutIndexMappingWithIndexRequest}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public PutIndexMappingWithIndexRequest build() { - _checkSingleUse(); - - return new PutIndexMappingWithIndexRequest(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, - PutIndexMappingWithIndexRequest - ::setupPutIndexMappingWithIndexRequestDeserializer); - - protected static void setupPutIndexMappingWithIndexRequestDeserializer( - ObjectDeserializer op) { - op.add(Builder::properties, JsonData._DESERIALIZER, "properties"); - } - - public static final Endpoint< - PutIndexMappingWithIndexRequest, - PutIndexMappingWithIndexResponse, - ErrorResponse> - _ENDPOINT = - new SimpleEndpoint<>( - // Request method - request -> { - return "put"; - }, - // Request path - request -> { - return "/" + request.index + "/_mapping"; - }, - // Request parameters - request -> { - Map params = new HashMap<>(); - if (request.allowNoIndices != null) { - params.put( - "allow_no_indices", - String.valueOf(request.allowNoIndices)); - } - if (request.clusterManagerTimeout != null) { - params.put( - "cluster_manager_timeout", - request.clusterManagerTimeout); - } - if (request.expandWildcards != null) { - params.put( - "expand_wildcards", - request.expandWildcards.jsonValue()); - } - if (request.ignoreUnavailable != null) { - params.put( - "ignore_unavailable", - String.valueOf(request.ignoreUnavailable)); - } - if (request.includeTypeName != null) { - params.put( - "include_type_name", - String.valueOf(request.includeTypeName)); - } - if (request.masterTimeout != null) { - params.put("master_timeout", request.masterTimeout); - } - if (request.timeout != null) { - params.put("timeout", request.timeout); - } - if (request.writeIndexOnly != null) { - params.put( - "write_index_only", - String.valueOf(request.writeIndexOnly)); - } - return params; - }, - SimpleEndpoint.emptyMap(), - true, - PutIndexMappingWithIndexResponse._DESERIALIZER); -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexResponse.java deleted file mode 100644 index 996f291c39..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PutIndexMappingWithIndexResponse.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class PutIndexMappingWithIndexResponse implements JsonpSerializable { - - @Nullable private final Boolean acknowledged; - - public PutIndexMappingWithIndexResponse(Builder builder) { - this.acknowledged = builder.acknowledged; - } - - public static PutIndexMappingWithIndexResponse of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final Boolean acknowledged() { - return this.acknowledged; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.acknowledged != null) { - generator.writeKey("acknowledged"); - generator.write(this.acknowledged); - } - } - - /** Builder for {@link PutIndexMappingWithIndexResponse}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private Boolean acknowledged; - - public final Builder acknowledged(Boolean value) { - this.acknowledged = value; - return this; - } - - /** - * Builds a {@link PutIndexMappingWithIndexResponse}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public PutIndexMappingWithIndexResponse build() { - _checkSingleUse(); - - return new PutIndexMappingWithIndexResponse(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, - PutIndexMappingWithIndexResponse - ::setupPutIndexMappingWithIndexResponseDeserializer); - - protected static void setupPutIndexMappingWithIndexResponseDeserializer( - ObjectDeserializer op) { - op.add(Builder::acknowledged, JsonpDeserializer.booleanDeserializer(), "acknowledged"); - } -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsRequest.java deleted file mode 100644 index d8c4d50354..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsRequest.java +++ /dev/null @@ -1,213 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.opensearch._types.*; -import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import java.util.stream.*; -import javax.annotation.*; - -/** Updates the cluster settings. */ -@JsonpDeserializable -public class PutUpdateClusterSettingsRequest extends RequestBase implements JsonpSerializable { - - @Nullable private final String clusterManagerTimeout; - - @Nullable private final Boolean flatSettings; - - @Nullable private final String masterTimeout; - - @Nullable private final Map persistent; - - @Nullable private final String timeout; - - @Nullable private final Map transient_; - - public PutUpdateClusterSettingsRequest(Builder builder) { - this.clusterManagerTimeout = builder.clusterManagerTimeout; - this.flatSettings = builder.flatSettings; - this.masterTimeout = builder.masterTimeout; - this.persistent = ApiTypeHelper.unmodifiable(builder.persistent); - this.timeout = builder.timeout; - this.transient_ = ApiTypeHelper.unmodifiable(builder.transient_); - } - - public static PutUpdateClusterSettingsRequest of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final String clusterManagerTimeout() { - return this.clusterManagerTimeout; - } - - public final Boolean flatSettings() { - return this.flatSettings; - } - - public final String masterTimeout() { - return this.masterTimeout; - } - - public final Map persistent() { - return this.persistent; - } - - public final String timeout() { - return this.timeout; - } - - public final Map transient_() { - return this.transient_; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (ApiTypeHelper.isDefined(this.persistent)) { - generator.writeKey("persistent"); - generator.writeStartObject(); - for (Map.Entry item0 : this.persistent.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - - if (ApiTypeHelper.isDefined(this.transient_)) { - generator.writeKey("transient"); - generator.writeStartObject(); - for (Map.Entry item0 : this.transient_.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - } - - /** Builder for {@link PutUpdateClusterSettingsRequest}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private String clusterManagerTimeout; - private Boolean flatSettings; - private String masterTimeout; - private Map persistent; - private String timeout; - private Map transient_; - - public final Builder clusterManagerTimeout(String value) { - this.clusterManagerTimeout = value; - return this; - } - - public final Builder flatSettings(Boolean value) { - this.flatSettings = value; - return this; - } - - public final Builder masterTimeout(String value) { - this.masterTimeout = value; - return this; - } - - public final Builder persistent(Map map) { - this.persistent = _mapPutAll(this.persistent, map); - return this; - } - - public final Builder persistent(String key, JsonData value) { - this.persistent = _mapPut(this.persistent, key, value); - return this; - } - - public final Builder timeout(String value) { - this.timeout = value; - return this; - } - - public final Builder transient_(Map map) { - this.transient_ = _mapPutAll(this.transient_, map); - return this; - } - - public final Builder transient_(String key, JsonData value) { - this.transient_ = _mapPut(this.transient_, key, value); - return this; - } - - /** - * Builds a {@link PutUpdateClusterSettingsRequest}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public PutUpdateClusterSettingsRequest build() { - _checkSingleUse(); - - return new PutUpdateClusterSettingsRequest(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, - PutUpdateClusterSettingsRequest - ::setupPutUpdateClusterSettingsRequestDeserializer); - - protected static void setupPutUpdateClusterSettingsRequestDeserializer( - ObjectDeserializer op) { - op.add( - Builder::persistent, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "persistent"); - op.add( - Builder::transient_, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "transient"); - } - - public static final Endpoint< - PutUpdateClusterSettingsRequest, - PutUpdateClusterSettingsResponse, - ErrorResponse> - _ENDPOINT = - new SimpleEndpoint<>( - // Request method - request -> { - return "put"; - }, - // Request path - request -> { - return "/_cluster/settings"; - }, - // Request parameters - request -> { - Map params = new HashMap<>(); - if (request.clusterManagerTimeout != null) { - params.put( - "cluster_manager_timeout", - request.clusterManagerTimeout); - } - if (request.flatSettings != null) { - params.put( - "flat_settings", String.valueOf(request.flatSettings)); - } - if (request.masterTimeout != null) { - params.put("master_timeout", request.masterTimeout); - } - if (request.timeout != null) { - params.put("timeout", request.timeout); - } - return params; - }, - SimpleEndpoint.emptyMap(), - true, - PutUpdateClusterSettingsResponse._DESERIALIZER); -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsResponse.java deleted file mode 100644 index e2ef0420d5..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/PutUpdateClusterSettingsResponse.java +++ /dev/null @@ -1,137 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class PutUpdateClusterSettingsResponse implements JsonpSerializable { - - @Nullable private final Boolean acknowledged; - - @Nullable private final Map persistent; - - @Nullable private final Map transient_; - - public PutUpdateClusterSettingsResponse(Builder builder) { - this.acknowledged = builder.acknowledged; - this.persistent = ApiTypeHelper.unmodifiable(builder.persistent); - this.transient_ = ApiTypeHelper.unmodifiable(builder.transient_); - } - - public static PutUpdateClusterSettingsResponse of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final Boolean acknowledged() { - return this.acknowledged; - } - - public final Map persistent() { - return this.persistent; - } - - public final Map transient_() { - return this.transient_; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.acknowledged != null) { - generator.writeKey("acknowledged"); - generator.write(this.acknowledged); - } - - if (ApiTypeHelper.isDefined(this.persistent)) { - generator.writeKey("persistent"); - generator.writeStartObject(); - for (Map.Entry item0 : this.persistent.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - - if (ApiTypeHelper.isDefined(this.transient_)) { - generator.writeKey("transient"); - generator.writeStartObject(); - for (Map.Entry item0 : this.transient_.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - } - - /** Builder for {@link PutUpdateClusterSettingsResponse}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private Boolean acknowledged; - private Map persistent; - private Map transient_; - - public final Builder acknowledged(Boolean value) { - this.acknowledged = value; - return this; - } - - public final Builder persistent(Map map) { - this.persistent = _mapPutAll(this.persistent, map); - return this; - } - - public final Builder persistent(String key, JsonData value) { - this.persistent = _mapPut(this.persistent, key, value); - return this; - } - - public final Builder transient_(Map map) { - this.transient_ = _mapPutAll(this.transient_, map); - return this; - } - - public final Builder transient_(String key, JsonData value) { - this.transient_ = _mapPut(this.transient_, key, value); - return this; - } - - /** - * Builds a {@link PutUpdateClusterSettingsResponse}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public PutUpdateClusterSettingsResponse build() { - _checkSingleUse(); - - return new PutUpdateClusterSettingsResponse(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, - PutUpdateClusterSettingsResponse - ::setupPutUpdateClusterSettingsResponseDeserializer); - - protected static void setupPutUpdateClusterSettingsResponseDeserializer( - ObjectDeserializer op) { - op.add(Builder::acknowledged, JsonpDeserializer.booleanDeserializer(), "acknowledged"); - op.add( - Builder::persistent, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "persistent"); - op.add( - Builder::transient_, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "transient"); - } -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/Relation.java b/java-client/src/generated/java/org/opensearch/client/opensearch/Relation.java deleted file mode 100644 index 6f4a04142b..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/Relation.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.JsonEnum; -import org.opensearch.client.json.JsonpDeserializable; - -@JsonpDeserializable -public enum Relation implements JsonEnum { - Eq("eq"), - Gte("gte"), - ; - - private final String jsonValue; - private final String[] aliases; - - Relation(String jsonValue, String... aliases) { - this.jsonValue = jsonValue; - this.aliases = aliases; - } - - public String jsonValue() { - return this.jsonValue; - } - - public String[] aliases() { - return this.aliases; - } - - public static final JsonEnum.Deserializer _DESERIALIZER = - new JsonEnum.Deserializer<>(Relation.values()); -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreInfo.java b/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreInfo.java deleted file mode 100644 index 8ab1fad1ab..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreInfo.java +++ /dev/null @@ -1,129 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class RemoteStoreRestoreInfo implements JsonpSerializable { - - @Nullable private final List indices; - - @Nullable private final RemoteStoreRestoreShardsInfo shards; - - @Nullable private final String snapshot; - - public RemoteStoreRestoreInfo(Builder builder) { - this.indices = ApiTypeHelper.unmodifiable(builder.indices); - this.shards = builder.shards; - this.snapshot = builder.snapshot; - } - - public static RemoteStoreRestoreInfo of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final List indices() { - return this.indices; - } - - public final RemoteStoreRestoreShardsInfo shards() { - return this.shards; - } - - public final String snapshot() { - return this.snapshot; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (ApiTypeHelper.isDefined(this.indices)) { - generator.writeKey("indices"); - generator.writeStartArray(); - for (String item0 : this.indices) { - generator.write(item0); - } - generator.writeEnd(); - } - - if (this.shards != null) { - generator.writeKey("shards"); - this.shards.serialize(generator, mapper); - } - - if (this.snapshot != null) { - generator.writeKey("snapshot"); - generator.write(this.snapshot); - } - } - - /** Builder for {@link RemoteStoreRestoreInfo}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private List indices; - private RemoteStoreRestoreShardsInfo shards; - private String snapshot; - - public final Builder indices(List list) { - this.indices = _listAddAll(this.indices, list); - return this; - } - - public final Builder indices(String value, String... values) { - this.indices = _listAdd(this.indices, value, values); - return this; - } - - public final Builder shards(RemoteStoreRestoreShardsInfo value) { - this.shards = value; - return this; - } - - public final Builder shards( - Function< - RemoteStoreRestoreShardsInfo.Builder, - ObjectBuilder> - fn) { - return shards(fn.apply(new RemoteStoreRestoreShardsInfo.Builder()).build()); - } - - public final Builder snapshot(String value) { - this.snapshot = value; - return this; - } - - /** - * Builds a {@link RemoteStoreRestoreInfo}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public RemoteStoreRestoreInfo build() { - _checkSingleUse(); - - return new RemoteStoreRestoreInfo(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, RemoteStoreRestoreInfo::setupRemoteStoreRestoreInfoDeserializer); - - protected static void setupRemoteStoreRestoreInfoDeserializer( - ObjectDeserializer op) { - op.add( - Builder::indices, - JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), - "indices"); - op.add(Builder::shards, RemoteStoreRestoreShardsInfo._DESERIALIZER, "shards"); - op.add(Builder::snapshot, JsonpDeserializer.stringDeserializer(), "snapshot"); - } -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreShardsInfo.java b/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreShardsInfo.java deleted file mode 100644 index 222c8e10b4..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/RemoteStoreRestoreShardsInfo.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class RemoteStoreRestoreShardsInfo implements JsonpSerializable { - - @Nullable private final Integer failed; - - @Nullable private final Integer successful; - - @Nullable private final Integer total; - - public RemoteStoreRestoreShardsInfo(Builder builder) { - this.failed = builder.failed; - this.successful = builder.successful; - this.total = builder.total; - } - - public static RemoteStoreRestoreShardsInfo of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final Integer failed() { - return this.failed; - } - - public final Integer successful() { - return this.successful; - } - - public final Integer total() { - return this.total; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.failed != null) { - generator.writeKey("failed"); - generator.write(this.failed); - } - - if (this.successful != null) { - generator.writeKey("successful"); - generator.write(this.successful); - } - - if (this.total != null) { - generator.writeKey("total"); - generator.write(this.total); - } - } - - /** Builder for {@link RemoteStoreRestoreShardsInfo}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private Integer failed; - private Integer successful; - private Integer total; - - public final Builder failed(Integer value) { - this.failed = value; - return this; - } - - public final Builder successful(Integer value) { - this.successful = value; - return this; - } - - public final Builder total(Integer value) { - this.total = value; - return this; - } - - /** - * Builds a {@link RemoteStoreRestoreShardsInfo}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public RemoteStoreRestoreShardsInfo build() { - _checkSingleUse(); - - return new RemoteStoreRestoreShardsInfo(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, - RemoteStoreRestoreShardsInfo::setupRemoteStoreRestoreShardsInfoDeserializer); - - protected static void setupRemoteStoreRestoreShardsInfoDeserializer( - ObjectDeserializer op) { - op.add(Builder::failed, JsonpDeserializer.integerDeserializer(), "failed"); - op.add(Builder::successful, JsonpDeserializer.integerDeserializer(), "successful"); - op.add(Builder::total, JsonpDeserializer.integerDeserializer(), "total"); - } -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/SearchType.java b/java-client/src/generated/java/org/opensearch/client/opensearch/SearchType.java deleted file mode 100644 index cac4758c0e..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/SearchType.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.JsonEnum; -import org.opensearch.client.json.JsonpDeserializable; - -@JsonpDeserializable -public enum SearchType implements JsonEnum { - QueryThenFetch("query_then_fetch"), - DfsQueryThenFetch("dfs_query_then_fetch"), - ; - - private final String jsonValue; - private final String[] aliases; - - SearchType(String jsonValue, String... aliases) { - this.jsonValue = jsonValue; - this.aliases = aliases; - } - - public String jsonValue() { - return this.jsonValue; - } - - public String[] aliases() { - return this.aliases; - } - - public static final JsonEnum.Deserializer _DESERIALIZER = - new JsonEnum.Deserializer<>(SearchType.values()); -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ShardStatistics.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ShardStatistics.java deleted file mode 100644 index a5c5a544c7..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ShardStatistics.java +++ /dev/null @@ -1,127 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class ShardStatistics implements JsonpSerializable { - - @Nullable private final Integer failed; - - @Nullable private final Integer skipped; - - @Nullable private final Integer successful; - - @Nullable private final Integer total; - - public ShardStatistics(Builder builder) { - this.failed = builder.failed; - this.skipped = builder.skipped; - this.successful = builder.successful; - this.total = builder.total; - } - - public static ShardStatistics of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final Integer failed() { - return this.failed; - } - - public final Integer skipped() { - return this.skipped; - } - - public final Integer successful() { - return this.successful; - } - - public final Integer total() { - return this.total; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.failed != null) { - generator.writeKey("failed"); - generator.write(this.failed); - } - - if (this.skipped != null) { - generator.writeKey("skipped"); - generator.write(this.skipped); - } - - if (this.successful != null) { - generator.writeKey("successful"); - generator.write(this.successful); - } - - if (this.total != null) { - generator.writeKey("total"); - generator.write(this.total); - } - } - - /** Builder for {@link ShardStatistics}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private Integer failed; - private Integer skipped; - private Integer successful; - private Integer total; - - public final Builder failed(Integer value) { - this.failed = value; - return this; - } - - public final Builder skipped(Integer value) { - this.skipped = value; - return this; - } - - public final Builder successful(Integer value) { - this.successful = value; - return this; - } - - public final Builder total(Integer value) { - this.total = value; - return this; - } - - /** - * Builds a {@link ShardStatistics}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public ShardStatistics build() { - _checkSingleUse(); - - return new ShardStatistics(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, ShardStatistics::setupShardStatisticsDeserializer); - - protected static void setupShardStatisticsDeserializer( - ObjectDeserializer op) { - op.add(Builder::failed, JsonpDeserializer.integerDeserializer(), "failed"); - op.add(Builder::skipped, JsonpDeserializer.integerDeserializer(), "skipped"); - op.add(Builder::successful, JsonpDeserializer.integerDeserializer(), "successful"); - op.add(Builder::total, JsonpDeserializer.integerDeserializer(), "total"); - } -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/SuggestMode.java b/java-client/src/generated/java/org/opensearch/client/opensearch/SuggestMode.java deleted file mode 100644 index 5e7366665c..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/SuggestMode.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.JsonEnum; -import org.opensearch.client.json.JsonpDeserializable; - -@JsonpDeserializable -public enum SuggestMode implements JsonEnum { - Missing("missing"), - Popular("popular"), - Always("always"), - ; - - private final String jsonValue; - private final String[] aliases; - - SuggestMode(String jsonValue, String... aliases) { - this.jsonValue = jsonValue; - this.aliases = aliases; - } - - public String jsonValue() { - return this.jsonValue; - } - - public String[] aliases() { - return this.aliases; - } - - public static final JsonEnum.Deserializer _DESERIALIZER = - new JsonEnum.Deserializer<>(SuggestMode.values()); -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/Total.java b/java-client/src/generated/java/org/opensearch/client/opensearch/Total.java deleted file mode 100644 index 3a9fe5450a..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/Total.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class Total implements JsonpSerializable { - - @Nullable private final Relation relation; - - @Nullable private final Integer value; - - public Total(Builder builder) { - this.relation = builder.relation; - this.value = builder.value; - } - - public static Total of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final Relation relation() { - return this.relation; - } - - public final Integer value() { - return this.value; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.relation != null) { - generator.writeKey("relation"); - this.relation.serialize(generator, mapper); - } - - if (this.value != null) { - generator.writeKey("value"); - generator.write(this.value); - } - } - - /** Builder for {@link Total}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Relation relation; - private Integer value; - - public final Builder relation(Relation value) { - this.relation = value; - return this; - } - - public final Builder value(Integer value) { - this.value = value; - return this; - } - - /** - * Builds a {@link Total}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public Total build() { - _checkSingleUse(); - - return new Total(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy(Builder::new, Total::setupTotalDeserializer); - - protected static void setupTotalDeserializer(ObjectDeserializer op) { - op.add(Builder::relation, Relation._DESERIALIZER, "relation"); - op.add(Builder::value, JsonpDeserializer.integerDeserializer(), "value"); - } -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedObjectStructure.java b/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedObjectStructure.java deleted file mode 100644 index a6832226a5..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedObjectStructure.java +++ /dev/null @@ -1,1229 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class UserDefinedObjectStructure implements JsonpSerializable { - - @Nullable private final JsonData bool; - - @Nullable private final JsonData boosting; - - @Nullable private final JsonData combinedFields; - - @Nullable private final JsonData constantScore; - - @Nullable private final JsonData disMax; - - @Nullable private final JsonData distanceFeature; - - @Nullable private final JsonData exists; - - @Nullable private final JsonData fieldMaskingSpan; - - @Nullable private final JsonData functionScore; - - @Nullable private final Map fuzzy; - - @Nullable private final JsonData geoBoundingBox; - - @Nullable private final JsonData geoDistance; - - @Nullable private final JsonData geoPolygon; - - @Nullable private final JsonData geoShape; - - @Nullable private final JsonData hasChild; - - @Nullable private final JsonData hasParent; - - @Nullable private final JsonData ids; - - @Nullable private final Map intervals; - - @Nullable private final JsonData knn; - - @Nullable private final Map match; - - @Nullable private final JsonData matchAll; - - @Nullable private final Map matchBoolPrefix; - - @Nullable private final JsonData matchNone; - - @Nullable private final Map matchPhrase; - - @Nullable private final Map matchPhrasePrefix; - - @Nullable private final JsonData moreLikeThis; - - @Nullable private final JsonData multiMatch; - - @Nullable private final JsonData nested; - - @Nullable private final JsonData parentId; - - @Nullable private final JsonData percolate; - - @Nullable private final JsonData pinned; - - @Nullable private final Map prefix; - - @Nullable private final JsonData queryString; - - @Nullable private final Map range; - - @Nullable private final JsonData rankFeature; - - @Nullable private final Map regexp; - - @Nullable private final JsonData script; - - @Nullable private final JsonData scriptScore; - - @Nullable private final JsonData shape; - - @Nullable private final JsonData simpleQueryString; - - @Nullable private final JsonData spanContaining; - - @Nullable private final JsonData spanFirst; - - @Nullable private final JsonData spanMulti; - - @Nullable private final JsonData spanNear; - - @Nullable private final JsonData spanNot; - - @Nullable private final JsonData spanOr; - - @Nullable private final Map spanTerm; - - @Nullable private final JsonData spanWithin; - - @Nullable private final Map term; - - @Nullable private final JsonData terms; - - @Nullable private final Map termsSet; - - @Nullable private final Map wildcard; - - @Nullable private final JsonData wrapper; - - public UserDefinedObjectStructure(Builder builder) { - this.bool = builder.bool; - this.boosting = builder.boosting; - this.combinedFields = builder.combinedFields; - this.constantScore = builder.constantScore; - this.disMax = builder.disMax; - this.distanceFeature = builder.distanceFeature; - this.exists = builder.exists; - this.fieldMaskingSpan = builder.fieldMaskingSpan; - this.functionScore = builder.functionScore; - this.fuzzy = ApiTypeHelper.unmodifiable(builder.fuzzy); - this.geoBoundingBox = builder.geoBoundingBox; - this.geoDistance = builder.geoDistance; - this.geoPolygon = builder.geoPolygon; - this.geoShape = builder.geoShape; - this.hasChild = builder.hasChild; - this.hasParent = builder.hasParent; - this.ids = builder.ids; - this.intervals = ApiTypeHelper.unmodifiable(builder.intervals); - this.knn = builder.knn; - this.match = ApiTypeHelper.unmodifiable(builder.match); - this.matchAll = builder.matchAll; - this.matchBoolPrefix = ApiTypeHelper.unmodifiable(builder.matchBoolPrefix); - this.matchNone = builder.matchNone; - this.matchPhrase = ApiTypeHelper.unmodifiable(builder.matchPhrase); - this.matchPhrasePrefix = ApiTypeHelper.unmodifiable(builder.matchPhrasePrefix); - this.moreLikeThis = builder.moreLikeThis; - this.multiMatch = builder.multiMatch; - this.nested = builder.nested; - this.parentId = builder.parentId; - this.percolate = builder.percolate; - this.pinned = builder.pinned; - this.prefix = ApiTypeHelper.unmodifiable(builder.prefix); - this.queryString = builder.queryString; - this.range = ApiTypeHelper.unmodifiable(builder.range); - this.rankFeature = builder.rankFeature; - this.regexp = ApiTypeHelper.unmodifiable(builder.regexp); - this.script = builder.script; - this.scriptScore = builder.scriptScore; - this.shape = builder.shape; - this.simpleQueryString = builder.simpleQueryString; - this.spanContaining = builder.spanContaining; - this.spanFirst = builder.spanFirst; - this.spanMulti = builder.spanMulti; - this.spanNear = builder.spanNear; - this.spanNot = builder.spanNot; - this.spanOr = builder.spanOr; - this.spanTerm = ApiTypeHelper.unmodifiable(builder.spanTerm); - this.spanWithin = builder.spanWithin; - this.term = ApiTypeHelper.unmodifiable(builder.term); - this.terms = builder.terms; - this.termsSet = ApiTypeHelper.unmodifiable(builder.termsSet); - this.wildcard = ApiTypeHelper.unmodifiable(builder.wildcard); - this.wrapper = builder.wrapper; - } - - public static UserDefinedObjectStructure of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final JsonData bool() { - return this.bool; - } - - public final JsonData boosting() { - return this.boosting; - } - - public final JsonData combinedFields() { - return this.combinedFields; - } - - public final JsonData constantScore() { - return this.constantScore; - } - - public final JsonData disMax() { - return this.disMax; - } - - public final JsonData distanceFeature() { - return this.distanceFeature; - } - - public final JsonData exists() { - return this.exists; - } - - public final JsonData fieldMaskingSpan() { - return this.fieldMaskingSpan; - } - - public final JsonData functionScore() { - return this.functionScore; - } - - public final Map fuzzy() { - return this.fuzzy; - } - - public final JsonData geoBoundingBox() { - return this.geoBoundingBox; - } - - public final JsonData geoDistance() { - return this.geoDistance; - } - - public final JsonData geoPolygon() { - return this.geoPolygon; - } - - public final JsonData geoShape() { - return this.geoShape; - } - - public final JsonData hasChild() { - return this.hasChild; - } - - public final JsonData hasParent() { - return this.hasParent; - } - - public final JsonData ids() { - return this.ids; - } - - public final Map intervals() { - return this.intervals; - } - - public final JsonData knn() { - return this.knn; - } - - public final Map match() { - return this.match; - } - - public final JsonData matchAll() { - return this.matchAll; - } - - public final Map matchBoolPrefix() { - return this.matchBoolPrefix; - } - - public final JsonData matchNone() { - return this.matchNone; - } - - public final Map matchPhrase() { - return this.matchPhrase; - } - - public final Map matchPhrasePrefix() { - return this.matchPhrasePrefix; - } - - public final JsonData moreLikeThis() { - return this.moreLikeThis; - } - - public final JsonData multiMatch() { - return this.multiMatch; - } - - public final JsonData nested() { - return this.nested; - } - - public final JsonData parentId() { - return this.parentId; - } - - public final JsonData percolate() { - return this.percolate; - } - - public final JsonData pinned() { - return this.pinned; - } - - public final Map prefix() { - return this.prefix; - } - - public final JsonData queryString() { - return this.queryString; - } - - public final Map range() { - return this.range; - } - - public final JsonData rankFeature() { - return this.rankFeature; - } - - public final Map regexp() { - return this.regexp; - } - - public final JsonData script() { - return this.script; - } - - public final JsonData scriptScore() { - return this.scriptScore; - } - - public final JsonData shape() { - return this.shape; - } - - public final JsonData simpleQueryString() { - return this.simpleQueryString; - } - - public final JsonData spanContaining() { - return this.spanContaining; - } - - public final JsonData spanFirst() { - return this.spanFirst; - } - - public final JsonData spanMulti() { - return this.spanMulti; - } - - public final JsonData spanNear() { - return this.spanNear; - } - - public final JsonData spanNot() { - return this.spanNot; - } - - public final JsonData spanOr() { - return this.spanOr; - } - - public final Map spanTerm() { - return this.spanTerm; - } - - public final JsonData spanWithin() { - return this.spanWithin; - } - - public final Map term() { - return this.term; - } - - public final JsonData terms() { - return this.terms; - } - - public final Map termsSet() { - return this.termsSet; - } - - public final Map wildcard() { - return this.wildcard; - } - - public final JsonData wrapper() { - return this.wrapper; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.bool != null) { - generator.writeKey("bool"); - this.bool.serialize(generator, mapper); - } - - if (this.boosting != null) { - generator.writeKey("boosting"); - this.boosting.serialize(generator, mapper); - } - - if (this.combinedFields != null) { - generator.writeKey("combined_fields"); - this.combinedFields.serialize(generator, mapper); - } - - if (this.constantScore != null) { - generator.writeKey("constant_score"); - this.constantScore.serialize(generator, mapper); - } - - if (this.disMax != null) { - generator.writeKey("dis_max"); - this.disMax.serialize(generator, mapper); - } - - if (this.distanceFeature != null) { - generator.writeKey("distance_feature"); - this.distanceFeature.serialize(generator, mapper); - } - - if (this.exists != null) { - generator.writeKey("exists"); - this.exists.serialize(generator, mapper); - } - - if (this.fieldMaskingSpan != null) { - generator.writeKey("field_masking_span"); - this.fieldMaskingSpan.serialize(generator, mapper); - } - - if (this.functionScore != null) { - generator.writeKey("function_score"); - this.functionScore.serialize(generator, mapper); - } - - if (ApiTypeHelper.isDefined(this.fuzzy)) { - generator.writeKey("fuzzy"); - generator.writeStartObject(); - for (Map.Entry item0 : this.fuzzy.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - - if (this.geoBoundingBox != null) { - generator.writeKey("geo_bounding_box"); - this.geoBoundingBox.serialize(generator, mapper); - } - - if (this.geoDistance != null) { - generator.writeKey("geo_distance"); - this.geoDistance.serialize(generator, mapper); - } - - if (this.geoPolygon != null) { - generator.writeKey("geo_polygon"); - this.geoPolygon.serialize(generator, mapper); - } - - if (this.geoShape != null) { - generator.writeKey("geo_shape"); - this.geoShape.serialize(generator, mapper); - } - - if (this.hasChild != null) { - generator.writeKey("has_child"); - this.hasChild.serialize(generator, mapper); - } - - if (this.hasParent != null) { - generator.writeKey("has_parent"); - this.hasParent.serialize(generator, mapper); - } - - if (this.ids != null) { - generator.writeKey("ids"); - this.ids.serialize(generator, mapper); - } - - if (ApiTypeHelper.isDefined(this.intervals)) { - generator.writeKey("intervals"); - generator.writeStartObject(); - for (Map.Entry item0 : this.intervals.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - - if (this.knn != null) { - generator.writeKey("knn"); - this.knn.serialize(generator, mapper); - } - - if (ApiTypeHelper.isDefined(this.match)) { - generator.writeKey("match"); - generator.writeStartObject(); - for (Map.Entry item0 : this.match.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - - if (this.matchAll != null) { - generator.writeKey("match_all"); - this.matchAll.serialize(generator, mapper); - } - - if (ApiTypeHelper.isDefined(this.matchBoolPrefix)) { - generator.writeKey("match_bool_prefix"); - generator.writeStartObject(); - for (Map.Entry item0 : this.matchBoolPrefix.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - - if (this.matchNone != null) { - generator.writeKey("match_none"); - this.matchNone.serialize(generator, mapper); - } - - if (ApiTypeHelper.isDefined(this.matchPhrase)) { - generator.writeKey("match_phrase"); - generator.writeStartObject(); - for (Map.Entry item0 : this.matchPhrase.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - - if (ApiTypeHelper.isDefined(this.matchPhrasePrefix)) { - generator.writeKey("match_phrase_prefix"); - generator.writeStartObject(); - for (Map.Entry item0 : this.matchPhrasePrefix.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - - if (this.moreLikeThis != null) { - generator.writeKey("more_like_this"); - this.moreLikeThis.serialize(generator, mapper); - } - - if (this.multiMatch != null) { - generator.writeKey("multi_match"); - this.multiMatch.serialize(generator, mapper); - } - - if (this.nested != null) { - generator.writeKey("nested"); - this.nested.serialize(generator, mapper); - } - - if (this.parentId != null) { - generator.writeKey("parent_id"); - this.parentId.serialize(generator, mapper); - } - - if (this.percolate != null) { - generator.writeKey("percolate"); - this.percolate.serialize(generator, mapper); - } - - if (this.pinned != null) { - generator.writeKey("pinned"); - this.pinned.serialize(generator, mapper); - } - - if (ApiTypeHelper.isDefined(this.prefix)) { - generator.writeKey("prefix"); - generator.writeStartObject(); - for (Map.Entry item0 : this.prefix.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - - if (this.queryString != null) { - generator.writeKey("query_string"); - this.queryString.serialize(generator, mapper); - } - - if (ApiTypeHelper.isDefined(this.range)) { - generator.writeKey("range"); - generator.writeStartObject(); - for (Map.Entry item0 : this.range.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - - if (this.rankFeature != null) { - generator.writeKey("rank_feature"); - this.rankFeature.serialize(generator, mapper); - } - - if (ApiTypeHelper.isDefined(this.regexp)) { - generator.writeKey("regexp"); - generator.writeStartObject(); - for (Map.Entry item0 : this.regexp.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - - if (this.script != null) { - generator.writeKey("script"); - this.script.serialize(generator, mapper); - } - - if (this.scriptScore != null) { - generator.writeKey("script_score"); - this.scriptScore.serialize(generator, mapper); - } - - if (this.shape != null) { - generator.writeKey("shape"); - this.shape.serialize(generator, mapper); - } - - if (this.simpleQueryString != null) { - generator.writeKey("simple_query_string"); - this.simpleQueryString.serialize(generator, mapper); - } - - if (this.spanContaining != null) { - generator.writeKey("span_containing"); - this.spanContaining.serialize(generator, mapper); - } - - if (this.spanFirst != null) { - generator.writeKey("span_first"); - this.spanFirst.serialize(generator, mapper); - } - - if (this.spanMulti != null) { - generator.writeKey("span_multi"); - this.spanMulti.serialize(generator, mapper); - } - - if (this.spanNear != null) { - generator.writeKey("span_near"); - this.spanNear.serialize(generator, mapper); - } - - if (this.spanNot != null) { - generator.writeKey("span_not"); - this.spanNot.serialize(generator, mapper); - } - - if (this.spanOr != null) { - generator.writeKey("span_or"); - this.spanOr.serialize(generator, mapper); - } - - if (ApiTypeHelper.isDefined(this.spanTerm)) { - generator.writeKey("span_term"); - generator.writeStartObject(); - for (Map.Entry item0 : this.spanTerm.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - - if (this.spanWithin != null) { - generator.writeKey("span_within"); - this.spanWithin.serialize(generator, mapper); - } - - if (ApiTypeHelper.isDefined(this.term)) { - generator.writeKey("term"); - generator.writeStartObject(); - for (Map.Entry item0 : this.term.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - - if (this.terms != null) { - generator.writeKey("terms"); - this.terms.serialize(generator, mapper); - } - - if (ApiTypeHelper.isDefined(this.termsSet)) { - generator.writeKey("terms_set"); - generator.writeStartObject(); - for (Map.Entry item0 : this.termsSet.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - - if (ApiTypeHelper.isDefined(this.wildcard)) { - generator.writeKey("wildcard"); - generator.writeStartObject(); - for (Map.Entry item0 : this.wildcard.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - - if (this.wrapper != null) { - generator.writeKey("wrapper"); - this.wrapper.serialize(generator, mapper); - } - } - - /** Builder for {@link UserDefinedObjectStructure}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private JsonData bool; - private JsonData boosting; - private JsonData combinedFields; - private JsonData constantScore; - private JsonData disMax; - private JsonData distanceFeature; - private JsonData exists; - private JsonData fieldMaskingSpan; - private JsonData functionScore; - private Map fuzzy; - private JsonData geoBoundingBox; - private JsonData geoDistance; - private JsonData geoPolygon; - private JsonData geoShape; - private JsonData hasChild; - private JsonData hasParent; - private JsonData ids; - private Map intervals; - private JsonData knn; - private Map match; - private JsonData matchAll; - private Map matchBoolPrefix; - private JsonData matchNone; - private Map matchPhrase; - private Map matchPhrasePrefix; - private JsonData moreLikeThis; - private JsonData multiMatch; - private JsonData nested; - private JsonData parentId; - private JsonData percolate; - private JsonData pinned; - private Map prefix; - private JsonData queryString; - private Map range; - private JsonData rankFeature; - private Map regexp; - private JsonData script; - private JsonData scriptScore; - private JsonData shape; - private JsonData simpleQueryString; - private JsonData spanContaining; - private JsonData spanFirst; - private JsonData spanMulti; - private JsonData spanNear; - private JsonData spanNot; - private JsonData spanOr; - private Map spanTerm; - private JsonData spanWithin; - private Map term; - private JsonData terms; - private Map termsSet; - private Map wildcard; - private JsonData wrapper; - - public final Builder bool(JsonData value) { - this.bool = value; - return this; - } - - public final Builder boosting(JsonData value) { - this.boosting = value; - return this; - } - - public final Builder combinedFields(JsonData value) { - this.combinedFields = value; - return this; - } - - public final Builder constantScore(JsonData value) { - this.constantScore = value; - return this; - } - - public final Builder disMax(JsonData value) { - this.disMax = value; - return this; - } - - public final Builder distanceFeature(JsonData value) { - this.distanceFeature = value; - return this; - } - - public final Builder exists(JsonData value) { - this.exists = value; - return this; - } - - public final Builder fieldMaskingSpan(JsonData value) { - this.fieldMaskingSpan = value; - return this; - } - - public final Builder functionScore(JsonData value) { - this.functionScore = value; - return this; - } - - public final Builder fuzzy(Map map) { - this.fuzzy = _mapPutAll(this.fuzzy, map); - return this; - } - - public final Builder fuzzy(String key, JsonData value) { - this.fuzzy = _mapPut(this.fuzzy, key, value); - return this; - } - - public final Builder geoBoundingBox(JsonData value) { - this.geoBoundingBox = value; - return this; - } - - public final Builder geoDistance(JsonData value) { - this.geoDistance = value; - return this; - } - - public final Builder geoPolygon(JsonData value) { - this.geoPolygon = value; - return this; - } - - public final Builder geoShape(JsonData value) { - this.geoShape = value; - return this; - } - - public final Builder hasChild(JsonData value) { - this.hasChild = value; - return this; - } - - public final Builder hasParent(JsonData value) { - this.hasParent = value; - return this; - } - - public final Builder ids(JsonData value) { - this.ids = value; - return this; - } - - public final Builder intervals(Map map) { - this.intervals = _mapPutAll(this.intervals, map); - return this; - } - - public final Builder intervals(String key, JsonData value) { - this.intervals = _mapPut(this.intervals, key, value); - return this; - } - - public final Builder knn(JsonData value) { - this.knn = value; - return this; - } - - public final Builder match(Map map) { - this.match = _mapPutAll(this.match, map); - return this; - } - - public final Builder match(String key, JsonData value) { - this.match = _mapPut(this.match, key, value); - return this; - } - - public final Builder matchAll(JsonData value) { - this.matchAll = value; - return this; - } - - public final Builder matchBoolPrefix(Map map) { - this.matchBoolPrefix = _mapPutAll(this.matchBoolPrefix, map); - return this; - } - - public final Builder matchBoolPrefix(String key, JsonData value) { - this.matchBoolPrefix = _mapPut(this.matchBoolPrefix, key, value); - return this; - } - - public final Builder matchNone(JsonData value) { - this.matchNone = value; - return this; - } - - public final Builder matchPhrase(Map map) { - this.matchPhrase = _mapPutAll(this.matchPhrase, map); - return this; - } - - public final Builder matchPhrase(String key, JsonData value) { - this.matchPhrase = _mapPut(this.matchPhrase, key, value); - return this; - } - - public final Builder matchPhrasePrefix(Map map) { - this.matchPhrasePrefix = _mapPutAll(this.matchPhrasePrefix, map); - return this; - } - - public final Builder matchPhrasePrefix(String key, JsonData value) { - this.matchPhrasePrefix = _mapPut(this.matchPhrasePrefix, key, value); - return this; - } - - public final Builder moreLikeThis(JsonData value) { - this.moreLikeThis = value; - return this; - } - - public final Builder multiMatch(JsonData value) { - this.multiMatch = value; - return this; - } - - public final Builder nested(JsonData value) { - this.nested = value; - return this; - } - - public final Builder parentId(JsonData value) { - this.parentId = value; - return this; - } - - public final Builder percolate(JsonData value) { - this.percolate = value; - return this; - } - - public final Builder pinned(JsonData value) { - this.pinned = value; - return this; - } - - public final Builder prefix(Map map) { - this.prefix = _mapPutAll(this.prefix, map); - return this; - } - - public final Builder prefix(String key, JsonData value) { - this.prefix = _mapPut(this.prefix, key, value); - return this; - } - - public final Builder queryString(JsonData value) { - this.queryString = value; - return this; - } - - public final Builder range(Map map) { - this.range = _mapPutAll(this.range, map); - return this; - } - - public final Builder range(String key, JsonData value) { - this.range = _mapPut(this.range, key, value); - return this; - } - - public final Builder rankFeature(JsonData value) { - this.rankFeature = value; - return this; - } - - public final Builder regexp(Map map) { - this.regexp = _mapPutAll(this.regexp, map); - return this; - } - - public final Builder regexp(String key, JsonData value) { - this.regexp = _mapPut(this.regexp, key, value); - return this; - } - - public final Builder script(JsonData value) { - this.script = value; - return this; - } - - public final Builder scriptScore(JsonData value) { - this.scriptScore = value; - return this; - } - - public final Builder shape(JsonData value) { - this.shape = value; - return this; - } - - public final Builder simpleQueryString(JsonData value) { - this.simpleQueryString = value; - return this; - } - - public final Builder spanContaining(JsonData value) { - this.spanContaining = value; - return this; - } - - public final Builder spanFirst(JsonData value) { - this.spanFirst = value; - return this; - } - - public final Builder spanMulti(JsonData value) { - this.spanMulti = value; - return this; - } - - public final Builder spanNear(JsonData value) { - this.spanNear = value; - return this; - } - - public final Builder spanNot(JsonData value) { - this.spanNot = value; - return this; - } - - public final Builder spanOr(JsonData value) { - this.spanOr = value; - return this; - } - - public final Builder spanTerm(Map map) { - this.spanTerm = _mapPutAll(this.spanTerm, map); - return this; - } - - public final Builder spanTerm(String key, JsonData value) { - this.spanTerm = _mapPut(this.spanTerm, key, value); - return this; - } - - public final Builder spanWithin(JsonData value) { - this.spanWithin = value; - return this; - } - - public final Builder term(Map map) { - this.term = _mapPutAll(this.term, map); - return this; - } - - public final Builder term(String key, JsonData value) { - this.term = _mapPut(this.term, key, value); - return this; - } - - public final Builder terms(JsonData value) { - this.terms = value; - return this; - } - - public final Builder termsSet(Map map) { - this.termsSet = _mapPutAll(this.termsSet, map); - return this; - } - - public final Builder termsSet(String key, JsonData value) { - this.termsSet = _mapPut(this.termsSet, key, value); - return this; - } - - public final Builder wildcard(Map map) { - this.wildcard = _mapPutAll(this.wildcard, map); - return this; - } - - public final Builder wildcard(String key, JsonData value) { - this.wildcard = _mapPut(this.wildcard, key, value); - return this; - } - - public final Builder wrapper(JsonData value) { - this.wrapper = value; - return this; - } - - /** - * Builds a {@link UserDefinedObjectStructure}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public UserDefinedObjectStructure build() { - _checkSingleUse(); - - return new UserDefinedObjectStructure(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, - UserDefinedObjectStructure::setupUserDefinedObjectStructureDeserializer); - - protected static void setupUserDefinedObjectStructureDeserializer( - ObjectDeserializer op) { - op.add(Builder::bool, JsonData._DESERIALIZER, "bool"); - op.add(Builder::boosting, JsonData._DESERIALIZER, "boosting"); - op.add(Builder::combinedFields, JsonData._DESERIALIZER, "combined_fields"); - op.add(Builder::constantScore, JsonData._DESERIALIZER, "constant_score"); - op.add(Builder::disMax, JsonData._DESERIALIZER, "dis_max"); - op.add(Builder::distanceFeature, JsonData._DESERIALIZER, "distance_feature"); - op.add(Builder::exists, JsonData._DESERIALIZER, "exists"); - op.add(Builder::fieldMaskingSpan, JsonData._DESERIALIZER, "field_masking_span"); - op.add(Builder::functionScore, JsonData._DESERIALIZER, "function_score"); - op.add( - Builder::fuzzy, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "fuzzy"); - op.add(Builder::geoBoundingBox, JsonData._DESERIALIZER, "geo_bounding_box"); - op.add(Builder::geoDistance, JsonData._DESERIALIZER, "geo_distance"); - op.add(Builder::geoPolygon, JsonData._DESERIALIZER, "geo_polygon"); - op.add(Builder::geoShape, JsonData._DESERIALIZER, "geo_shape"); - op.add(Builder::hasChild, JsonData._DESERIALIZER, "has_child"); - op.add(Builder::hasParent, JsonData._DESERIALIZER, "has_parent"); - op.add(Builder::ids, JsonData._DESERIALIZER, "ids"); - op.add( - Builder::intervals, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "intervals"); - op.add(Builder::knn, JsonData._DESERIALIZER, "knn"); - op.add( - Builder::match, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "match"); - op.add(Builder::matchAll, JsonData._DESERIALIZER, "match_all"); - op.add( - Builder::matchBoolPrefix, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "match_bool_prefix"); - op.add(Builder::matchNone, JsonData._DESERIALIZER, "match_none"); - op.add( - Builder::matchPhrase, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "match_phrase"); - op.add( - Builder::matchPhrasePrefix, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "match_phrase_prefix"); - op.add(Builder::moreLikeThis, JsonData._DESERIALIZER, "more_like_this"); - op.add(Builder::multiMatch, JsonData._DESERIALIZER, "multi_match"); - op.add(Builder::nested, JsonData._DESERIALIZER, "nested"); - op.add(Builder::parentId, JsonData._DESERIALIZER, "parent_id"); - op.add(Builder::percolate, JsonData._DESERIALIZER, "percolate"); - op.add(Builder::pinned, JsonData._DESERIALIZER, "pinned"); - op.add( - Builder::prefix, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "prefix"); - op.add(Builder::queryString, JsonData._DESERIALIZER, "query_string"); - op.add( - Builder::range, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "range"); - op.add(Builder::rankFeature, JsonData._DESERIALIZER, "rank_feature"); - op.add( - Builder::regexp, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "regexp"); - op.add(Builder::script, JsonData._DESERIALIZER, "script"); - op.add(Builder::scriptScore, JsonData._DESERIALIZER, "script_score"); - op.add(Builder::shape, JsonData._DESERIALIZER, "shape"); - op.add(Builder::simpleQueryString, JsonData._DESERIALIZER, "simple_query_string"); - op.add(Builder::spanContaining, JsonData._DESERIALIZER, "span_containing"); - op.add(Builder::spanFirst, JsonData._DESERIALIZER, "span_first"); - op.add(Builder::spanMulti, JsonData._DESERIALIZER, "span_multi"); - op.add(Builder::spanNear, JsonData._DESERIALIZER, "span_near"); - op.add(Builder::spanNot, JsonData._DESERIALIZER, "span_not"); - op.add(Builder::spanOr, JsonData._DESERIALIZER, "span_or"); - op.add( - Builder::spanTerm, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "span_term"); - op.add(Builder::spanWithin, JsonData._DESERIALIZER, "span_within"); - op.add( - Builder::term, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "term"); - op.add(Builder::terms, JsonData._DESERIALIZER, "terms"); - op.add( - Builder::termsSet, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "terms_set"); - op.add( - Builder::wildcard, - JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), - "wildcard"); - op.add(Builder::wrapper, JsonData._DESERIALIZER, "wrapper"); - } -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedStructure.java b/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedStructure.java deleted file mode 100644 index b57971d3e6..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/UserDefinedStructure.java +++ /dev/null @@ -1,285 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class UserDefinedStructure implements JsonpSerializable { - - @Nullable private final String alias; - - @Nullable private final List aliases; - - @Nullable private final JsonData filter; - - @Nullable private final String index; - - @Nullable private final String indexRouting; - - @Nullable private final List indices; - - @Nullable private final Boolean isHidden; - - @Nullable private final Boolean isWriteIndex; - - @Nullable private final String mustExist; - - @Nullable private final String routing; - - @Nullable private final String searchRouting; - - public UserDefinedStructure(Builder builder) { - this.alias = builder.alias; - this.aliases = ApiTypeHelper.unmodifiable(builder.aliases); - this.filter = builder.filter; - this.index = builder.index; - this.indexRouting = builder.indexRouting; - this.indices = ApiTypeHelper.unmodifiable(builder.indices); - this.isHidden = builder.isHidden; - this.isWriteIndex = builder.isWriteIndex; - this.mustExist = builder.mustExist; - this.routing = builder.routing; - this.searchRouting = builder.searchRouting; - } - - public static UserDefinedStructure of( - Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final String alias() { - return this.alias; - } - - public final List aliases() { - return this.aliases; - } - - public final JsonData filter() { - return this.filter; - } - - public final String index() { - return this.index; - } - - public final String indexRouting() { - return this.indexRouting; - } - - public final List indices() { - return this.indices; - } - - public final Boolean isHidden() { - return this.isHidden; - } - - public final Boolean isWriteIndex() { - return this.isWriteIndex; - } - - public final String mustExist() { - return this.mustExist; - } - - public final String routing() { - return this.routing; - } - - public final String searchRouting() { - return this.searchRouting; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.alias != null) { - generator.writeKey("alias"); - generator.write(this.alias); - } - - if (ApiTypeHelper.isDefined(this.aliases)) { - generator.writeKey("aliases"); - generator.writeStartArray(); - for (String item0 : this.aliases) { - generator.write(item0); - } - generator.writeEnd(); - } - - if (this.filter != null) { - generator.writeKey("filter"); - this.filter.serialize(generator, mapper); - } - - if (this.index != null) { - generator.writeKey("index"); - generator.write(this.index); - } - - if (this.indexRouting != null) { - generator.writeKey("index_routing"); - generator.write(this.indexRouting); - } - - if (ApiTypeHelper.isDefined(this.indices)) { - generator.writeKey("indices"); - generator.writeStartArray(); - for (String item0 : this.indices) { - generator.write(item0); - } - generator.writeEnd(); - } - - if (this.isHidden != null) { - generator.writeKey("is_hidden"); - generator.write(this.isHidden); - } - - if (this.isWriteIndex != null) { - generator.writeKey("is_write_index"); - generator.write(this.isWriteIndex); - } - - if (this.mustExist != null) { - generator.writeKey("must_exist"); - generator.write(this.mustExist); - } - - if (this.routing != null) { - generator.writeKey("routing"); - generator.write(this.routing); - } - - if (this.searchRouting != null) { - generator.writeKey("search_routing"); - generator.write(this.searchRouting); - } - } - - /** Builder for {@link UserDefinedStructure}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { - private String alias; - private List aliases; - private JsonData filter; - private String index; - private String indexRouting; - private List indices; - private Boolean isHidden; - private Boolean isWriteIndex; - private String mustExist; - private String routing; - private String searchRouting; - - public final Builder alias(String value) { - this.alias = value; - return this; - } - - public final Builder aliases(List list) { - this.aliases = _listAddAll(this.aliases, list); - return this; - } - - public final Builder aliases(String value, String... values) { - this.aliases = _listAdd(this.aliases, value, values); - return this; - } - - public final Builder filter(JsonData value) { - this.filter = value; - return this; - } - - public final Builder index(String value) { - this.index = value; - return this; - } - - public final Builder indexRouting(String value) { - this.indexRouting = value; - return this; - } - - public final Builder indices(List list) { - this.indices = _listAddAll(this.indices, list); - return this; - } - - public final Builder indices(String value, String... values) { - this.indices = _listAdd(this.indices, value, values); - return this; - } - - public final Builder isHidden(Boolean value) { - this.isHidden = value; - return this; - } - - public final Builder isWriteIndex(Boolean value) { - this.isWriteIndex = value; - return this; - } - - public final Builder mustExist(String value) { - this.mustExist = value; - return this; - } - - public final Builder routing(String value) { - this.routing = value; - return this; - } - - public final Builder searchRouting(String value) { - this.searchRouting = value; - return this; - } - - /** - * Builds a {@link UserDefinedStructure}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public UserDefinedStructure build() { - _checkSingleUse(); - - return new UserDefinedStructure(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy( - Builder::new, UserDefinedStructure::setupUserDefinedStructureDeserializer); - - protected static void setupUserDefinedStructureDeserializer( - ObjectDeserializer op) { - op.add(Builder::alias, JsonpDeserializer.stringDeserializer(), "alias"); - op.add( - Builder::aliases, - JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), - "aliases"); - op.add(Builder::filter, JsonData._DESERIALIZER, "filter"); - op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "index"); - op.add(Builder::indexRouting, JsonpDeserializer.stringDeserializer(), "index_routing"); - op.add( - Builder::indices, - JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), - "indices"); - op.add(Builder::isHidden, JsonpDeserializer.booleanDeserializer(), "is_hidden"); - op.add(Builder::isWriteIndex, JsonpDeserializer.booleanDeserializer(), "is_write_index"); - op.add(Builder::mustExist, JsonpDeserializer.stringDeserializer(), "must_exist"); - op.add(Builder::routing, JsonpDeserializer.stringDeserializer(), "routing"); - op.add(Builder::searchRouting, JsonpDeserializer.stringDeserializer(), "search_routing"); - } -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/Version.java b/java-client/src/generated/java/org/opensearch/client/opensearch/Version.java deleted file mode 100644 index a9cd5a1f0f..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/Version.java +++ /dev/null @@ -1,225 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; -import jakarta.json.stream.JsonGenerator; -import java.util.*; -import java.util.function.Function; -import javax.annotation.*; - -@JsonpDeserializable -public class Version implements JsonpSerializable { - - @Nullable private final String buildDate; - - @Nullable private final String buildHash; - - @Nullable private final Boolean buildSnapshot; - - @Nullable private final String buildType; - - @Nullable private final String distribution; - - @Nullable private final String luceneVersion; - - @Nullable private final String minimumIndexCompatibilityVersion; - - @Nullable private final String minimumWireCompatibilityVersion; - - @Nullable private final String number; - - public Version(Builder builder) { - this.buildDate = builder.buildDate; - this.buildHash = builder.buildHash; - this.buildSnapshot = builder.buildSnapshot; - this.buildType = builder.buildType; - this.distribution = builder.distribution; - this.luceneVersion = builder.luceneVersion; - this.minimumIndexCompatibilityVersion = builder.minimumIndexCompatibilityVersion; - this.minimumWireCompatibilityVersion = builder.minimumWireCompatibilityVersion; - this.number = builder.number; - } - - public static Version of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - public final String buildDate() { - return this.buildDate; - } - - public final String buildHash() { - return this.buildHash; - } - - public final Boolean buildSnapshot() { - return this.buildSnapshot; - } - - public final String buildType() { - return this.buildType; - } - - public final String distribution() { - return this.distribution; - } - - public final String luceneVersion() { - return this.luceneVersion; - } - - public final String minimumIndexCompatibilityVersion() { - return this.minimumIndexCompatibilityVersion; - } - - public final String minimumWireCompatibilityVersion() { - return this.minimumWireCompatibilityVersion; - } - - public final String number() { - return this.number; - } - - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (this.buildDate != null) { - generator.writeKey("build_date"); - generator.write(this.buildDate); - } - - if (this.buildHash != null) { - generator.writeKey("build_hash"); - generator.write(this.buildHash); - } - - if (this.buildSnapshot != null) { - generator.writeKey("build_snapshot"); - generator.write(this.buildSnapshot); - } - - if (this.buildType != null) { - generator.writeKey("build_type"); - generator.write(this.buildType); - } - - if (this.distribution != null) { - generator.writeKey("distribution"); - generator.write(this.distribution); - } - - if (this.luceneVersion != null) { - generator.writeKey("lucene_version"); - generator.write(this.luceneVersion); - } - - if (this.minimumIndexCompatibilityVersion != null) { - generator.writeKey("minimum_index_compatibility_version"); - generator.write(this.minimumIndexCompatibilityVersion); - } - - if (this.minimumWireCompatibilityVersion != null) { - generator.writeKey("minimum_wire_compatibility_version"); - generator.write(this.minimumWireCompatibilityVersion); - } - - if (this.number != null) { - generator.writeKey("number"); - generator.write(this.number); - } - } - - /** Builder for {@link Version}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private String buildDate; - private String buildHash; - private Boolean buildSnapshot; - private String buildType; - private String distribution; - private String luceneVersion; - private String minimumIndexCompatibilityVersion; - private String minimumWireCompatibilityVersion; - private String number; - - public final Builder buildDate(String value) { - this.buildDate = value; - return this; - } - - public final Builder buildHash(String value) { - this.buildHash = value; - return this; - } - - public final Builder buildSnapshot(Boolean value) { - this.buildSnapshot = value; - return this; - } - - public final Builder buildType(String value) { - this.buildType = value; - return this; - } - - public final Builder distribution(String value) { - this.distribution = value; - return this; - } - - public final Builder luceneVersion(String value) { - this.luceneVersion = value; - return this; - } - - public final Builder minimumIndexCompatibilityVersion(String value) { - this.minimumIndexCompatibilityVersion = value; - return this; - } - - public final Builder minimumWireCompatibilityVersion(String value) { - this.minimumWireCompatibilityVersion = value; - return this; - } - - public final Builder number(String value) { - this.number = value; - return this; - } - - /** - * Builds a {@link Version}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public Version build() { - _checkSingleUse(); - - return new Version(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = - ObjectBuilderDeserializer.lazy(Builder::new, Version::setupVersionDeserializer); - - protected static void setupVersionDeserializer(ObjectDeserializer op) { - op.add(Builder::buildDate, JsonpDeserializer.stringDeserializer(), "build_date"); - op.add(Builder::buildHash, JsonpDeserializer.stringDeserializer(), "build_hash"); - op.add(Builder::buildSnapshot, JsonpDeserializer.booleanDeserializer(), "build_snapshot"); - op.add(Builder::buildType, JsonpDeserializer.stringDeserializer(), "build_type"); - op.add(Builder::distribution, JsonpDeserializer.stringDeserializer(), "distribution"); - op.add(Builder::luceneVersion, JsonpDeserializer.stringDeserializer(), "lucene_version"); - op.add( - Builder::minimumIndexCompatibilityVersion, - JsonpDeserializer.stringDeserializer(), - "minimum_index_compatibility_version"); - op.add( - Builder::minimumWireCompatibilityVersion, - JsonpDeserializer.stringDeserializer(), - "minimum_wire_compatibility_version"); - op.add(Builder::number, JsonpDeserializer.stringDeserializer(), "number"); - } -} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/VersionType.java b/java-client/src/generated/java/org/opensearch/client/opensearch/VersionType.java deleted file mode 100644 index 512bcb42af..0000000000 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/VersionType.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.opensearch.client.opensearch; - -import org.opensearch.client.json.JsonEnum; -import org.opensearch.client.json.JsonpDeserializable; - -@JsonpDeserializable -public enum VersionType implements JsonEnum { - Internal("internal"), - External("external"), - ExternalGte("external_gte"), - ; - - private final String jsonValue; - private final String[] aliases; - - VersionType(String jsonValue, String... aliases) { - this.jsonValue = jsonValue; - this.aliases = aliases; - } - - public String jsonValue() { - return this.jsonValue; - } - - public String[] aliases() { - return this.aliases; - } - - public static final JsonEnum.Deserializer _DESERIALIZER = - new JsonEnum.Deserializer<>(VersionType.values()); -} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java b/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java index be5220edae..5bdc51c24b 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java @@ -1,3 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.codegen; import org.openapi4j.core.exception.DecodeException; @@ -7,7 +15,12 @@ import org.openapi4j.core.validation.ValidationException; import org.openapi4j.parser.OpenApi3Parser; import org.openapi4j.parser.model.AbsRefOpenApiSchema; -import org.openapi4j.parser.model.v3.*; +import org.openapi4j.parser.model.v3.MediaType; +import org.openapi4j.parser.model.v3.OpenApi3; +import org.openapi4j.parser.model.v3.Operation; +import org.openapi4j.parser.model.v3.Path; +import org.openapi4j.parser.model.v3.RequestBody; +import org.openapi4j.parser.model.v3.Schema; import org.opensearch.client.codegen.exceptions.ApiSpecificationParseException; import org.opensearch.client.codegen.model.EnumShape; import org.opensearch.client.codegen.model.Field; @@ -16,7 +29,12 @@ import org.opensearch.client.codegen.utils.Schemas; import java.io.File; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.Stream; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java b/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java index 1f5b620413..8b34bed3c1 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java @@ -1,3 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.codegen; import org.opensearch.client.codegen.exceptions.ApiSpecificationParseException; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/Main.java b/java-codegen/src/main/java/org/opensearch/client/codegen/Main.java index 9510d2ca4f..ba8d247d8e 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/Main.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/Main.java @@ -1,3 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.codegen; import java.io.File; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/NameSanitizer.java b/java-codegen/src/main/java/org/opensearch/client/codegen/NameSanitizer.java index 030ce9e7e9..f04d82cea9 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/NameSanitizer.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/NameSanitizer.java @@ -1,3 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.codegen; import org.opensearch.client.codegen.utils.Strings; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java b/java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java index 6554a40f11..3ae74ad035 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java @@ -1,3 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.codegen; import com.google.googlejavaformat.java.Formatter; @@ -9,7 +17,13 @@ import org.apache.commons.text.StringEscapeUtils; import org.opensearch.client.codegen.exceptions.RenderException; -import java.io.*; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.StringWriter; +import java.io.Writer; import java.util.HashMap; import java.util.Map; import java.util.MissingResourceException; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java b/java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java index 4f84d1e65b..75d034a401 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java @@ -1,3 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.codegen; import org.openapi4j.core.model.OAIContext; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/exceptions/ApiSpecificationParseException.java b/java-codegen/src/main/java/org/opensearch/client/codegen/exceptions/ApiSpecificationParseException.java index 042ad5f8fc..eb4f34baed 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/exceptions/ApiSpecificationParseException.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/exceptions/ApiSpecificationParseException.java @@ -1,3 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.codegen.exceptions; public class ApiSpecificationParseException extends Exception { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/exceptions/RenderException.java b/java-codegen/src/main/java/org/opensearch/client/codegen/exceptions/RenderException.java index e3724207d1..22822558dd 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/exceptions/RenderException.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/exceptions/RenderException.java @@ -1,3 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.codegen.exceptions; public class RenderException extends Exception { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Client.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Client.java index 11e4188308..b89985e09f 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Client.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Client.java @@ -1,3 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.codegen.model; import org.opensearch.client.codegen.utils.Strings; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ClientOperation.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ClientOperation.java index e570bb1f08..b7f266dc8e 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ClientOperation.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ClientOperation.java @@ -1,3 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.codegen.model; import org.opensearch.client.codegen.utils.Strings; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java index 5beafd69b2..ae8c14ab5b 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java @@ -1,3 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.codegen.model; import org.opensearch.client.codegen.utils.Strings; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java index 40f2949923..244ab06dad 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java @@ -1,3 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.codegen.model; import org.opensearch.client.codegen.NameSanitizer; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java index 6b937275e8..b174f62692 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java @@ -1,3 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.codegen.model; import java.util.Collection; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java index 0011903908..2530597703 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java @@ -1,3 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.codegen.model; import java.util.Collection; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java index f08b525616..c867bac064 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java @@ -1,7 +1,14 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.codegen.model; import com.samskivert.mustache.Mustache; -import org.openapi4j.core.model.v3.OAI3SchemaKeywords; import org.openapi4j.parser.model.v3.Schema; import org.opensearch.client.codegen.utils.Schemas; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Schemas.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Schemas.java index f551403972..30dfbb78ef 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Schemas.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Schemas.java @@ -1,3 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.codegen.utils; import org.openapi4j.core.model.v3.OAI3SchemaKeywords; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Strings.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Strings.java index 553f8597e6..ebc9470ea2 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Strings.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Strings.java @@ -1,3 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.codegen.utils; import org.apache.commons.text.CaseUtils; From 44c2f24d1b6ce4026cb5f4b403a2d3df6a28f17d Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Fri, 17 Feb 2023 10:28:25 +1300 Subject: [PATCH 10/50] Generate namespaces remote store client Signed-off-by: Thomas Farr --- .../OpenSearchRemoteStoreAsyncClient.java | 54 + .../OpenSearchRemoteStoreClient.java | 53 + .../PostRemoteStoreRestoreRequest.java | 144 + .../PostRemoteStoreRestoreResponse.java | 92 + java-codegen/OpenSearch.openapi.json | 2844 ----------------- java-codegen/OpenSearch.yaml | 80 + java-codegen/build.gradle.kts | 2 +- .../client/codegen/ApiSpecification.java | 9 +- .../opensearch/client/codegen/Generator.java | 37 +- .../client/codegen/model/Client.java | 27 +- .../client/codegen/model/EnumShape.java | 9 +- .../client/codegen/model/ObjectShape.java | 11 +- .../client/codegen/model/RequestShape.java | 4 +- .../client/codegen/model/Shape.java | 31 + .../client/codegen/utils/Schemas.java | 18 + .../client/codegen/templates/Client.mustache | 2 +- .../codegen/templates/EnumShape.mustache | 2 +- .../codegen/templates/ObjectShape.mustache | 2 +- .../codegen/templates/RequestShape.mustache | 2 +- 19 files changed, 524 insertions(+), 2899 deletions(-) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreAsyncClient.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreClient.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/PostRemoteStoreRestoreRequest.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/PostRemoteStoreRestoreResponse.java delete mode 100644 java-codegen/OpenSearch.openapi.json create mode 100644 java-codegen/OpenSearch.yaml create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreAsyncClient.java b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreAsyncClient.java new file mode 100644 index 0000000000..6ee515e734 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreAsyncClient.java @@ -0,0 +1,54 @@ +package org.opensearch.client.opensearch.remotestore; + +import org.opensearch.client.ApiClient; +import org.opensearch.client.opensearch._types.OpenSearchException; +import org.opensearch.client.opensearch._types.ErrorResponse; +import org.opensearch.client.transport.OpenSearchTransport; +import org.opensearch.client.transport.JsonEndpoint; +import org.opensearch.client.transport.TransportOptions; +import org.opensearch.client.util.ObjectBuilder; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import java.util.function.Function; +import javax.annotation.Nullable; + +public class OpenSearchRemoteStoreAsyncClient + extends ApiClient { + public OpenSearchRemoteStoreAsyncClient(OpenSearchTransport transport) { + super(transport, null); + } + + public OpenSearchRemoteStoreAsyncClient( + OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { + super(transport, transportOptions); + } + + @Override + public OpenSearchRemoteStoreAsyncClient withTransportOptions( + @Nullable TransportOptions transportOptions) { + return new OpenSearchRemoteStoreAsyncClient(this.transport, transportOptions); + } + + public CompletableFuture postRemoteStoreRestore( + PostRemoteStoreRestoreRequest request) throws IOException, OpenSearchException { + JsonEndpoint + endpoint = + (JsonEndpoint< + PostRemoteStoreRestoreRequest, + PostRemoteStoreRestoreResponse, + ErrorResponse>) + PostRemoteStoreRestoreRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + public final CompletableFuture postRemoteStoreRestore( + Function< + PostRemoteStoreRestoreRequest.Builder, + ObjectBuilder> + fn) + throws IOException, OpenSearchException { + return postRemoteStoreRestore( + fn.apply(new PostRemoteStoreRestoreRequest.Builder()).build()); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreClient.java b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreClient.java new file mode 100644 index 0000000000..db28ab73a6 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreClient.java @@ -0,0 +1,53 @@ +package org.opensearch.client.opensearch.remotestore; + +import org.opensearch.client.ApiClient; +import org.opensearch.client.opensearch._types.OpenSearchException; +import org.opensearch.client.opensearch._types.ErrorResponse; +import org.opensearch.client.transport.OpenSearchTransport; +import org.opensearch.client.transport.JsonEndpoint; +import org.opensearch.client.transport.TransportOptions; +import org.opensearch.client.util.ObjectBuilder; +import java.io.IOException; +import java.util.function.Function; +import javax.annotation.Nullable; + +public class OpenSearchRemoteStoreClient + extends ApiClient { + public OpenSearchRemoteStoreClient(OpenSearchTransport transport) { + super(transport, null); + } + + public OpenSearchRemoteStoreClient( + OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { + super(transport, transportOptions); + } + + @Override + public OpenSearchRemoteStoreClient withTransportOptions( + @Nullable TransportOptions transportOptions) { + return new OpenSearchRemoteStoreClient(this.transport, transportOptions); + } + + public PostRemoteStoreRestoreResponse postRemoteStoreRestore( + PostRemoteStoreRestoreRequest request) throws IOException, OpenSearchException { + JsonEndpoint + endpoint = + (JsonEndpoint< + PostRemoteStoreRestoreRequest, + PostRemoteStoreRestoreResponse, + ErrorResponse>) + PostRemoteStoreRestoreRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + public final PostRemoteStoreRestoreResponse postRemoteStoreRestore( + Function< + PostRemoteStoreRestoreRequest.Builder, + ObjectBuilder> + fn) + throws IOException, OpenSearchException { + return postRemoteStoreRestore( + fn.apply(new PostRemoteStoreRestoreRequest.Builder()).build()); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/PostRemoteStoreRestoreRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/PostRemoteStoreRestoreRequest.java new file mode 100644 index 0000000000..2a4da0a8d8 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/PostRemoteStoreRestoreRequest.java @@ -0,0 +1,144 @@ +package org.opensearch.client.opensearch.remotestore; + +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.json.*; +import org.opensearch.client.transport.*; +import org.opensearch.client.transport.endpoints.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import java.util.stream.*; +import javax.annotation.*; + +/** Restore one or more indices from a remote backup. */ +@JsonpDeserializable +public class PostRemoteStoreRestoreRequest extends RequestBase implements JsonpSerializable { + + @Nullable private final String clusterManagerTimeout; + + private final List indices; + + @Nullable private final Boolean waitForCompletion; + + public PostRemoteStoreRestoreRequest(Builder builder) { + this.clusterManagerTimeout = builder.clusterManagerTimeout; + this.indices = ApiTypeHelper.unmodifiableRequired(builder.indices, this, "indices"); + this.waitForCompletion = builder.waitForCompletion; + } + + public static PostRemoteStoreRestoreRequest of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final String clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + + public final List indices() { + return this.indices; + } + + public final Boolean waitForCompletion() { + return this.waitForCompletion; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + generator.writeKey("indices"); + generator.writeStartArray(); + for (String item0 : this.indices) { + generator.write(item0); + } + generator.writeEnd(); + } + + /** Builder for {@link PostRemoteStoreRestoreRequest}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private String clusterManagerTimeout; + private List indices; + private Boolean waitForCompletion; + + public final Builder clusterManagerTimeout(String value) { + this.clusterManagerTimeout = value; + return this; + } + + public final Builder indices(List list) { + this.indices = _listAddAll(this.indices, list); + return this; + } + + public final Builder indices(String value, String... values) { + this.indices = _listAdd(this.indices, value, values); + return this; + } + + public final Builder waitForCompletion(Boolean value) { + this.waitForCompletion = value; + return this; + } + + /** + * Builds a {@link PostRemoteStoreRestoreRequest}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public PostRemoteStoreRestoreRequest build() { + _checkSingleUse(); + + return new PostRemoteStoreRestoreRequest(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, + PostRemoteStoreRestoreRequest::setupPostRemoteStoreRestoreRequestDeserializer); + + protected static void setupPostRemoteStoreRestoreRequestDeserializer( + ObjectDeserializer op) { + op.add( + Builder::indices, + JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), + "indices"); + } + + public static final Endpoint< + PostRemoteStoreRestoreRequest, PostRemoteStoreRestoreResponse, ErrorResponse> + _ENDPOINT = + new SimpleEndpoint<>( + // Request method + request -> { + return "post"; + }, + // Request path + request -> { + return "/_remotestore/_restore"; + }, + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.clusterManagerTimeout != null) { + params.put( + "cluster_manager_timeout", + request.clusterManagerTimeout); + } + if (request.waitForCompletion != null) { + params.put( + "wait_for_completion", + String.valueOf(request.waitForCompletion)); + } + return params; + }, + SimpleEndpoint.emptyMap(), + true, + PostRemoteStoreRestoreResponse._DESERIALIZER); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/PostRemoteStoreRestoreResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/PostRemoteStoreRestoreResponse.java new file mode 100644 index 0000000000..2942c75e59 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/PostRemoteStoreRestoreResponse.java @@ -0,0 +1,92 @@ +package org.opensearch.client.opensearch.remotestore; + +import org.opensearch.client.json.*; +import org.opensearch.client.util.*; +import jakarta.json.stream.JsonGenerator; +import java.util.*; +import java.util.function.Function; +import javax.annotation.*; + +@JsonpDeserializable +public class PostRemoteStoreRestoreResponse implements JsonpSerializable { + + @Nullable private final Boolean accepted; + + @Nullable private final String remoteStore; + + public PostRemoteStoreRestoreResponse(Builder builder) { + this.accepted = builder.accepted; + this.remoteStore = builder.remoteStore; + } + + public static PostRemoteStoreRestoreResponse of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final Boolean accepted() { + return this.accepted; + } + + public final String remoteStore() { + return this.remoteStore; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.accepted != null) { + generator.writeKey("accepted"); + generator.write(this.accepted); + } + + if (this.remoteStore != null) { + generator.writeKey("remote_store"); + generator.write(this.remoteStore); + } + } + + /** Builder for {@link PostRemoteStoreRestoreResponse}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private Boolean accepted; + private String remoteStore; + + public final Builder accepted(Boolean value) { + this.accepted = value; + return this; + } + + public final Builder remoteStore(String value) { + this.remoteStore = value; + return this; + } + + /** + * Builds a {@link PostRemoteStoreRestoreResponse}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public PostRemoteStoreRestoreResponse build() { + _checkSingleUse(); + + return new PostRemoteStoreRestoreResponse(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, + PostRemoteStoreRestoreResponse + ::setupPostRemoteStoreRestoreResponseDeserializer); + + protected static void setupPostRemoteStoreRestoreResponseDeserializer( + ObjectDeserializer op) { + op.add(Builder::accepted, JsonpDeserializer.booleanDeserializer(), "accepted"); + op.add(Builder::remoteStore, JsonpDeserializer.stringDeserializer(), "remote_store"); + } +} diff --git a/java-codegen/OpenSearch.openapi.json b/java-codegen/OpenSearch.openapi.json deleted file mode 100644 index 69df2e6a00..0000000000 --- a/java-codegen/OpenSearch.openapi.json +++ /dev/null @@ -1,2844 +0,0 @@ -{ - "openapi": "3.0.2", - "info": { - "title": "OpenSearch", - "version": "2021-11-23" - }, - "paths": { - "/": { - "get": { - "description": "Returns whether the cluster is running.", - "operationId": "GetClusterInfo", - "responses": { - "200": { - "description": "GetClusterInfo 200 response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GetClusterInfoResponseContent" - } - } - } - } - } - } - }, - "/_aliases": { - "post": { - "description": "Adds or removes index aliases.", - "operationId": "PostAliases", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PostAliasesRequestContent" - }, - "examples": { - "PostAliases_example1": { - "summary": "Examples for Post Aliases Operation.", - "description": "", - "value": {} - } - } - } - } - }, - "parameters": [ - { - "name": "master_timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", - "deprecated": true - } - }, - { - "name": "cluster_manager_timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - } - }, - { - "name": "timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - } - } - ], - "responses": { - "200": { - "description": "PostAliases 200 response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PostAliasesResponseContent" - }, - "examples": { - "PostAliases_example1": { - "summary": "Examples for Post Aliases Operation.", - "description": "", - "value": { - "acknowledged": true - } - } - } - } - } - } - } - } - }, - "/_cat/indices": { - "get": { - "description": "Returns information about indices: number of primaries and replicas, document counts, disk size, etc.", - "operationId": "GetCatIndices", - "parameters": [ - { - "name": "master_timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", - "deprecated": true - } - }, - { - "name": "cluster_manager_timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - } - }, - { - "name": "bytes", - "in": "query", - "schema": { - "type": "integer" - } - }, - { - "name": "expand_wildcards", - "in": "query", - "schema": { - "$ref": "#/components/schemas/ExpandWildcards" - } - }, - { - "name": "health", - "in": "query", - "schema": { - "$ref": "#/components/schemas/HealthStatus" - } - }, - { - "name": "include_unloaded_segments", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "pri", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "time", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - } - }, - { - "name": "format", - "in": "query", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "GetCatIndices 200 response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GetCatIndicesOutputPayload" - } - } - } - } - } - } - }, - "/_cat/indices/{index}": { - "get": { - "description": "Returns information about indices: number of primaries and replicas, document counts, disk size, etc.", - "operationId": "GetCatIndicesWithIndex", - "parameters": [ - { - "name": "index", - "in": "path", - "schema": { - "type": "string", - "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" - }, - "required": true, - "examples": { - "GetCatIndicesWithIndex_example1": { - "summary": "Examples for Cat indices with Index Operation.", - "description": "", - "value": "books" - } - } - }, - { - "name": "master_timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", - "deprecated": true - } - }, - { - "name": "cluster_manager_timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - } - }, - { - "name": "bytes", - "in": "query", - "schema": { - "type": "integer" - } - }, - { - "name": "expand_wildcards", - "in": "query", - "schema": { - "$ref": "#/components/schemas/ExpandWildcards" - } - }, - { - "name": "health", - "in": "query", - "schema": { - "$ref": "#/components/schemas/HealthStatus" - } - }, - { - "name": "include_unloaded_segments", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "pri", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "time", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - } - }, - { - "name": "format", - "in": "query", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "GetCatIndicesWithIndex 200 response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GetCatIndicesWithIndexOutputPayload" - } - } - } - } - } - } - }, - "/_cat/nodes": { - "get": { - "description": "Returns basic statistics about performance of cluster nodes.", - "operationId": "GetCatNodes", - "parameters": [ - { - "name": "master_timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", - "deprecated": true - } - }, - { - "name": "cluster_manager_timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - } - }, - { - "name": "bytes", - "in": "query", - "schema": { - "type": "integer" - } - }, - { - "name": "full_id", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "local", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "time", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - } - }, - { - "name": "include_unloaded_segments", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "format", - "in": "query", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "GetCatNodes 200 response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GetCatNodesOutputPayload" - } - } - } - } - } - } - }, - "/_cluster/settings": { - "get": { - "description": "Returns cluster settings.", - "operationId": "GetClusterSettings", - "parameters": [ - { - "name": "master_timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", - "deprecated": true - } - }, - { - "name": "cluster_manager_timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - } - }, - { - "name": "flat_settings", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "include_defaults", - "in": "query", - "schema": { - "type": "boolean" - }, - "examples": { - "GetClusterSettings_example1": { - "summary": "Examples for Get cluster settings Operation.", - "description": "", - "value": true - } - } - } - ], - "responses": { - "200": { - "description": "GetClusterSettings 200 response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GetClusterSettingsResponseContent" - }, - "examples": { - "GetClusterSettings_example1": { - "summary": "Examples for Get cluster settings Operation.", - "description": "", - "value": {} - } - } - } - } - } - } - }, - "put": { - "description": "Updates the cluster settings.", - "operationId": "PutUpdateClusterSettings", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PutUpdateClusterSettingsRequestContent" - } - } - } - }, - "parameters": [ - { - "name": "master_timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", - "deprecated": true - } - }, - { - "name": "cluster_manager_timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - } - }, - { - "name": "flat_settings", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - } - } - ], - "responses": { - "200": { - "description": "PutUpdateClusterSettings 200 response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PutUpdateClusterSettingsResponseContent" - } - } - } - } - } - } - }, - "/_remotestore/_restore": { - "post": { - "description": "Restore one or more indices from a remote backup.", - "operationId": "PostRemoteStoreRestore", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PostRemoteStoreRestoreRequestContent" - }, - "examples": { - "PostRemoteStoreRestore_example1": { - "summary": "Examples for Post Remote Storage Restore Operation.", - "description": "", - "value": { - "indices": [ - "books" - ] - } - } - } - } - }, - "required": true - }, - "parameters": [ - { - "name": "cluster_manager_timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - } - }, - { - "name": "wait_for_completion", - "in": "query", - "schema": { - "type": "boolean" - } - } - ], - "responses": { - "200": { - "description": "PostRemoteStoreRestore 200 response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PostRemoteStoreRestoreResponseContent" - }, - "examples": { - "PostRemoteStoreRestore_example1": { - "summary": "Examples for Post Remote Storage Restore Operation.", - "description": "", - "value": { - "remote_store": { - "indices": [ - "books" - ], - "shards": { - "total": 1, - "failed": 0, - "successful": 1 - } - } - } - } - } - } - } - } - } - } - }, - "/_search": { - "post": { - "description": "Returns results matching a query.", - "operationId": "PostSearch", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PostSearchRequestContent" - }, - "examples": { - "PostSearch_example1": { - "summary": "Examples for Post Search Operation.", - "description": "", - "value": { - "query": { - "match_all": {} - }, - "fields": [ - "*" - ] - } - } - } - } - } - }, - "parameters": [ - { - "name": "allow_no_indices", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "allow_partial_search_results", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "analyzer", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "analyze_wildcard", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "batched_reduce_size", - "in": "query", - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "ccs_minimize_roundtrips", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "default_operator", - "in": "query", - "schema": { - "$ref": "#/components/schemas/DefaultOperator" - } - }, - { - "name": "df", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "docvalue_fields", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "expand_wildcards", - "in": "query", - "schema": { - "$ref": "#/components/schemas/ExpandWildcards" - } - }, - { - "name": "explain", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "from", - "in": "query", - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "ignore_throttled", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "ignore_unavailable", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "lenient", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "max_concurrent_shard_requests", - "in": "query", - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "pre_filter_shard_size", - "in": "query", - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "preference", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "q", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "request_cache", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "rest_total_hits_as_int", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "routing", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "scroll", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - }, - "examples": { - "PostSearch_example1": { - "summary": "Examples for Post Search Operation.", - "description": "", - "value": "1d" - } - } - }, - { - "name": "search_type", - "in": "query", - "schema": { - "$ref": "#/components/schemas/SearchType" - } - }, - { - "name": "seq_no_primary_term", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "size", - "in": "query", - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "sort", - "in": "query", - "style": "form", - "schema": { - "type": "array", - "items": { - "type": "string" - } - }, - "explode": true - }, - { - "name": "source", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "source_excludes", - "in": "query", - "style": "form", - "schema": { - "type": "array", - "items": { - "type": "string" - } - }, - "explode": true - }, - { - "name": "source_includes", - "in": "query", - "style": "form", - "schema": { - "type": "array", - "items": { - "type": "string" - } - }, - "explode": true - }, - { - "name": "stats", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "stored_fields", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "suggest_field", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "suggest_mode", - "in": "query", - "schema": { - "$ref": "#/components/schemas/SuggestMode" - } - }, - { - "name": "suggest_size", - "in": "query", - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "suggest_text", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "terminate_after", - "in": "query", - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - } - }, - { - "name": "track_scores", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "track_total_hits", - "in": "query", - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "typed_keys", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "version", - "in": "query", - "schema": { - "type": "boolean" - } - } - ], - "responses": { - "200": { - "description": "PostSearch 200 response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PostSearchResponseContent" - }, - "examples": { - "PostSearch_example1": { - "summary": "Examples for Post Search Operation.", - "description": "", - "value": { - "timed_out": false, - "_shards": { - "total": 1, - "successful": 1, - "skipped": 0, - "failed": 0 - }, - "hits": { - "total": { - "value": 0, - "relation": "eq" - }, - "hits": [] - } - } - } - } - } - } - } - } - } - }, - "/{index}": { - "delete": { - "description": "Removes a document from the index.", - "operationId": "DeleteIndex", - "parameters": [ - { - "name": "index", - "in": "path", - "schema": { - "type": "string", - "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" - }, - "required": true, - "examples": { - "DeleteIndex_example1": { - "summary": "Examples for Delete Index Operation.", - "description": "", - "value": "books" - } - } - }, - { - "name": "master_timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", - "deprecated": true - } - }, - { - "name": "cluster_manager_timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - } - }, - { - "name": "allow_no_indices", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "expand_wildcards", - "in": "query", - "schema": { - "$ref": "#/components/schemas/ExpandWildcards" - } - }, - { - "name": "ignore_unavailable", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - } - } - ], - "responses": { - "200": { - "description": "DeleteIndex 200 response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DeleteIndexResponseContent" - }, - "examples": { - "DeleteIndex_example1": { - "summary": "Examples for Delete Index Operation.", - "description": "", - "value": { - "acknowledged": true - } - } - } - } - } - } - } - }, - "put": { - "description": "Creates index mappings.", - "operationId": "PutCreateIndex", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PutCreateIndexRequestContent" - }, - "examples": { - "PutCreateIndex_example1": { - "summary": "Examples for Create Index Operation.", - "description": "", - "value": {} - } - } - } - } - }, - "parameters": [ - { - "name": "index", - "in": "path", - "schema": { - "type": "string", - "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" - }, - "required": true, - "examples": { - "PutCreateIndex_example1": { - "summary": "Examples for Create Index Operation.", - "description": "", - "value": "books" - } - } - }, - { - "name": "master_timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", - "deprecated": true - } - }, - { - "name": "cluster_manager_timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - } - }, - { - "name": "include_type_name", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "wait_for_active_shards", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - } - } - ], - "responses": { - "200": { - "description": "PutCreateIndex 200 response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PutCreateIndexResponseContent" - }, - "examples": { - "PutCreateIndex_example1": { - "summary": "Examples for Create Index Operation.", - "description": "", - "value": { - "index": "books", - "shards_acknowledged": true, - "acknowledged": true - } - } - } - } - } - } - } - } - }, - "/{index}/_doc/{id}": { - "get": { - "description": "Returns a document", - "operationId": "GetDocumentDoc", - "parameters": [ - { - "name": "index", - "in": "path", - "schema": { - "type": "string", - "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" - }, - "required": true, - "examples": { - "GetDocumentDoc_example1": { - "summary": "Examples for Get document doc Operation.", - "description": "", - "value": "books" - } - } - }, - { - "name": "id", - "in": "path", - "schema": { - "type": "string" - }, - "required": true, - "examples": { - "GetDocumentDoc_example1": { - "summary": "Examples for Get document doc Operation.", - "description": "", - "value": "1" - } - } - }, - { - "name": "preference", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "realtime", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "refresh", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "routing", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "stored_fields", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "_source", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "_source_excludes", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "_source_includes", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "version", - "in": "query", - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "version_type", - "in": "query", - "schema": { - "$ref": "#/components/schemas/VersionType" - } - } - ], - "responses": { - "200": { - "description": "GetDocumentDoc 200 response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GetDocumentDocResponseContent" - }, - "examples": { - "GetDocumentDoc_example1": { - "summary": "Examples for Get document doc Operation.", - "description": "", - "value": { - "_index": "books", - "_id": "1", - "found": true - } - } - } - } - } - } - } - } - }, - "/{index}/_mapping": { - "put": { - "description": "The put mapping API operation lets you add new mappings and fields to an index.", - "operationId": "PutIndexMappingWithIndex", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PutIndexMappingWithIndexRequestContent" - }, - "examples": { - "PutIndexMappingWithIndex_example1": { - "summary": "Examples for Put Index Mapping with index Operation.", - "description": "", - "value": {} - } - } - } - } - }, - "parameters": [ - { - "name": "index", - "in": "path", - "schema": { - "type": "string", - "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" - }, - "required": true, - "examples": { - "PutIndexMappingWithIndex_example1": { - "summary": "Examples for Put Index Mapping with index Operation.", - "description": "", - "value": "books" - } - } - }, - { - "name": "master_timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", - "deprecated": true - } - }, - { - "name": "cluster_manager_timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - } - }, - { - "name": "allow_no_indices", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "expand_wildcards", - "in": "query", - "schema": { - "$ref": "#/components/schemas/ExpandWildcards" - } - }, - { - "name": "ignore_unavailable", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "include_type_name", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - } - }, - { - "name": "write_index_only", - "in": "query", - "schema": { - "type": "boolean" - } - } - ], - "responses": { - "200": { - "description": "PutIndexMappingWithIndex 200 response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PutIndexMappingWithIndexResponseContent" - }, - "examples": { - "PutIndexMappingWithIndex_example1": { - "summary": "Examples for Put Index Mapping with index Operation.", - "description": "", - "value": { - "acknowledged": true - } - } - } - } - } - } - } - } - }, - "/{index}/_search": { - "post": { - "description": "Returns results matching a query.", - "operationId": "PostSearchWithIndex", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PostSearchWithIndexRequestContent" - }, - "examples": { - "PostSearchWithIndex_example1": { - "summary": "Examples for Post Search With Index Operation.", - "description": "", - "value": { - "query": { - "match_all": {} - }, - "fields": [ - "*" - ] - } - } - } - } - } - }, - "parameters": [ - { - "name": "index", - "in": "path", - "schema": { - "type": "string", - "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" - }, - "required": true, - "examples": { - "PostSearchWithIndex_example1": { - "summary": "Examples for Post Search With Index Operation.", - "description": "", - "value": "books" - } - } - }, - { - "name": "allow_no_indices", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "allow_partial_search_results", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "analyzer", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "analyze_wildcard", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "batched_reduce_size", - "in": "query", - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "ccs_minimize_roundtrips", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "default_operator", - "in": "query", - "schema": { - "$ref": "#/components/schemas/DefaultOperator" - } - }, - { - "name": "df", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "docvalue_fields", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "expand_wildcards", - "in": "query", - "schema": { - "$ref": "#/components/schemas/ExpandWildcards" - } - }, - { - "name": "explain", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "from", - "in": "query", - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "ignore_throttled", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "ignore_unavailable", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "lenient", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "max_concurrent_shard_requests", - "in": "query", - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "pre_filter_shard_size", - "in": "query", - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "preference", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "q", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "request_cache", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "rest_total_hits_as_int", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "routing", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "scroll", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - }, - "examples": { - "PostSearchWithIndex_example1": { - "summary": "Examples for Post Search With Index Operation.", - "description": "", - "value": "1d" - } - } - }, - { - "name": "search_type", - "in": "query", - "schema": { - "$ref": "#/components/schemas/SearchType" - } - }, - { - "name": "seq_no_primary_term", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "size", - "in": "query", - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "sort", - "in": "query", - "style": "form", - "schema": { - "type": "array", - "items": { - "type": "string" - } - }, - "explode": true - }, - { - "name": "source", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "source_excludes", - "in": "query", - "style": "form", - "schema": { - "type": "array", - "items": { - "type": "string" - } - }, - "explode": true - }, - { - "name": "source_includes", - "in": "query", - "style": "form", - "schema": { - "type": "array", - "items": { - "type": "string" - } - }, - "explode": true - }, - { - "name": "stats", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "stored_fields", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "suggest_field", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "suggest_mode", - "in": "query", - "schema": { - "$ref": "#/components/schemas/SuggestMode" - } - }, - { - "name": "suggest_size", - "in": "query", - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "suggest_text", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "terminate_after", - "in": "query", - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - } - }, - { - "name": "track_scores", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "track_total_hits", - "in": "query", - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "typed_keys", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "version", - "in": "query", - "schema": { - "type": "boolean" - } - } - ], - "responses": { - "200": { - "description": "PostSearchWithIndex 200 response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PostSearchWithIndexResponseContent" - }, - "examples": { - "PostSearchWithIndex_example1": { - "summary": "Examples for Post Search With Index Operation.", - "description": "", - "value": { - "timed_out": false, - "_shards": { - "total": 1, - "successful": 1, - "skipped": 0, - "failed": 0 - }, - "hits": { - "total": { - "value": 0, - "relation": "eq" - }, - "hits": [] - } - } - } - } - } - } - } - } - } - }, - "/{index}/_settings": { - "get": { - "description": "The get settings API operation returns all the settings in your index.", - "operationId": "GetSettingsIndex", - "parameters": [ - { - "name": "index", - "in": "path", - "schema": { - "type": "string", - "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" - }, - "required": true, - "examples": { - "GetSettingsIndex_example1": { - "summary": "Examples for Get settings Index Operation.", - "description": "", - "value": "books" - } - } - }, - { - "name": "master_timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", - "deprecated": true - } - }, - { - "name": "cluster_manager_timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - } - }, - { - "name": "allow_no_indices", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "expand_wildcards", - "in": "query", - "schema": { - "$ref": "#/components/schemas/ExpandWildcards" - } - }, - { - "name": "flat_settings", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "include_defaults", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "ignore_unavailable", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "local", - "in": "query", - "schema": { - "type": "boolean" - } - } - ], - "responses": { - "200": { - "description": "GetSettingsIndex 200 response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GetSettingsIndexOutputPayload" - } - } - } - } - } - } - }, - "/{index}/_settings/{setting}": { - "get": { - "description": "The get settings API operation returns all the settings in your index.", - "operationId": "GetSettingsIndexSetting", - "parameters": [ - { - "name": "index", - "in": "path", - "schema": { - "type": "string", - "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" - }, - "required": true, - "examples": { - "GetSettingsIndexSetting_example1": { - "summary": "Examples for Get settings Index-setting Operation.", - "description": "", - "value": "books" - } - } - }, - { - "name": "setting", - "in": "path", - "schema": { - "type": "string" - }, - "required": true, - "examples": { - "GetSettingsIndexSetting_example1": { - "summary": "Examples for Get settings Index-setting Operation.", - "description": "", - "value": "index" - } - } - }, - { - "name": "master_timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", - "deprecated": true - } - }, - { - "name": "cluster_manager_timeout", - "in": "query", - "schema": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - } - }, - { - "name": "allow_no_indices", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "expand_wildcards", - "in": "query", - "schema": { - "$ref": "#/components/schemas/ExpandWildcards" - } - }, - { - "name": "flat_settings", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "include_defaults", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "ignore_unavailable", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "local", - "in": "query", - "schema": { - "type": "boolean" - } - } - ], - "responses": { - "200": { - "description": "GetSettingsIndexSetting 200 response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GetSettingsIndexSettingOutputPayload" - } - } - } - } - } - } - }, - "/{index}/_source/{id}": { - "get": { - "description": "Returns a document.", - "operationId": "GetDocumentSource", - "parameters": [ - { - "name": "index", - "in": "path", - "schema": { - "type": "string", - "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" - }, - "required": true, - "examples": { - "GetDocumentSource_example1": { - "summary": "Examples for Get document source Operation.", - "description": "", - "value": "books" - } - } - }, - { - "name": "id", - "in": "path", - "schema": { - "type": "string" - }, - "required": true, - "examples": { - "GetDocumentSource_example1": { - "summary": "Examples for Get document source Operation.", - "description": "", - "value": "1" - } - } - }, - { - "name": "preference", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "realtime", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "refresh", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "routing", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "stored_fields", - "in": "query", - "schema": { - "type": "boolean" - } - }, - { - "name": "_source", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "_source_excludes", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "_source_includes", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "version", - "in": "query", - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "version_type", - "in": "query", - "schema": { - "$ref": "#/components/schemas/VersionType" - } - } - ], - "responses": { - "200": { - "description": "GetDocumentSource 200 response" - } - } - } - } - }, - "components": { - "schemas": { - "ActionObjectStructure": { - "type": "object", - "properties": { - "add": { - "$ref": "#/components/schemas/UserDefinedStructure" - }, - "remove": { - "$ref": "#/components/schemas/UserDefinedStructure" - }, - "remove_index": { - "$ref": "#/components/schemas/UserDefinedStructure" - } - } - }, - "DefaultOperator": { - "type": "string", - "enum": [ - "AND", - "OR" - ] - }, - "DeleteIndexResponseContent": { - "type": "object", - "properties": { - "acknowledged": { - "type": "boolean" - } - } - }, - "ExpandWildcards": { - "type": "string", - "enum": [ - "all", - "open", - "closed", - "hidden", - "none" - ] - }, - "GetCatIndicesOutputPayload": {}, - "GetCatIndicesWithIndexOutputPayload": {}, - "GetCatNodesOutputPayload": {}, - "GetClusterInfoResponseContent": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "cluster_name": { - "type": "string" - }, - "cluster_uuid": { - "type": "string" - }, - "version": { - "$ref": "#/components/schemas/Version" - }, - "tagline": { - "type": "string" - } - } - }, - "GetClusterSettingsResponseContent": { - "type": "object", - "properties": { - "persistent": { - "$ref": "#/components/schemas/UserDefinedValueMap" - }, - "transient": { - "$ref": "#/components/schemas/UserDefinedValueMap" - }, - "defaults": { - "$ref": "#/components/schemas/UserDefinedValueMap" - } - } - }, - "GetDocumentDocResponseContent": { - "type": "object", - "properties": { - "_index": { - "type": "string", - "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" - }, - "_type": { - "type": "string" - }, - "_id": { - "type": "string" - }, - "version": { - "type": "integer", - "format": "int32" - }, - "seq_no": { - "type": "integer", - "format": "int64" - }, - "primary_term": { - "type": "integer", - "format": "int64" - }, - "found": { - "type": "boolean" - }, - "_routing": { - "type": "string" - }, - "_source": { - "$ref": "#/components/schemas/UserDefinedValueMap" - }, - "_fields": { - "$ref": "#/components/schemas/UserDefinedValueMap" - } - }, - "required": [ - "_id", - "_index", - "found" - ] - }, - "GetSettingsIndexOutputPayload": {}, - "GetSettingsIndexSettingOutputPayload": {}, - "HealthStatus": { - "type": "string", - "enum": [ - "green", - "yellow", - "red" - ] - }, - "Hits": { - "type": "object", - "properties": { - "_index": { - "type": "string" - }, - "_type": { - "type": "string" - }, - "_id": { - "type": "string" - }, - "_score": { - "type": "number", - "format": "float" - }, - "_source": {}, - "fields": {} - } - }, - "HitsMetadata": { - "type": "object", - "properties": { - "total": { - "$ref": "#/components/schemas/Total" - }, - "max_score": { - "type": "number", - "format": "double" - }, - "hits": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Hits" - } - } - } - }, - "PostAliasesRequestContent": { - "type": "object", - "properties": { - "actions": { - "$ref": "#/components/schemas/ActionObjectStructure" - } - } - }, - "PostAliasesResponseContent": { - "type": "object", - "properties": { - "acknowledged": { - "type": "boolean" - } - }, - "required": [ - "acknowledged" - ] - }, - "PostRemoteStoreRestoreRequestContent": { - "type": "object", - "properties": { - "indices": { - "type": "array", - "items": { - "type": "string", - "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" - } - } - }, - "required": [ - "indices" - ] - }, - "PostRemoteStoreRestoreResponseContent": { - "type": "object", - "properties": { - "accepted": { - "type": "boolean" - }, - "remote_store": { - "$ref": "#/components/schemas/RemoteStoreRestoreInfo" - } - } - }, - "PostSearchRequestContent": { - "type": "object", - "properties": { - "docvalue_fields": { - "type": "string" - }, - "explain": { - "type": "boolean" - }, - "from": { - "type": "integer", - "format": "int32" - }, - "seq_no_primary_term": { - "type": "boolean" - }, - "size": { - "type": "integer", - "format": "int32" - }, - "source": { - "type": "string" - }, - "stats": { - "type": "string" - }, - "terminate_after": { - "type": "integer", - "format": "int32" - }, - "timeout": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - }, - "version": { - "type": "boolean" - }, - "fields": { - "type": "array", - "items": { - "type": "string" - } - }, - "min_score": { - "type": "integer", - "format": "int32" - }, - "indices_boost": { - "type": "array", - "items": {} - }, - "query": { - "$ref": "#/components/schemas/UserDefinedObjectStructure" - } - } - }, - "PostSearchResponseContent": { - "type": "object", - "properties": { - "_scroll_id": { - "type": "string" - }, - "took": { - "type": "integer", - "format": "int64" - }, - "timed_out": { - "type": "boolean" - }, - "_shards": { - "$ref": "#/components/schemas/ShardStatistics" - }, - "hits": { - "$ref": "#/components/schemas/HitsMetadata" - } - } - }, - "PostSearchWithIndexRequestContent": { - "type": "object", - "properties": { - "docvalue_fields": { - "type": "string" - }, - "explain": { - "type": "boolean" - }, - "from": { - "type": "integer", - "format": "int32" - }, - "seq_no_primary_term": { - "type": "boolean" - }, - "size": { - "type": "integer", - "format": "int32" - }, - "source": { - "type": "string" - }, - "stats": { - "type": "string" - }, - "terminate_after": { - "type": "integer", - "format": "int32" - }, - "timeout": { - "type": "string", - "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$" - }, - "version": { - "type": "boolean" - }, - "fields": { - "type": "array", - "items": { - "type": "string" - } - }, - "min_score": { - "type": "integer", - "format": "int32" - }, - "indices_boost": { - "type": "array", - "items": {} - }, - "query": { - "$ref": "#/components/schemas/UserDefinedObjectStructure" - } - } - }, - "PostSearchWithIndexResponseContent": { - "type": "object", - "properties": { - "_scroll_id": { - "type": "string" - }, - "took": { - "type": "integer", - "format": "int64" - }, - "timed_out": { - "type": "boolean" - }, - "_shards": { - "$ref": "#/components/schemas/ShardStatistics" - }, - "hits": { - "$ref": "#/components/schemas/HitsMetadata" - } - } - }, - "PutCreateIndexRequestContent": { - "type": "object", - "properties": { - "aliases": { - "$ref": "#/components/schemas/UserDefinedValueMap" - }, - "mapping": { - "$ref": "#/components/schemas/UserDefinedValueMap" - }, - "settings": { - "$ref": "#/components/schemas/UserDefinedValueMap" - } - } - }, - "PutCreateIndexResponseContent": { - "type": "object", - "properties": { - "index": { - "type": "string", - "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" - }, - "shards_acknowledged": { - "type": "boolean" - }, - "acknowledged": { - "type": "boolean" - } - }, - "required": [ - "acknowledged", - "index", - "shards_acknowledged" - ] - }, - "PutIndexMappingWithIndexRequestContent": { - "type": "object", - "properties": { - "properties": {} - } - }, - "PutIndexMappingWithIndexResponseContent": { - "type": "object", - "properties": { - "acknowledged": { - "type": "boolean" - } - } - }, - "PutUpdateClusterSettingsRequestContent": { - "type": "object", - "properties": { - "persistent": { - "$ref": "#/components/schemas/UserDefinedValueMap" - }, - "transient": { - "$ref": "#/components/schemas/UserDefinedValueMap" - } - } - }, - "PutUpdateClusterSettingsResponseContent": { - "type": "object", - "properties": { - "acknowledged": { - "type": "boolean" - }, - "persistent": { - "$ref": "#/components/schemas/UserDefinedValueMap" - }, - "transient": { - "$ref": "#/components/schemas/UserDefinedValueMap" - } - } - }, - "Relation": { - "type": "string", - "enum": [ - "eq", - "gte" - ] - }, - "RemoteStoreRestoreInfo": { - "type": "object", - "properties": { - "snapshot": { - "type": "string" - }, - "indices": { - "type": "array", - "items": { - "type": "string", - "pattern": "^[^+_\\-\\.][^\\\\, /*?\"<>| ,#\\nA-Z]+$" - } - }, - "shards": { - "$ref": "#/components/schemas/RemoteStoreRestoreShardsInfo" - } - } - }, - "RemoteStoreRestoreShardsInfo": { - "type": "object", - "properties": { - "total": { - "type": "integer", - "format": "int32" - }, - "failed": { - "type": "integer", - "format": "int32" - }, - "successful": { - "type": "integer", - "format": "int32" - } - } - }, - "SearchType": { - "type": "string", - "enum": [ - "query_then_fetch", - "dfs_query_then_fetch" - ] - }, - "ShardStatistics": { - "type": "object", - "properties": { - "total": { - "type": "integer", - "format": "int32" - }, - "successful": { - "type": "integer", - "format": "int32" - }, - "skipped": { - "type": "integer", - "format": "int32" - }, - "failed": { - "type": "integer", - "format": "int32" - } - } - }, - "SuggestMode": { - "type": "string", - "enum": [ - "missing", - "popular", - "always" - ] - }, - "Total": { - "type": "object", - "properties": { - "value": { - "type": "integer", - "format": "int32" - }, - "relation": { - "$ref": "#/components/schemas/Relation" - } - } - }, - "UserDefinedObjectStructure": { - "type": "object", - "properties": { - "bool": {}, - "boosting": {}, - "combined_fields": {}, - "constant_score": {}, - "dis_max": {}, - "distance_feature": {}, - "exists": {}, - "function_score": {}, - "fuzzy": { - "$ref": "#/components/schemas/UserDefinedValueMap" - }, - "geo_bounding_box": {}, - "geo_distance": {}, - "geo_polygon": {}, - "geo_shape": {}, - "has_child": {}, - "has_parent": {}, - "ids": {}, - "intervals": { - "$ref": "#/components/schemas/UserDefinedValueMap" - }, - "knn": {}, - "match": { - "$ref": "#/components/schemas/UserDefinedValueMap" - }, - "match_all": {}, - "match_bool_prefix": { - "$ref": "#/components/schemas/UserDefinedValueMap" - }, - "match_none": {}, - "match_phrase": { - "$ref": "#/components/schemas/UserDefinedValueMap" - }, - "match_phrase_prefix": { - "$ref": "#/components/schemas/UserDefinedValueMap" - }, - "more_like_this": {}, - "multi_match": {}, - "nested": {}, - "parent_id": {}, - "percolate": {}, - "pinned": {}, - "prefix": { - "$ref": "#/components/schemas/UserDefinedValueMap" - }, - "query_string": {}, - "range": { - "$ref": "#/components/schemas/UserDefinedValueMap" - }, - "rank_feature": {}, - "regexp": { - "$ref": "#/components/schemas/UserDefinedValueMap" - }, - "script": {}, - "script_score": {}, - "shape": {}, - "simple_query_string": {}, - "span_containing": {}, - "field_masking_span": {}, - "span_first": {}, - "span_multi": {}, - "span_near": {}, - "span_not": {}, - "span_or": {}, - "span_term": { - "$ref": "#/components/schemas/UserDefinedValueMap" - }, - "span_within": {}, - "term": { - "$ref": "#/components/schemas/UserDefinedValueMap" - }, - "terms": {}, - "terms_set": { - "$ref": "#/components/schemas/UserDefinedValueMap" - }, - "wildcard": { - "$ref": "#/components/schemas/UserDefinedValueMap" - }, - "wrapper": {} - } - }, - "UserDefinedStructure": { - "type": "object", - "properties": { - "alias": { - "type": "string" - }, - "aliases": { - "type": "array", - "items": { - "type": "string" - } - }, - "filter": {}, - "index": { - "type": "string" - }, - "indices": { - "type": "array", - "items": { - "type": "string" - } - }, - "index_routing": { - "type": "string" - }, - "is_hidden": { - "type": "boolean" - }, - "is_write_index": { - "type": "boolean" - }, - "must_exist": { - "type": "string" - }, - "routing": { - "type": "string" - }, - "search_routing": { - "type": "string" - } - } - }, - "UserDefinedValueMap": { - "type": "object", - "additionalProperties": {} - }, - "Version": { - "type": "object", - "properties": { - "distribution": { - "type": "string" - }, - "number": { - "type": "string" - }, - "build_type": { - "type": "string" - }, - "build_hash": { - "type": "string" - }, - "build_date": { - "type": "string" - }, - "build_snapshot": { - "type": "boolean" - }, - "lucene_version": { - "type": "string" - }, - "minimum_wire_compatibility_version": { - "type": "string" - }, - "minimum_index_compatibility_version": { - "type": "string" - } - } - }, - "VersionType": { - "type": "string", - "enum": [ - "internal", - "external", - "external_gte" - ] - } - }, - "securitySchemes": { - "smithy.api.httpBasicAuth": { - "type": "http", - "description": "HTTP Basic authentication", - "scheme": "Basic" - } - } - }, - "security": [ - { - "smithy.api.httpBasicAuth": [] - } - ] -} diff --git a/java-codegen/OpenSearch.yaml b/java-codegen/OpenSearch.yaml new file mode 100644 index 0000000000..5dd44b506e --- /dev/null +++ b/java-codegen/OpenSearch.yaml @@ -0,0 +1,80 @@ +openapi: 3.0.3 +info: + title: OpenSearch + version: 1.0.0 +paths: + /_remotestore/_restore: + post: + description: Restore one or more indices from a remote backup. + operationId: PostRemoteStoreRestore + x-namespace: remote_store + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/PostRemoteStoreRestoreRequest" + required: true + parameters: + - name: cluster_manager_timeout + in: query + schema: + type: string + pattern: ^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$ + - name: wait_for_completion + in: query + schema: + type: boolean + responses: + 200: + description: PostRemoteStoreRestore 200 response + content: + application/json: + schema: + $ref: "#/components/schemas/PostRemoteStoreRestoreResponse" +components: + schemas: + PostRemoteStoreRestoreRequest: + x-namespace: remote_store + type: object + properties: + indices: + type: array + items: + type: string + pattern: ^[^+_\-\.][^\\, /*?"<>| ,#\nA-Z]+$ + required: + - indices + PostRemoteStoreRestoreResponse: + x-namespace: remote_store + type: object + properties: + accepted: + type: boolean + remote_store: + $ref: "#/components/schemas/RemoteStoreRestoreInfo" + RemoteStoreRestoreInfo: + x-namespace: remote_store + type: string + properties: + snapshot: + type: string + indices: + type: array + items: + type: string + pattern: ^[^+_\-\.][^\\, /*?"<>| ,#\nA-Z]+$ + shards: + $ref: "#/components/schemas/RemoteStoreRestoreShardsInfo" + RemoteStoreRestoreShardsInfo: + x-namespace: remote_store + type: object + properties: + total: + type: integer + format: int32 + failed: + type: integer + format: int32 + successful: + type: integer + format: int32 \ No newline at end of file diff --git a/java-codegen/build.gradle.kts b/java-codegen/build.gradle.kts index 1b46b81894..1f5eb2e1f4 100644 --- a/java-codegen/build.gradle.kts +++ b/java-codegen/build.gradle.kts @@ -60,7 +60,7 @@ application { tasks.named("run") { args = listOf( - "${projectDir}/OpenSearch.openapi.json", + "${projectDir}/OpenSearch.yaml", "${project(":java-client").projectDir}/src/generated/java/" ) } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java b/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java index 5bdc51c24b..6d8d972d0d 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java @@ -92,6 +92,7 @@ private void visit(String httpPath, Path path) throws ApiSpecificationParseExcep private void visit(String httpPath, Path path, String httpMethod, Operation operation) throws ApiSpecificationParseException { RequestShape requestShape = new RequestShape( + Schemas.getNamespaceExtension(operation), operation.getOperationId(), operation.getDescription(), httpMethod, @@ -131,12 +132,16 @@ private void visitReferencedSchema(String ref, Schema schema) { if (Schemas.isObject(schema)) { visitObjectShape(name, schema); } else if (Schemas.isString(schema) && schema.hasEnums()) { - enumShapes.add(new EnumShape(name, schema.getEnums().stream().map(Object::toString).collect(Collectors.toList()))); + enumShapes.add(new EnumShape( + Schemas.getNamespaceExtension(schema), + name, + schema.getEnums().stream().map(Object::toString).collect(Collectors.toList()) + )); } } private void visitObjectShape(String name, Schema schema) { - ObjectShape shape = new ObjectShape(name); + ObjectShape shape = new ObjectShape(Schemas.getNamespaceExtension(schema), name); visitFields(schema, shape::addBodyField); objectShapes.add(shape); } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java b/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java index 8b34bed3c1..50c1b5705a 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java @@ -14,25 +14,26 @@ import org.opensearch.client.codegen.model.EnumShape; import org.opensearch.client.codegen.model.ObjectShape; import org.opensearch.client.codegen.model.RequestShape; +import org.opensearch.client.codegen.model.Shape; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.Comparator; +import java.util.HashMap; +import java.util.Map; import java.util.stream.Stream; public class Generator { private final ApiSpecification apiSpecification; private final Renderer renderer; private final File outputDir; - private final File packageDir; public Generator(File schemaFile, File outputDir) throws ApiSpecificationParseException { apiSpecification = ApiSpecification.parse(schemaFile); renderer = new Renderer(); this.outputDir = outputDir; - packageDir = new File(outputDir, "org/opensearch/client/opensearch/"); } public void generate() throws RenderException { @@ -44,33 +45,33 @@ public void generate() throws RenderException { throw new RenderException("Unable to cleanup output directory: " + outputDir, e); } - packageDir.mkdirs(); - - Client client = new Client(""); + Map namespaceClients = new HashMap<>(); for (RequestShape requestShape : apiSpecification.getRequestShapes()) { - File file = new File(packageDir, requestShape.className() + ".java"); - renderer.render(requestShape, file); + renderShape(requestShape); - client.addOperation(requestShape.id()); + namespaceClients.computeIfAbsent(requestShape.namespace(), Client::new) + .addOperation(requestShape.id()); } for (ObjectShape objectShape : apiSpecification.getObjectShapes()) { - File file = new File(packageDir, objectShape.className() + ".java"); - renderer.render(objectShape, file); + renderShape(objectShape); } for (EnumShape enumShape : apiSpecification.getEnumShapes()) { - File file = new File(packageDir, enumShape.className() + ".java"); - renderer.render(enumShape, file); + renderShape(enumShape); } - File clientFile = new File(packageDir, client.className() + ".java"); - renderer.render(client, clientFile); - - client.async(true); + for (Client client : namespaceClients.values()) { + renderShape(client); + renderShape(client.async(true)); + } + } - File asyncClientFile = new File(packageDir, client.className() + ".java"); - renderer.render(client, asyncClientFile); + private void renderShape(S shape) throws RenderException { + File packageDir = new File(outputDir, shape.packageName().replace('.', '/')); + packageDir.mkdirs(); + File outputFile = new File(packageDir, shape.className() + ".java"); + renderer.render(shape, outputFile); } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Client.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Client.java index b89985e09f..637c283d5c 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Client.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Client.java @@ -14,25 +14,21 @@ import java.util.Map; import java.util.TreeMap; -public class Client { - private final String namespace; - private boolean async; +public class Client extends Shape { + private final boolean async; private final Map operations = new TreeMap<>(); public Client(String namespace) { - this.namespace = namespace; + this(namespace, false); } - public void addOperation(String id) { - operations.put(id, new ClientOperation(id)); - } - - public String className() { - return "OpenSearch" + Strings.toPascalCase(namespace) + (async ? "Async" : "") + "Client"; + private Client(String namespace, boolean async) { + super(namespace, "OpenSearch" + Strings.toPascalCase(namespace) + (async ? "Async" : "") + "Client"); + this.async = async; } - public String namespace() { - return namespace; + public void addOperation(String id) { + operations.put(id, new ClientOperation(id)); } public Collection operations() { @@ -43,7 +39,10 @@ public boolean async() { return async; } - public void async(boolean async) { - this.async = async; + public Client async(boolean async) { + if (async == this.async) return this; + Client client = new Client(namespace, async); + operations.keySet().forEach(client::addOperation); + return client; } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java index ae8c14ab5b..24443a53b6 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java @@ -14,17 +14,14 @@ import java.util.List; import java.util.stream.Collectors; -public class EnumShape { - public final String name; +public class EnumShape extends Shape { public final List variants; - public EnumShape(String name, Collection variants) { - this.name = name; + public EnumShape(String namespace, String className, Collection variants) { + super(namespace, className); this.variants = variants.stream().map(Variant::new).collect(Collectors.toList()); } - public String className() { return name; } - public static class Variant { public final String wireName; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java index b174f62692..7ed40a678e 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java @@ -12,22 +12,17 @@ import java.util.Map; import java.util.TreeMap; -public class ObjectShape { - private final String className; +public class ObjectShape extends Shape { private final Map bodyFields = new TreeMap<>(); - public ObjectShape(String className) { - this.className = className; + public ObjectShape(String namespace, String className) { + super(namespace, className); } public void addBodyField(Field field) { bodyFields.put(field.name(), field); } - public String className() { - return className; - } - public Collection bodyFields() { return bodyFields.values(); } public Collection fields() { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java index 2530597703..9d5c6854d1 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java @@ -21,8 +21,8 @@ public class RequestShape extends ObjectShape { private final Map pathParams = new TreeMap<>(); private final Map fields = new TreeMap<>(); - public RequestShape(String id, String description, String httpMethod, String httpPath) { - super(id + "Request"); + public RequestShape(String namespace, String id, String description, String httpMethod, String httpPath) { + super(namespace, id + "Request"); this.id = id; this.description = description; this.httpMethod = httpMethod; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java new file mode 100644 index 0000000000..18e8f7b2ca --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java @@ -0,0 +1,31 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.client.codegen.model; + +public abstract class Shape { + protected final String namespace; + private final String className; + + public Shape(String namespace, String className) { + this.namespace = namespace; + this.className = className; + } + + public String namespace() { + return this.namespace; + } + + public String packageName() { + return "org.opensearch.client.opensearch." + this.namespace.replace("_", "").toLowerCase(); + } + + public String className() { + return this.className; + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Schemas.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Schemas.java index 30dfbb78ef..e3a6b23ddf 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Schemas.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Schemas.java @@ -9,6 +9,8 @@ package org.opensearch.client.codegen.utils; import org.openapi4j.core.model.v3.OAI3SchemaKeywords; +import org.openapi4j.parser.model.v3.AbsExtendedOpenApiSchema; +import org.openapi4j.parser.model.v3.AbsExtendedRefOpenApiSchema; import org.openapi4j.parser.model.v3.Schema; public final class Schemas { @@ -20,4 +22,20 @@ public final class Schemas { public static boolean isString(Schema schema) { return is(schema, OAI3SchemaKeywords.TYPE_STRING); } public static boolean hasEnums(Schema schema) { return schema != null && schema.hasEnums(); } + + public static String getNamespaceExtension(AbsExtendedOpenApiSchema schema) { + return (String) getExtension(schema, "x-namespace"); + } + + public static String getNamespaceExtension(AbsExtendedRefOpenApiSchema schema) { + return (String) getExtension(schema, "x-namespace"); + } + + public static Object getExtension(AbsExtendedOpenApiSchema schema, String key) { + return schema.getExtensions().get(key); + } + + public static Object getExtension(AbsExtendedRefOpenApiSchema schema, String key) { + return schema.getExtensions().get(key); + } } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Client.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Client.mustache index 0aae699919..d09387ee13 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Client.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Client.mustache @@ -1,4 +1,4 @@ -package org.opensearch.client.opensearch; +package {{packageName}}; import org.opensearch.client.ApiClient; import org.opensearch.client.opensearch._types.OpenSearchException; diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache index 7aa1819e49..6ea9876d61 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache @@ -1,4 +1,4 @@ -package org.opensearch.client.opensearch; +package {{packageName}}; import org.opensearch.client.json.JsonEnum; import org.opensearch.client.json.JsonpDeserializable; diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache index 15430f824c..9a6c990157 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache @@ -1,4 +1,4 @@ -package org.opensearch.client.opensearch; +package {{packageName}}; import org.opensearch.client.json.*; import org.opensearch.client.util.*; diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache index df4e16873c..b9e030c516 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache @@ -1,4 +1,4 @@ -package org.opensearch.client.opensearch; +package {{packageName}}; import org.opensearch.client.opensearch._types.*; {{#hasRequestBody}} From 29d6e6ae01a22d0ca90e787d6dbba748143ed44b Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Fri, 17 Feb 2023 13:29:49 +1300 Subject: [PATCH 11/50] Add license header, improve http path builder, fix remote store spec Signed-off-by: Thomas Farr --- .../OpenSearchRemoteStoreAsyncClient.java | 8 + .../OpenSearchRemoteStoreClient.java | 8 + .../PostRemoteStoreRestoreRequest.java | 38 +++-- .../PostRemoteStoreRestoreResponse.java | 42 +++-- .../remotestore/RemoteStoreRestoreInfo.java | 145 ++++++++++++++++++ .../RemoteStoreRestoreShardsInfo.java | 126 +++++++++++++++ java-codegen/OpenSearch.yaml | 2 +- .../client/codegen/model/RequestShape.java | 44 +++++- .../client/codegen/templates/Client.mustache | 2 + .../codegen/templates/EnumShape.mustache | 2 + .../codegen/templates/ObjectShape.mustache | 18 ++- .../templates/Partials/LicenseHeader.mustache | 7 + .../codegen/templates/RequestShape.mustache | 39 +++-- 13 files changed, 446 insertions(+), 35 deletions(-) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RemoteStoreRestoreInfo.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RemoteStoreRestoreShardsInfo.java create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Partials/LicenseHeader.mustache diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreAsyncClient.java b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreAsyncClient.java index 6ee515e734..8532eb0ea3 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreAsyncClient.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreAsyncClient.java @@ -1,3 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.opensearch.remotestore; import org.opensearch.client.ApiClient; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreClient.java b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreClient.java index db28ab73a6..8ff4a99e9c 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreClient.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreClient.java @@ -1,3 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.opensearch.remotestore; import org.opensearch.client.ApiClient; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/PostRemoteStoreRestoreRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/PostRemoteStoreRestoreRequest.java index 2a4da0a8d8..033025529b 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/PostRemoteStoreRestoreRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/PostRemoteStoreRestoreRequest.java @@ -1,15 +1,33 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.opensearch.remotestore; -import org.opensearch.client.opensearch._types.*; -import org.opensearch.client.json.*; -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; -import org.opensearch.client.util.*; +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.JsonpSerializable; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.opensearch._types.ErrorResponse; +import org.opensearch.client.opensearch._types.RequestBase; +import org.opensearch.client.transport.Endpoint; +import org.opensearch.client.transport.endpoints.SimpleEndpoint; +import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ObjectBuilderBase; import jakarta.json.stream.JsonGenerator; -import java.util.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.function.Function; -import java.util.stream.*; -import javax.annotation.*; +import java.util.stream.Collectors; +import javax.annotation.Nullable; /** Restore one or more indices from a remote backup. */ @JsonpDeserializable @@ -121,7 +139,9 @@ protected static void setupPostRemoteStoreRestoreRequestDeserializer( }, // Request path request -> { - return "/_remotestore/_restore"; + StringBuilder buf = new StringBuilder(); + buf.append("/_remotestore/_restore"); + return buf.toString(); }, // Request parameters request -> { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/PostRemoteStoreRestoreResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/PostRemoteStoreRestoreResponse.java index 2942c75e59..18fa8dd09f 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/PostRemoteStoreRestoreResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/PostRemoteStoreRestoreResponse.java @@ -1,18 +1,34 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.opensearch.remotestore; -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.JsonpSerializable; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ObjectBuilderBase; import jakarta.json.stream.JsonGenerator; -import java.util.*; +import java.util.List; +import java.util.Map; import java.util.function.Function; -import javax.annotation.*; +import javax.annotation.Nullable; @JsonpDeserializable public class PostRemoteStoreRestoreResponse implements JsonpSerializable { @Nullable private final Boolean accepted; - @Nullable private final String remoteStore; + @Nullable private final RemoteStoreRestoreInfo remoteStore; public PostRemoteStoreRestoreResponse(Builder builder) { this.accepted = builder.accepted; @@ -28,7 +44,7 @@ public final Boolean accepted() { return this.accepted; } - public final String remoteStore() { + public final RemoteStoreRestoreInfo remoteStore() { return this.remoteStore; } @@ -46,7 +62,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (this.remoteStore != null) { generator.writeKey("remote_store"); - generator.write(this.remoteStore); + this.remoteStore.serialize(generator, mapper); } } @@ -54,18 +70,24 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private Boolean accepted; - private String remoteStore; + private RemoteStoreRestoreInfo remoteStore; public final Builder accepted(Boolean value) { this.accepted = value; return this; } - public final Builder remoteStore(String value) { + public final Builder remoteStore(RemoteStoreRestoreInfo value) { this.remoteStore = value; return this; } + public final Builder remoteStore( + Function> + fn) { + return remoteStore(fn.apply(new RemoteStoreRestoreInfo.Builder()).build()); + } + /** * Builds a {@link PostRemoteStoreRestoreResponse}. * @@ -87,6 +109,6 @@ public PostRemoteStoreRestoreResponse build() { protected static void setupPostRemoteStoreRestoreResponseDeserializer( ObjectDeserializer op) { op.add(Builder::accepted, JsonpDeserializer.booleanDeserializer(), "accepted"); - op.add(Builder::remoteStore, JsonpDeserializer.stringDeserializer(), "remote_store"); + op.add(Builder::remoteStore, RemoteStoreRestoreInfo._DESERIALIZER, "remote_store"); } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RemoteStoreRestoreInfo.java b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RemoteStoreRestoreInfo.java new file mode 100644 index 0000000000..00a025b321 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RemoteStoreRestoreInfo.java @@ -0,0 +1,145 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.client.opensearch.remotestore; + +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.JsonpSerializable; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ObjectBuilderBase; +import jakarta.json.stream.JsonGenerator; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import javax.annotation.Nullable; + +@JsonpDeserializable +public class RemoteStoreRestoreInfo implements JsonpSerializable { + + @Nullable private final List indices; + + @Nullable private final RemoteStoreRestoreShardsInfo shards; + + @Nullable private final String snapshot; + + public RemoteStoreRestoreInfo(Builder builder) { + this.indices = ApiTypeHelper.unmodifiable(builder.indices); + this.shards = builder.shards; + this.snapshot = builder.snapshot; + } + + public static RemoteStoreRestoreInfo of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final List indices() { + return this.indices; + } + + public final RemoteStoreRestoreShardsInfo shards() { + return this.shards; + } + + public final String snapshot() { + return this.snapshot; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (ApiTypeHelper.isDefined(this.indices)) { + generator.writeKey("indices"); + generator.writeStartArray(); + for (String item0 : this.indices) { + generator.write(item0); + } + generator.writeEnd(); + } + + if (this.shards != null) { + generator.writeKey("shards"); + this.shards.serialize(generator, mapper); + } + + if (this.snapshot != null) { + generator.writeKey("snapshot"); + generator.write(this.snapshot); + } + } + + /** Builder for {@link RemoteStoreRestoreInfo}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private List indices; + private RemoteStoreRestoreShardsInfo shards; + private String snapshot; + + public final Builder indices(List list) { + this.indices = _listAddAll(this.indices, list); + return this; + } + + public final Builder indices(String value, String... values) { + this.indices = _listAdd(this.indices, value, values); + return this; + } + + public final Builder shards(RemoteStoreRestoreShardsInfo value) { + this.shards = value; + return this; + } + + public final Builder shards( + Function< + RemoteStoreRestoreShardsInfo.Builder, + ObjectBuilder> + fn) { + return shards(fn.apply(new RemoteStoreRestoreShardsInfo.Builder()).build()); + } + + public final Builder snapshot(String value) { + this.snapshot = value; + return this; + } + + /** + * Builds a {@link RemoteStoreRestoreInfo}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public RemoteStoreRestoreInfo build() { + _checkSingleUse(); + + return new RemoteStoreRestoreInfo(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, RemoteStoreRestoreInfo::setupRemoteStoreRestoreInfoDeserializer); + + protected static void setupRemoteStoreRestoreInfoDeserializer( + ObjectDeserializer op) { + op.add( + Builder::indices, + JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), + "indices"); + op.add(Builder::shards, RemoteStoreRestoreShardsInfo._DESERIALIZER, "shards"); + op.add(Builder::snapshot, JsonpDeserializer.stringDeserializer(), "snapshot"); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RemoteStoreRestoreShardsInfo.java b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RemoteStoreRestoreShardsInfo.java new file mode 100644 index 0000000000..437761a52b --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RemoteStoreRestoreShardsInfo.java @@ -0,0 +1,126 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.client.opensearch.remotestore; + +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.JsonpSerializable; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ObjectBuilderBase; +import jakarta.json.stream.JsonGenerator; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import javax.annotation.Nullable; + +@JsonpDeserializable +public class RemoteStoreRestoreShardsInfo implements JsonpSerializable { + + @Nullable private final Integer failed; + + @Nullable private final Integer successful; + + @Nullable private final Integer total; + + public RemoteStoreRestoreShardsInfo(Builder builder) { + this.failed = builder.failed; + this.successful = builder.successful; + this.total = builder.total; + } + + public static RemoteStoreRestoreShardsInfo of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public final Integer failed() { + return this.failed; + } + + public final Integer successful() { + return this.successful; + } + + public final Integer total() { + return this.total; + } + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.failed != null) { + generator.writeKey("failed"); + generator.write(this.failed); + } + + if (this.successful != null) { + generator.writeKey("successful"); + generator.write(this.successful); + } + + if (this.total != null) { + generator.writeKey("total"); + generator.write(this.total); + } + } + + /** Builder for {@link RemoteStoreRestoreShardsInfo}. */ + public static class Builder extends ObjectBuilderBase + implements ObjectBuilder { + private Integer failed; + private Integer successful; + private Integer total; + + public final Builder failed(Integer value) { + this.failed = value; + return this; + } + + public final Builder successful(Integer value) { + this.successful = value; + return this; + } + + public final Builder total(Integer value) { + this.total = value; + return this; + } + + /** + * Builds a {@link RemoteStoreRestoreShardsInfo}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public RemoteStoreRestoreShardsInfo build() { + _checkSingleUse(); + + return new RemoteStoreRestoreShardsInfo(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = + ObjectBuilderDeserializer.lazy( + Builder::new, + RemoteStoreRestoreShardsInfo::setupRemoteStoreRestoreShardsInfoDeserializer); + + protected static void setupRemoteStoreRestoreShardsInfoDeserializer( + ObjectDeserializer op) { + op.add(Builder::failed, JsonpDeserializer.integerDeserializer(), "failed"); + op.add(Builder::successful, JsonpDeserializer.integerDeserializer(), "successful"); + op.add(Builder::total, JsonpDeserializer.integerDeserializer(), "total"); + } +} diff --git a/java-codegen/OpenSearch.yaml b/java-codegen/OpenSearch.yaml index 5dd44b506e..5b5ad50eb5 100644 --- a/java-codegen/OpenSearch.yaml +++ b/java-codegen/OpenSearch.yaml @@ -54,7 +54,7 @@ components: $ref: "#/components/schemas/RemoteStoreRestoreInfo" RemoteStoreRestoreInfo: x-namespace: remote_store - type: string + type: object properties: snapshot: type: string diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java index 9d5c6854d1..282a00eddd 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java @@ -8,7 +8,9 @@ package org.opensearch.client.codegen.model; +import java.util.ArrayList; import java.util.Collection; +import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -41,8 +43,32 @@ public String httpMethod() { return httpMethod; } - public String httpPath() { - return '"' + httpPath.replace("{", "\" + request.").replace("}", " + \"") + '"'; + public Collection httpPathParts() { + List parts = new ArrayList<>(); + boolean isParameter = false; + StringBuilder content = new StringBuilder(); + for (char c : httpPath.toCharArray()) { + if (c == '{') { + if (content.length() > 0) { + parts.add(new HttpPathPart(isParameter, content.toString())); + } + content = new StringBuilder(); + isParameter = true; + } else if (c == '}') { + if (content.length() > 0) { + parts.add(new HttpPathPart(isParameter, content.toString())); + } + content = new StringBuilder(); + isParameter = false; + } else { + content.append(c); + } + } + if (content.length() > 0) { + parts.add(new HttpPathPart(isParameter, content.toString())); + } + + return parts; } public String responseType() { @@ -81,4 +107,18 @@ public void addPathParam(Field field) { pathParams.put(field.name(), field); fields.put(field.name(), field); } + + public class HttpPathPart { + public final boolean isParameter; + public final String content; + + public HttpPathPart(boolean isParameter, String content) { + this.isParameter = isParameter; + this.content = content; + } + + public Field parameter() { + return isParameter ? pathParams.get(content) : null; + } + } } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Client.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Client.mustache index d09387ee13..f8a1b8ebf9 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Client.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Client.mustache @@ -1,3 +1,5 @@ +{{>Partials/LicenseHeader}} + package {{packageName}}; import org.opensearch.client.ApiClient; diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache index 6ea9876d61..1a9e737210 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache @@ -1,3 +1,5 @@ +{{>Partials/LicenseHeader}} + package {{packageName}}; import org.opensearch.client.json.JsonEnum; diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache index 9a6c990157..29cd5b9f0e 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache @@ -1,11 +1,21 @@ +{{>Partials/LicenseHeader}} + package {{packageName}}; -import org.opensearch.client.json.*; -import org.opensearch.client.util.*; +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.JsonpSerializable; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ObjectBuilderBase; import jakarta.json.stream.JsonGenerator; -import java.util.*; +import java.util.List; +import java.util.Map; import java.util.function.Function; -import javax.annotation.*; +import javax.annotation.Nullable; @JsonpDeserializable public class {{className}} implements JsonpSerializable { diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Partials/LicenseHeader.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Partials/LicenseHeader.mustache new file mode 100644 index 0000000000..b5b39ea4ed --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Partials/LicenseHeader.mustache @@ -0,0 +1,7 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache index b9e030c516..32d7cf7dd5 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache @@ -1,19 +1,31 @@ +{{>Partials/LicenseHeader}} + package {{packageName}}; -import org.opensearch.client.opensearch._types.*; {{#hasRequestBody}} -import org.opensearch.client.json.*; +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.JsonpSerializable; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; {{/hasRequestBody}} -import org.opensearch.client.transport.*; -import org.opensearch.client.transport.endpoints.*; -import org.opensearch.client.util.*; +import org.opensearch.client.opensearch._types.ErrorResponse; +import org.opensearch.client.opensearch._types.RequestBase; +import org.opensearch.client.transport.Endpoint; +import org.opensearch.client.transport.endpoints.SimpleEndpoint; +import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ObjectBuilderBase; {{#hasRequestBody}} import jakarta.json.stream.JsonGenerator; {{/hasRequestBody}} -import java.util.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.function.Function; -import java.util.stream.*; -import javax.annotation.*; +import java.util.stream.Collectors; +import javax.annotation.Nullable; /** * {{description}} @@ -43,7 +55,16 @@ public class {{className}} extends RequestBase{{#hasRequestBody}} implements Jso }, // Request path request -> { - return {{{httpPath}}}; + StringBuilder buf = new StringBuilder(); + {{#httpPathParts}} + {{#isParameter}} + SimpleEndpoint.pathEncode({{#parameter.type.queryParamify}}request.{{parameter.name}}{{/parameter.type.queryParamify}}, buf); + {{/isParameter}} + {{^isParameter}} + buf.append({{#dq}}{{content}}{{/dq}}); + {{/isParameter}} + {{/httpPathParts}} + return buf.toString(); }, // Request parameters request -> { From 13489b0faad1f7aeeaf594b96a29568a9d19a92b Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Fri, 17 Feb 2023 16:45:06 +1300 Subject: [PATCH 12/50] Suppress checkstyle unused imports lint for generated code Signed-off-by: Thomas Farr --- config/checkstyle/checkstyle_suppressions.xml | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 config/checkstyle/checkstyle_suppressions.xml diff --git a/config/checkstyle/checkstyle_suppressions.xml b/config/checkstyle/checkstyle_suppressions.xml new file mode 100644 index 0000000000..94661a18bb --- /dev/null +++ b/config/checkstyle/checkstyle_suppressions.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + From d02b9571d9ea69e8241960ee3b26b19e7584d07b Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Mon, 20 Feb 2023 10:24:38 +1300 Subject: [PATCH 13/50] Centralize some naming Signed-off-by: Thomas Farr --- .../client/codegen/ApiSpecification.java | 2 +- .../client/codegen/model/ClientOperation.java | 4 ++-- .../client/codegen/model/RequestShape.java | 14 ++++++++++++-- .../opensearch/client/codegen/utils/Strings.java | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java b/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java index 6d8d972d0d..0f95e967c8 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java @@ -120,7 +120,7 @@ private void visit(String httpPath, Path path, String httpMethod, Operation oper MediaType responseMediaType = operation.getResponse("200").getContentMediaType("application/json"); Schema responseSchema = responseMediaType != null ? resolve(responseMediaType.getSchema()) : new Schema(); - visitObjectShape(operation.getOperationId() + "Response", responseSchema); + visitObjectShape(requestShape.responseType(), responseSchema); } private void visitReferencedSchema(String ref, Schema schema) { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ClientOperation.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ClientOperation.java index b7f266dc8e..e6695e0369 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ClientOperation.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ClientOperation.java @@ -22,10 +22,10 @@ public String name() { } public String requestType() { - return Strings.toPascalCase(id) + "Request"; + return RequestShape.requestClassName(id); } public String responseType() { - return Strings.toPascalCase(id) + "Response"; + return RequestShape.responseClassName(id); } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java index 282a00eddd..f23c4754d2 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java @@ -8,6 +8,8 @@ package org.opensearch.client.codegen.model; +import org.opensearch.client.codegen.utils.Strings; + import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -15,6 +17,14 @@ import java.util.TreeMap; public class RequestShape extends ObjectShape { + public static String requestClassName(String id) { + return Strings.toPascalCase(id) + "Request"; + } + + public static String responseClassName(String id) { + return Strings.toPascalCase(id) + "Response"; + } + private final String id; private final String description; private final String httpMethod; @@ -24,7 +34,7 @@ public class RequestShape extends ObjectShape { private final Map fields = new TreeMap<>(); public RequestShape(String namespace, String id, String description, String httpMethod, String httpPath) { - super(namespace, id + "Request"); + super(namespace, requestClassName(id)); this.id = id; this.description = description; this.httpMethod = httpMethod; @@ -72,7 +82,7 @@ public Collection httpPathParts() { } public String responseType() { - return id + "Response"; + return responseClassName(id); } public boolean hasRequestBody() { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Strings.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Strings.java index ebc9470ea2..7c8aeff517 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Strings.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Strings.java @@ -24,7 +24,7 @@ public static String toPascalCase(String str) { } private static String toCamelCase(String str, boolean capitalizeFirstLetter) { - return CaseUtils.toCamelCase(toSnakeCase(str), capitalizeFirstLetter, '_'); + return CaseUtils.toCamelCase(toSnakeCase(str), capitalizeFirstLetter, '_', '.'); } public static String toSnakeCase(String str) { From c5a93f5bd204af83cb5ed83c28a6146c6c8aaf29 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Thu, 23 Feb 2023 13:10:20 +1300 Subject: [PATCH 14/50] Allow renaming operations Signed-off-by: Thomas Farr --- .../OpenSearchRemoteStoreAsyncClient.java | 24 ++--- .../OpenSearchRemoteStoreClient.java | 23 ++--- ...estoreRequest.java => RestoreRequest.java} | 87 +++++++++---------- ...toreResponse.java => RestoreResponse.java} | 27 +++--- java-codegen/OpenSearch.yaml | 1 + .../client/codegen/ApiSpecification.java | 10 +-- .../client/codegen/utils/Schemas.java | 8 ++ 7 files changed, 81 insertions(+), 99 deletions(-) rename java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/{PostRemoteStoreRestoreRequest.java => RestoreRequest.java} (56%) rename java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/{PostRemoteStoreRestoreResponse.java => RestoreResponse.java} (75%) diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreAsyncClient.java b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreAsyncClient.java index 8532eb0ea3..2d5d5c0811 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreAsyncClient.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreAsyncClient.java @@ -37,26 +37,18 @@ public OpenSearchRemoteStoreAsyncClient withTransportOptions( return new OpenSearchRemoteStoreAsyncClient(this.transport, transportOptions); } - public CompletableFuture postRemoteStoreRestore( - PostRemoteStoreRestoreRequest request) throws IOException, OpenSearchException { - JsonEndpoint - endpoint = - (JsonEndpoint< - PostRemoteStoreRestoreRequest, - PostRemoteStoreRestoreResponse, - ErrorResponse>) - PostRemoteStoreRestoreRequest._ENDPOINT; + public CompletableFuture restore(RestoreRequest request) + throws IOException, OpenSearchException { + JsonEndpoint endpoint = + (JsonEndpoint) + RestoreRequest._ENDPOINT; return this.transport.performRequestAsync(request, endpoint, this.transportOptions); } - public final CompletableFuture postRemoteStoreRestore( - Function< - PostRemoteStoreRestoreRequest.Builder, - ObjectBuilder> - fn) + public final CompletableFuture restore( + Function> fn) throws IOException, OpenSearchException { - return postRemoteStoreRestore( - fn.apply(new PostRemoteStoreRestoreRequest.Builder()).build()); + return restore(fn.apply(new RestoreRequest.Builder()).build()); } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreClient.java b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreClient.java index 8ff4a99e9c..9e0e6a236f 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreClient.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreClient.java @@ -36,26 +36,17 @@ public OpenSearchRemoteStoreClient withTransportOptions( return new OpenSearchRemoteStoreClient(this.transport, transportOptions); } - public PostRemoteStoreRestoreResponse postRemoteStoreRestore( - PostRemoteStoreRestoreRequest request) throws IOException, OpenSearchException { - JsonEndpoint - endpoint = - (JsonEndpoint< - PostRemoteStoreRestoreRequest, - PostRemoteStoreRestoreResponse, - ErrorResponse>) - PostRemoteStoreRestoreRequest._ENDPOINT; + public RestoreResponse restore(RestoreRequest request) throws IOException, OpenSearchException { + JsonEndpoint endpoint = + (JsonEndpoint) + RestoreRequest._ENDPOINT; return this.transport.performRequest(request, endpoint, this.transportOptions); } - public final PostRemoteStoreRestoreResponse postRemoteStoreRestore( - Function< - PostRemoteStoreRestoreRequest.Builder, - ObjectBuilder> - fn) + public final RestoreResponse restore( + Function> fn) throws IOException, OpenSearchException { - return postRemoteStoreRestore( - fn.apply(new PostRemoteStoreRestoreRequest.Builder()).build()); + return restore(fn.apply(new RestoreRequest.Builder()).build()); } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/PostRemoteStoreRestoreRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RestoreRequest.java similarity index 56% rename from java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/PostRemoteStoreRestoreRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RestoreRequest.java index 033025529b..477205cba0 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/PostRemoteStoreRestoreRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RestoreRequest.java @@ -31,7 +31,7 @@ /** Restore one or more indices from a remote backup. */ @JsonpDeserializable -public class PostRemoteStoreRestoreRequest extends RequestBase implements JsonpSerializable { +public class RestoreRequest extends RequestBase implements JsonpSerializable { @Nullable private final String clusterManagerTimeout; @@ -39,14 +39,13 @@ public class PostRemoteStoreRestoreRequest extends RequestBase implements JsonpS @Nullable private final Boolean waitForCompletion; - public PostRemoteStoreRestoreRequest(Builder builder) { + public RestoreRequest(Builder builder) { this.clusterManagerTimeout = builder.clusterManagerTimeout; this.indices = ApiTypeHelper.unmodifiableRequired(builder.indices, this, "indices"); this.waitForCompletion = builder.waitForCompletion; } - public static PostRemoteStoreRestoreRequest of( - Function> fn) { + public static RestoreRequest of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -77,9 +76,8 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeEnd(); } - /** Builder for {@link PostRemoteStoreRestoreRequest}. */ - public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { + /** Builder for {@link RestoreRequest}. */ + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private String clusterManagerTimeout; private List indices; private Boolean waitForCompletion; @@ -105,60 +103,55 @@ public final Builder waitForCompletion(Boolean value) { } /** - * Builds a {@link PostRemoteStoreRestoreRequest}. + * Builds a {@link RestoreRequest}. * * @throws NullPointerException if some of the required fields are null. */ - public PostRemoteStoreRestoreRequest build() { + public RestoreRequest build() { _checkSingleUse(); - return new PostRemoteStoreRestoreRequest(this); + return new RestoreRequest(this); } } - public static final JsonpDeserializer _DESERIALIZER = + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( - Builder::new, - PostRemoteStoreRestoreRequest::setupPostRemoteStoreRestoreRequestDeserializer); + Builder::new, RestoreRequest::setupRestoreRequestDeserializer); - protected static void setupPostRemoteStoreRestoreRequestDeserializer( - ObjectDeserializer op) { + protected static void setupRestoreRequestDeserializer( + ObjectDeserializer op) { op.add( Builder::indices, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "indices"); } - public static final Endpoint< - PostRemoteStoreRestoreRequest, PostRemoteStoreRestoreResponse, ErrorResponse> - _ENDPOINT = - new SimpleEndpoint<>( - // Request method - request -> { - return "post"; - }, - // Request path - request -> { - StringBuilder buf = new StringBuilder(); - buf.append("/_remotestore/_restore"); - return buf.toString(); - }, - // Request parameters - request -> { - Map params = new HashMap<>(); - if (request.clusterManagerTimeout != null) { - params.put( - "cluster_manager_timeout", - request.clusterManagerTimeout); - } - if (request.waitForCompletion != null) { - params.put( - "wait_for_completion", - String.valueOf(request.waitForCompletion)); - } - return params; - }, - SimpleEndpoint.emptyMap(), - true, - PostRemoteStoreRestoreResponse._DESERIALIZER); + public static final Endpoint _ENDPOINT = + new SimpleEndpoint<>( + // Request method + request -> { + return "post"; + }, + // Request path + request -> { + StringBuilder buf = new StringBuilder(); + buf.append("/_remotestore/_restore"); + return buf.toString(); + }, + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.clusterManagerTimeout != null) { + params.put("cluster_manager_timeout", request.clusterManagerTimeout); + } + if (request.waitForCompletion != null) { + params.put( + "wait_for_completion", + String.valueOf(request.waitForCompletion)); + } + return params; + }, + SimpleEndpoint.emptyMap(), + true, + RestoreResponse._DESERIALIZER); } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/PostRemoteStoreRestoreResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RestoreResponse.java similarity index 75% rename from java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/PostRemoteStoreRestoreResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RestoreResponse.java index 18fa8dd09f..69318a615c 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/PostRemoteStoreRestoreResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RestoreResponse.java @@ -24,19 +24,18 @@ import javax.annotation.Nullable; @JsonpDeserializable -public class PostRemoteStoreRestoreResponse implements JsonpSerializable { +public class RestoreResponse implements JsonpSerializable { @Nullable private final Boolean accepted; @Nullable private final RemoteStoreRestoreInfo remoteStore; - public PostRemoteStoreRestoreResponse(Builder builder) { + public RestoreResponse(Builder builder) { this.accepted = builder.accepted; this.remoteStore = builder.remoteStore; } - public static PostRemoteStoreRestoreResponse of( - Function> fn) { + public static RestoreResponse of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -66,9 +65,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } } - /** Builder for {@link PostRemoteStoreRestoreResponse}. */ + /** Builder for {@link RestoreResponse}. */ public static class Builder extends ObjectBuilderBase - implements ObjectBuilder { + implements ObjectBuilder { private Boolean accepted; private RemoteStoreRestoreInfo remoteStore; @@ -89,25 +88,23 @@ public final Builder remoteStore( } /** - * Builds a {@link PostRemoteStoreRestoreResponse}. + * Builds a {@link RestoreResponse}. * * @throws NullPointerException if some of the required fields are null. */ - public PostRemoteStoreRestoreResponse build() { + public RestoreResponse build() { _checkSingleUse(); - return new PostRemoteStoreRestoreResponse(this); + return new RestoreResponse(this); } } - public static final JsonpDeserializer _DESERIALIZER = + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( - Builder::new, - PostRemoteStoreRestoreResponse - ::setupPostRemoteStoreRestoreResponseDeserializer); + Builder::new, RestoreResponse::setupRestoreResponseDeserializer); - protected static void setupPostRemoteStoreRestoreResponseDeserializer( - ObjectDeserializer op) { + protected static void setupRestoreResponseDeserializer( + ObjectDeserializer op) { op.add(Builder::accepted, JsonpDeserializer.booleanDeserializer(), "accepted"); op.add(Builder::remoteStore, RemoteStoreRestoreInfo._DESERIALIZER, "remote_store"); } diff --git a/java-codegen/OpenSearch.yaml b/java-codegen/OpenSearch.yaml index 5b5ad50eb5..be75cb6e57 100644 --- a/java-codegen/OpenSearch.yaml +++ b/java-codegen/OpenSearch.yaml @@ -8,6 +8,7 @@ paths: description: Restore one or more indices from a remote backup. operationId: PostRemoteStoreRestore x-namespace: remote_store + x-operation-name: restore requestBody: content: application/json: diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java b/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java index 0f95e967c8..498c10528c 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java @@ -93,7 +93,7 @@ private void visit(String httpPath, Path path) throws ApiSpecificationParseExcep private void visit(String httpPath, Path path, String httpMethod, Operation operation) throws ApiSpecificationParseException { RequestShape requestShape = new RequestShape( Schemas.getNamespaceExtension(operation), - operation.getOperationId(), + Schemas.getOperationNameExtension(operation), operation.getDescription(), httpMethod, httpPath @@ -120,7 +120,7 @@ private void visit(String httpPath, Path path, String httpMethod, Operation oper MediaType responseMediaType = operation.getResponse("200").getContentMediaType("application/json"); Schema responseSchema = responseMediaType != null ? resolve(responseMediaType.getSchema()) : new Schema(); - visitObjectShape(requestShape.responseType(), responseSchema); + visitObjectShape(requestShape.namespace(), requestShape.responseType(), responseSchema); } private void visitReferencedSchema(String ref, Schema schema) { @@ -130,7 +130,7 @@ private void visitReferencedSchema(String ref, Schema schema) { String name = refParts[refParts.length - 1]; if (Schemas.isObject(schema)) { - visitObjectShape(name, schema); + visitObjectShape(Schemas.getNamespaceExtension(schema), name, schema); } else if (Schemas.isString(schema) && schema.hasEnums()) { enumShapes.add(new EnumShape( Schemas.getNamespaceExtension(schema), @@ -140,8 +140,8 @@ private void visitReferencedSchema(String ref, Schema schema) { } } - private void visitObjectShape(String name, Schema schema) { - ObjectShape shape = new ObjectShape(Schemas.getNamespaceExtension(schema), name); + private void visitObjectShape(String namespace, String name, Schema schema) { + ObjectShape shape = new ObjectShape(namespace, name); visitFields(schema, shape::addBodyField); objectShapes.add(shape); } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Schemas.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Schemas.java index e3a6b23ddf..77363d0dbc 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Schemas.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Schemas.java @@ -31,6 +31,14 @@ public static String getNamespaceExtension(AbsExtendedRefOpenApiSchema schema return (String) getExtension(schema, "x-namespace"); } + public static String getOperationNameExtension(AbsExtendedOpenApiSchema schema) { + return (String) getExtension(schema, "x-operation-name"); + } + + public static String getOperationNameExtension(AbsExtendedRefOpenApiSchema schema) { + return (String) getExtension(schema, "x-operation-name"); + } + public static Object getExtension(AbsExtendedOpenApiSchema schema, String key) { return schema.getExtensions().get(key); } From ec58087fb6a21b02108bd36d62f10a9b69315ba5 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Wed, 1 Mar 2023 10:47:06 +1300 Subject: [PATCH 15/50] Add generated warning header Signed-off-by: Thomas Farr --- .../remotestore/OpenSearchRemoteStoreAsyncClient.java | 4 ++++ .../opensearch/remotestore/OpenSearchRemoteStoreClient.java | 4 ++++ .../client/opensearch/remotestore/RemoteStoreRestoreInfo.java | 4 ++++ .../opensearch/remotestore/RemoteStoreRestoreShardsInfo.java | 4 ++++ .../client/opensearch/remotestore/RestoreRequest.java | 4 ++++ .../client/opensearch/remotestore/RestoreResponse.java | 4 ++++ .../client/codegen/templates/Partials/LicenseHeader.mustache | 4 ++++ 7 files changed, 28 insertions(+) diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreAsyncClient.java b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreAsyncClient.java index 2d5d5c0811..d54b298f64 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreAsyncClient.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreAsyncClient.java @@ -6,6 +6,10 @@ * compatible open source license. */ +// ---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +// ---------------------------------------------------- + package org.opensearch.client.opensearch.remotestore; import org.opensearch.client.ApiClient; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreClient.java b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreClient.java index 9e0e6a236f..2f1a88d58f 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreClient.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreClient.java @@ -6,6 +6,10 @@ * compatible open source license. */ +// ---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +// ---------------------------------------------------- + package org.opensearch.client.opensearch.remotestore; import org.opensearch.client.ApiClient; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RemoteStoreRestoreInfo.java b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RemoteStoreRestoreInfo.java index 00a025b321..1b375ed994 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RemoteStoreRestoreInfo.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RemoteStoreRestoreInfo.java @@ -6,6 +6,10 @@ * compatible open source license. */ +// ---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +// ---------------------------------------------------- + package org.opensearch.client.opensearch.remotestore; import org.opensearch.client.json.JsonpDeserializable; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RemoteStoreRestoreShardsInfo.java b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RemoteStoreRestoreShardsInfo.java index 437761a52b..b9431aa565 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RemoteStoreRestoreShardsInfo.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RemoteStoreRestoreShardsInfo.java @@ -6,6 +6,10 @@ * compatible open source license. */ +// ---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +// ---------------------------------------------------- + package org.opensearch.client.opensearch.remotestore; import org.opensearch.client.json.JsonpDeserializable; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RestoreRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RestoreRequest.java index 477205cba0..669dca13e1 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RestoreRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RestoreRequest.java @@ -6,6 +6,10 @@ * compatible open source license. */ +// ---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +// ---------------------------------------------------- + package org.opensearch.client.opensearch.remotestore; import org.opensearch.client.json.JsonpDeserializable; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RestoreResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RestoreResponse.java index 69318a615c..8d969b5f72 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RestoreResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RestoreResponse.java @@ -6,6 +6,10 @@ * compatible open source license. */ +// ---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +// ---------------------------------------------------- + package org.opensearch.client.opensearch.remotestore; import org.opensearch.client.json.JsonpDeserializable; diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Partials/LicenseHeader.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Partials/LicenseHeader.mustache index b5b39ea4ed..9a577a5570 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Partials/LicenseHeader.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Partials/LicenseHeader.mustache @@ -5,3 +5,7 @@ * this file be licensed under the Apache-2.0 license or a * compatible open source license. */ + +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- From 055a0fcacf0b8c44cc3d887d410622e1d2031652 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Fri, 3 Mar 2023 15:10:01 +1300 Subject: [PATCH 16/50] Refactor Signed-off-by: Thomas Farr --- .../client/codegen/ApiSpecification.java | 182 ------------------ .../opensearch/client/codegen/Generator.java | 77 -------- .../org/opensearch/client/codegen/Main.java | 42 +++- .../opensearch/client/codegen/Renderer.java | 21 +- .../opensearch/client/codegen/TypeMapper.java | 13 +- .../client/codegen/model/Client.java | 48 ----- .../client/codegen/model/ClientOperation.java | 31 --- .../client/codegen/model/Context.java | 20 ++ .../client/codegen/model/EnumShape.java | 37 +++- .../client/codegen/model/Field.java | 48 ++++- .../client/codegen/model/HttpPathPart.java | 67 +++++++ .../client/codegen/model/Namespace.java | 158 +++++++++++++++ .../client/codegen/model/ObjectShape.java | 14 +- .../client/codegen/model/RequestShape.java | 110 +++++------ .../client/codegen/model/Shape.java | 20 +- .../client/codegen/utils/MediaType.java | 7 + .../client/codegen/utils/Schemas.java | 87 ++++++++- .../client/codegen/utils/TriConsumer.java | 6 + .../client/codegen/templates/Client.mustache | 17 +- .../codegen/templates/EnumShape.mustache | 2 +- .../ObjectShape/Constructor.mustache | 4 +- .../ObjectShape/Deserialize.mustache | 2 +- .../templates/ObjectShape/Serialize.mustache | 2 +- .../codegen/templates/RequestShape.mustache | 6 +- 24 files changed, 560 insertions(+), 461 deletions(-) delete mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java delete mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java delete mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/model/Client.java delete mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/model/ClientOperation.java create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/model/Context.java create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/model/HttpPathPart.java create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/utils/MediaType.java create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/utils/TriConsumer.java diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java b/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java deleted file mode 100644 index 498c10528c..0000000000 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/ApiSpecification.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -package org.opensearch.client.codegen; - -import org.openapi4j.core.exception.DecodeException; -import org.openapi4j.core.exception.ResolutionException; -import org.openapi4j.core.model.OAIContext; -import org.openapi4j.core.model.reference.Reference; -import org.openapi4j.core.validation.ValidationException; -import org.openapi4j.parser.OpenApi3Parser; -import org.openapi4j.parser.model.AbsRefOpenApiSchema; -import org.openapi4j.parser.model.v3.MediaType; -import org.openapi4j.parser.model.v3.OpenApi3; -import org.openapi4j.parser.model.v3.Operation; -import org.openapi4j.parser.model.v3.Path; -import org.openapi4j.parser.model.v3.RequestBody; -import org.openapi4j.parser.model.v3.Schema; -import org.opensearch.client.codegen.exceptions.ApiSpecificationParseException; -import org.opensearch.client.codegen.model.EnumShape; -import org.opensearch.client.codegen.model.Field; -import org.opensearch.client.codegen.model.ObjectShape; -import org.opensearch.client.codegen.model.RequestShape; -import org.opensearch.client.codegen.utils.Schemas; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Consumer; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class ApiSpecification { - private final OAIContext context; - private final Set visitedReferencedSchemas; - private final List requestShapes; - private final List objectShapes; - private final List enumShapes; - private final TypeMapper typeMapper; - - private ApiSpecification(OpenApi3 api) throws ApiSpecificationParseException { - context = api.getContext(); - visitedReferencedSchemas = new HashSet<>(); - requestShapes = new ArrayList<>(); - objectShapes = new ArrayList<>(); - enumShapes = new ArrayList<>(); - typeMapper = new TypeMapper(context, this::visitReferencedSchema); - visit(api); - } - - public static ApiSpecification parse(File schemaFile) throws ApiSpecificationParseException { - try { - OpenApi3 api = new OpenApi3Parser().parse(schemaFile, true); - return new ApiSpecification(api); - } catch (ResolutionException | ValidationException e) { - throw new ApiSpecificationParseException("Failed to parse schema: " + schemaFile, e); - } - } - - public List getRequestShapes() { - return Collections.unmodifiableList(requestShapes); - } - - public List getObjectShapes() { - return Collections.unmodifiableList(objectShapes); - } - - public List getEnumShapes() { - return Collections.unmodifiableList(enumShapes); - } - - private void visit(OpenApi3 api) throws ApiSpecificationParseException { - for (Map.Entry entry : api.getPaths().entrySet()) { - visit(entry.getKey(), entry.getValue()); - } - } - - private void visit(String httpPath, Path path) throws ApiSpecificationParseException { - for (Map.Entry entry : path.getOperations().entrySet()) { - visit(httpPath, path, entry.getKey(), entry.getValue()); - } - } - - private void visit(String httpPath, Path path, String httpMethod, Operation operation) throws ApiSpecificationParseException { - RequestShape requestShape = new RequestShape( - Schemas.getNamespaceExtension(operation), - Schemas.getOperationNameExtension(operation), - operation.getDescription(), - httpMethod, - httpPath - ); - - RequestBody requestBody = resolve(operation.getRequestBody()); - - if (requestBody != null) { - Schema requestBodySchema = resolve(requestBody.getContentMediaType("application/json").getSchema()); - visitFields(requestBodySchema, requestShape::addBodyField); - } - - Stream.of(path.getParametersIn(context, "query"), operation.getParametersIn(context, "query")) - .flatMap(List::stream) - .map(p -> new Field(p.getName(), typeMapper.mapType(p.getSchema()), p.isRequired())) - .forEach(requestShape::addQueryParam); - - Stream.of(path.getParametersIn(context, "path"), operation.getParametersIn(context, "path")) - .flatMap(List::stream) - .map(p -> new Field(p.getName(), typeMapper.mapType(p.getSchema()), p.isRequired())) - .forEach(requestShape::addPathParam); - - requestShapes.add(requestShape); - - MediaType responseMediaType = operation.getResponse("200").getContentMediaType("application/json"); - Schema responseSchema = responseMediaType != null ? resolve(responseMediaType.getSchema()) : new Schema(); - visitObjectShape(requestShape.namespace(), requestShape.responseType(), responseSchema); - } - - private void visitReferencedSchema(String ref, Schema schema) { - if (!visitedReferencedSchemas.add(ref)) return; - - String[] refParts = ref.split("/"); - String name = refParts[refParts.length - 1]; - - if (Schemas.isObject(schema)) { - visitObjectShape(Schemas.getNamespaceExtension(schema), name, schema); - } else if (Schemas.isString(schema) && schema.hasEnums()) { - enumShapes.add(new EnumShape( - Schemas.getNamespaceExtension(schema), - name, - schema.getEnums().stream().map(Object::toString).collect(Collectors.toList()) - )); - } - } - - private void visitObjectShape(String namespace, String name, Schema schema) { - ObjectShape shape = new ObjectShape(namespace, name); - visitFields(schema, shape::addBodyField); - objectShapes.add(shape); - } - - private void visitFields(Schema schema, Consumer fieldVisitor) { - Map properties = schema.getProperties(); - - if (properties == null) return; - - Set requiredFields = new HashSet<>(schema.hasRequiredFields() ? schema.getRequiredFields() : new ArrayList<>(0)); - - properties.forEach((name, propertySchema) -> fieldVisitor.accept(new Field( - name, - typeMapper.mapType(propertySchema), - requiredFields.contains(name) - ))); - } - - private RequestBody resolve(RequestBody body) throws ApiSpecificationParseException { - return resolve(body, RequestBody.class); - } - - private Schema resolve(Schema schema) throws ApiSpecificationParseException { - return resolve(schema, Schema.class); - } - - private > S resolve(S schema, Class clazz) throws ApiSpecificationParseException { - while (schema != null && schema.isRef()) { - Reference ref = schema.getReference(context); - try { - schema = ref.getMappedContent(clazz); - } catch (DecodeException e) { - throw new ApiSpecificationParseException("Failed to decode reference as " + clazz + ": " + ref, e); - } - } - return schema; - } -} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java b/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java deleted file mode 100644 index 50c1b5705a..0000000000 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/Generator.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -package org.opensearch.client.codegen; - -import org.opensearch.client.codegen.exceptions.ApiSpecificationParseException; -import org.opensearch.client.codegen.exceptions.RenderException; -import org.opensearch.client.codegen.model.Client; -import org.opensearch.client.codegen.model.EnumShape; -import org.opensearch.client.codegen.model.ObjectShape; -import org.opensearch.client.codegen.model.RequestShape; -import org.opensearch.client.codegen.model.Shape; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Stream; - -public class Generator { - private final ApiSpecification apiSpecification; - private final Renderer renderer; - private final File outputDir; - - public Generator(File schemaFile, File outputDir) throws ApiSpecificationParseException { - apiSpecification = ApiSpecification.parse(schemaFile); - renderer = new Renderer(); - this.outputDir = outputDir; - } - - public void generate() throws RenderException { - try (Stream walker = Files.walk(outputDir.toPath())) { - walker.sorted(Comparator.reverseOrder()) - .map(Path::toFile) - .forEach(File::delete); - } catch (IOException e) { - throw new RenderException("Unable to cleanup output directory: " + outputDir, e); - } - - Map namespaceClients = new HashMap<>(); - - for (RequestShape requestShape : apiSpecification.getRequestShapes()) { - renderShape(requestShape); - - namespaceClients.computeIfAbsent(requestShape.namespace(), Client::new) - .addOperation(requestShape.id()); - } - - for (ObjectShape objectShape : apiSpecification.getObjectShapes()) { - renderShape(objectShape); - } - - for (EnumShape enumShape : apiSpecification.getEnumShapes()) { - renderShape(enumShape); - } - - for (Client client : namespaceClients.values()) { - renderShape(client); - renderShape(client.async(true)); - } - } - - private void renderShape(S shape) throws RenderException { - File packageDir = new File(outputDir, shape.packageName().replace('.', '/')); - packageDir.mkdirs(); - File outputFile = new File(packageDir, shape.className() + ".java"); - renderer.render(shape, outputFile); - } -} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/Main.java b/java-codegen/src/main/java/org/opensearch/client/codegen/Main.java index ba8d247d8e..e38eaf0802 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/Main.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/Main.java @@ -9,6 +9,18 @@ package org.opensearch.client.codegen; import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Comparator; +import java.util.stream.Stream; +import org.openapi4j.core.exception.ResolutionException; +import org.openapi4j.core.validation.ValidationException; +import org.openapi4j.parser.OpenApi3Parser; +import org.openapi4j.parser.model.v3.OpenApi3; +import org.opensearch.client.codegen.exceptions.ApiSpecificationParseException; +import org.opensearch.client.codegen.exceptions.RenderException; +import org.opensearch.client.codegen.model.Namespace; public class Main { public static void main(String[] args) { @@ -23,10 +35,36 @@ public static void main(String[] args) { File outputDir = new File(args[1]); System.out.println("Spec File: " + specFile); System.out.println("Output Dir: " + outputDir); - Generator generator = new Generator(specFile, outputDir); - generator.generate(); + + Namespace root = parseSpec(specFile); + + cleanDirectory(outputDir); + + outputDir = new File(outputDir, root.packageName().replace('.', '/')); + + root.render(new Renderer(), outputDir); } catch (Throwable e) { e.printStackTrace(System.err); + System.exit(1); + } + } + + private static Namespace parseSpec(File spec) throws ApiSpecificationParseException { + try { + OpenApi3 api = new OpenApi3Parser().parse(spec, true); + return Namespace.from(api); + } catch (ResolutionException | ValidationException e) { + throw new ApiSpecificationParseException("Failed to parse schema: " + spec, e); + } + } + + private static void cleanDirectory(File dir) throws RenderException { + try (Stream walker = Files.walk(dir.toPath())) { + walker.sorted(Comparator.reverseOrder()) + .map(Path::toFile) + .forEach(File::delete); + } catch (IOException e) { + throw new RenderException("Unable to cleanup output directory: " + dir, e); } } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java b/java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java index 3ae74ad035..7988ccad24 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java @@ -14,6 +14,7 @@ import com.samskivert.mustache.Mustache; import com.samskivert.mustache.MustacheException; import com.samskivert.mustache.Template; +import java.util.function.Function; import org.apache.commons.text.StringEscapeUtils; import org.opensearch.client.codegen.exceptions.RenderException; @@ -27,10 +28,16 @@ import java.util.HashMap; import java.util.Map; import java.util.MissingResourceException; +import org.opensearch.client.codegen.utils.Strings; public class Renderer { + private static Mustache.Lambda transformer(Function transform) { + return ((frag, out) -> out.write(transform.apply(frag.execute()))); + } + private static final Map lambdas = new HashMap<>() {{ - put("dq", (frag, out) -> out.write('\"' + StringEscapeUtils.escapeJava(frag.execute()) + '\"')); + put("quoted", transformer(s -> '\"' + StringEscapeUtils.escapeJava(s) + '\"')); + put("camelCase", transformer(Strings::toCamelCase)); }}; private final Mustache.Compiler compiler; @@ -51,9 +58,9 @@ public Renderer() { .build()); } - public String render(T object) throws RenderException { + public String render(Object object, String templateName) throws RenderException { try { - Template template = compiler.loadTemplate(object.getClass().getSimpleName()); + Template template = compiler.loadTemplate(templateName); Writer writer = new StringWriter(); template.execute(object, lambdas, writer); @@ -72,8 +79,12 @@ public String render(T object) throws RenderException { } } - public void render(T object, File outputFile) throws RenderException { - String output = render(object); + public void render(Object object, File outputFile) throws RenderException { + render(object, object.getClass().getSimpleName(), outputFile); + } + + public void render(Object object, String templateName, File outputFile) throws RenderException { + String output = render(object, templateName); try (Writer writer = new FileWriter(outputFile)) { writer.write(output); } catch (IOException e) { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java b/java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java index 75d034a401..242faf7007 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/TypeMapper.java @@ -8,23 +8,22 @@ package org.opensearch.client.codegen; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.BiConsumer; import org.openapi4j.core.model.OAIContext; import org.openapi4j.core.model.v3.OAI3SchemaKeywords; import org.openapi4j.parser.model.v3.Schema; import org.opensearch.client.codegen.model.Type; import org.opensearch.client.codegen.utils.Schemas; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.function.BiConsumer; - public class TypeMapper { - private final OAIContext context; + private final OAIContext openApiCtx; private final Map cache = new ConcurrentHashMap<>(); private final BiConsumer referencedSchemaVisitor; public TypeMapper(OAIContext context, BiConsumer referencedSchemaVisitor) { - this.context = context; + this.openApiCtx = context; this.referencedSchemaVisitor = referencedSchemaVisitor; } @@ -43,7 +42,7 @@ public Type mapType(Schema schema, boolean boxed) { private Type mapTypeInner(Schema schema) { if (schema.isRef()) { - Schema target = schema.getFlatSchema(context); + Schema target = schema.getFlatSchema(openApiCtx); if (!shouldKeepRef(target)) { return mapType(target); diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Client.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Client.java deleted file mode 100644 index 637c283d5c..0000000000 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Client.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -package org.opensearch.client.codegen.model; - -import org.opensearch.client.codegen.utils.Strings; - -import java.util.Collection; -import java.util.Map; -import java.util.TreeMap; - -public class Client extends Shape { - private final boolean async; - private final Map operations = new TreeMap<>(); - - public Client(String namespace) { - this(namespace, false); - } - - private Client(String namespace, boolean async) { - super(namespace, "OpenSearch" + Strings.toPascalCase(namespace) + (async ? "Async" : "") + "Client"); - this.async = async; - } - - public void addOperation(String id) { - operations.put(id, new ClientOperation(id)); - } - - public Collection operations() { - return operations.values(); - } - - public boolean async() { - return async; - } - - public Client async(boolean async) { - if (async == this.async) return this; - Client client = new Client(namespace, async); - operations.keySet().forEach(client::addOperation); - return client; - } -} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ClientOperation.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ClientOperation.java deleted file mode 100644 index e6695e0369..0000000000 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ClientOperation.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -package org.opensearch.client.codegen.model; - -import org.opensearch.client.codegen.utils.Strings; - -public class ClientOperation { - private final String id; - - public ClientOperation(String id) { - this.id = id; - } - - public String name() { - return Strings.toCamelCase(id); - } - - public String requestType() { - return RequestShape.requestClassName(id); - } - - public String responseType() { - return RequestShape.responseClassName(id); - } -} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Context.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Context.java new file mode 100644 index 0000000000..343a5d66c6 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Context.java @@ -0,0 +1,20 @@ +package org.opensearch.client.codegen.model; + +import org.openapi4j.core.model.OAIContext; +import org.opensearch.client.codegen.TypeMapper; + +public class Context { + public final Namespace namespace; + public final OAIContext openApiCtx; + public final TypeMapper typeMapper; + + public Context(Namespace namespace, OAIContext openApiCtx, TypeMapper typeMapper) { + this.namespace = namespace; + this.openApiCtx = openApiCtx; + this.typeMapper = typeMapper; + } + + public Context withNamespace(Namespace namespace) { + return new Context(namespace, openApiCtx, typeMapper); + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java index 24443a53b6..a05c9c4a29 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java @@ -8,27 +8,48 @@ package org.opensearch.client.codegen.model; -import org.opensearch.client.codegen.utils.Strings; - import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.stream.Collectors; +import org.openapi4j.parser.model.v3.Schema; +import org.opensearch.client.codegen.utils.Strings; public class EnumShape extends Shape { - public final List variants; + public static EnumShape from(Context ctx, String name, Schema schema) { + return new EnumShape( + ctx.namespace, + name, + schema.getEnums() + .stream() + .map(Object::toString) + .map(Variant::new) + .collect(Collectors.toList()) + ); + } + + private final List variants; - public EnumShape(String namespace, String className, Collection variants) { - super(namespace, className); - this.variants = variants.stream().map(Variant::new).collect(Collectors.toList()); + private EnumShape(Namespace parent, String className, List variants) { + super(parent, className); + this.variants = variants; + } + + public Collection variants() { + return Collections.unmodifiableCollection(variants); } public static class Variant { - public final String wireName; + private final String wireName; - public Variant(String wireName) { + private Variant(String wireName) { this.wireName = wireName; } + public String wireName() { + return wireName; + } + public String name() { return Strings.toPascalCase(wireName); } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java index 244ab06dad..6aa847eafb 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java @@ -8,20 +8,60 @@ package org.opensearch.client.codegen.model; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; +import org.openapi4j.parser.model.v3.Operation; +import org.openapi4j.parser.model.v3.Parameter; +import org.openapi4j.parser.model.v3.Path; +import org.openapi4j.parser.model.v3.Schema; import org.opensearch.client.codegen.NameSanitizer; +import org.opensearch.client.codegen.utils.Schemas; public class Field { - public String wireName; - public Type type; - public boolean required; + public static Field from(Context ctx, Parameter parameter) { + return from(ctx, parameter.getName(), parameter.getSchema(), parameter.isRequired()); + } + + public static Field from(Context ctx, String name, Schema schema, boolean required) { + return new Field(name, ctx.typeMapper.mapType(schema), required); + } + + public static List allFrom(Context ctx, Schema schema) { + List fields = new ArrayList<>(); + Schemas.forEachProperty(schema, (name, prop, required) -> fields.add(from(ctx, name, prop, required))); + return fields; + } + + public static List allFrom(Context ctx, Path path, Operation operation, String in) { + return Schemas.getParametersIn(ctx.openApiCtx, path, operation, in) + .map(p -> from(ctx, p)) + .collect(Collectors.toList()); + } - public Field(String wireName, Type type, boolean required) { + private final String wireName; + private final Type type; + private final boolean required; + + private Field(String wireName, Type type, boolean required) { this.wireName = wireName; this.type = required ? type : type.boxed(); this.required = required; } + public String wireName() { + return wireName; + } + public String name() { return NameSanitizer.wireNameToField(wireName); } + + public Type type() { + return type; + } + + public boolean required() { + return required; + } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/HttpPathPart.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/HttpPathPart.java new file mode 100644 index 0000000000..5870a2f6d9 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/HttpPathPart.java @@ -0,0 +1,67 @@ +package org.opensearch.client.codegen.model; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +public class HttpPathPart { + public static Collection partsFrom(String httpPath, Map pathParams) { + List parts = new ArrayList<>(); + boolean isParameter = false; + StringBuilder content = new StringBuilder(); + for (char c : httpPath.toCharArray()) { + if (c == '{') { + if (content.length() > 0) { + parts.add(from(isParameter, content.toString(), pathParams)); + } + content = new StringBuilder(); + isParameter = true; + } else if (c == '}') { + if (content.length() > 0) { + parts.add(from(isParameter, content.toString(), pathParams)); + } + content = new StringBuilder(); + isParameter = false; + } else { + content.append(c); + } + } + if (content.length() > 0) { + parts.add(from(isParameter, content.toString(), pathParams)); + } + + return parts; + } + + private static HttpPathPart from(boolean isParameter, String content, Map pathParams) { + return isParameter + ? new HttpPathPart(pathParams.get(content)) + : new HttpPathPart(content); + } + + private final Field parameter; + private final String content; + + private HttpPathPart(Field parameter) { + this.parameter = parameter; + this.content = null; + } + + private HttpPathPart(String content) { + this.parameter = null; + this.content = content; + } + + public boolean isParameter() { + return parameter != null; + } + + public String content() { + return content; + } + + public Field parameter() { + return parameter; + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java new file mode 100644 index 0000000000..e7592d1016 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java @@ -0,0 +1,158 @@ +package org.opensearch.client.codegen.model; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Queue; +import java.util.Set; +import java.util.TreeMap; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.stream.Collectors; +import org.apache.commons.lang3.tuple.Pair; +import org.openapi4j.core.model.OAIContext; +import org.openapi4j.parser.model.v3.OpenApi3; +import org.openapi4j.parser.model.v3.Schema; +import org.opensearch.client.codegen.Renderer; +import org.opensearch.client.codegen.TypeMapper; +import org.opensearch.client.codegen.exceptions.RenderException; +import org.opensearch.client.codegen.utils.Schemas; +import org.opensearch.client.codegen.utils.Strings; + +public class Namespace extends Shape { + public static Namespace from(OpenApi3 api) { + OAIContext openApiCtx = api.getContext(); + Queue> referencedSchemas = new ConcurrentLinkedQueue<>(); + Context ctx = new Context( + new Namespace(), + openApiCtx, + new TypeMapper(openApiCtx, (ref, schema) -> referencedSchemas.add(Pair.of(ref, schema))) + ); + + api.getPaths().forEach((httpPath, path) -> path.getOperations().forEach((method, operation) -> { + Namespace parent = ctx.namespace.child(Schemas.getNamespaceExtension(operation)); + Context opCtx = ctx.withNamespace(parent); + + RequestShape requestShape = RequestShape.from(opCtx, httpPath, path, method, operation); + parent.operations.put(requestShape.id(), requestShape); + parent.shapes.add(requestShape); + + Schema responseSchema = Schemas.resolveResponseBodySchema(opCtx.openApiCtx, operation).orElseGet(Schema::new); + parent.shapes.add(ObjectShape.from(opCtx, requestShape.responseType(), responseSchema)); + })); + + Set seenRefs = new HashSet<>(); + Pair schemaRef; + while ((schemaRef = referencedSchemas.poll()) != null) { + String ref = schemaRef.getKey(); + Schema schema = schemaRef.getValue(); + + if (!seenRefs.add(ref)) continue; + + String[] refParts = ref.split("/"); + String name = refParts[refParts.length - 1]; + + Namespace parent = ctx.namespace.child(Schemas.getNamespaceExtension(schema)); + Context thisCtx = ctx.withNamespace(parent); + + if (Schemas.isObject(schema)) { + parent.shapes.add(ObjectShape.from(thisCtx, name, schema)); + } else if (Schemas.isString(schema) && schema.hasEnums()) { + parent.shapes.add(EnumShape.from(thisCtx, name, schema)); + } + } + + return ctx.namespace; + } + + private final String name; + private final Map children = new TreeMap<>(); + private final Map operations = new TreeMap<>(); + private final List shapes = new ArrayList<>(); + + private Namespace() { + this(null, ""); + } + + private Namespace(Namespace parent, String name) { + super(parent, null); + this.name = name; + } + + @Override + public String packageName() { + return parent != null + ? parent.packageName() + "." + packageNamePart() + : "org.opensearch.client.opensearch"; + } + + private String packageNamePart() { + return name.replace("_", "").toLowerCase(); + } + + public Namespace child(String name) { + if (name == null || name.isEmpty()) { + return this; + } + + int idx = name.indexOf('.'); + Namespace child = children.computeIfAbsent( + idx >= 0 ? name.substring(0, idx) : name, + n -> new Namespace(this, n) + ); + return idx < 0 + ? child + : child.child(name.substring(idx + 1)); + } + + @Override + public void render(Renderer renderer, File outputDir) throws RenderException { + outputDir.mkdirs(); + + for (Namespace child : children.values()) { + child.render(renderer, new File(outputDir, child.packageNamePart())); + } + + for (Shape shape : shapes) { + shape.render(renderer, outputDir); + } + + // Don't generate root client for now otherwise conflicts + if (parent == null) return; + + new Client(this, false).render(renderer, outputDir); + new Client(this, true).render(renderer, outputDir); + } + + private static class Client extends Shape { + private final boolean async; + + public Client(Namespace parent, boolean async) { + super(parent, "OpenSearch" + Strings.toPascalCase(parent.name) + (async ? "Async" : "") + "Client"); + this.async = async; + } + + public String name() { + return parent.name; + } + + public Collection children() { + return parent + .children + .values() + .stream() + .map(n -> new Client(n, async)) + .collect(Collectors.toList()); + } + + public Collection operations() { + return parent.operations.values(); + } + + public boolean async() { + return this.async; + } + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java index 7ed40a678e..1465ce0a66 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java @@ -11,16 +11,18 @@ import java.util.Collection; import java.util.Map; import java.util.TreeMap; +import org.openapi4j.parser.model.v3.Schema; public class ObjectShape extends Shape { - private final Map bodyFields = new TreeMap<>(); - - public ObjectShape(String namespace, String className) { - super(namespace, className); + public static ObjectShape from(Context ctx, String name, Schema schema) { + return new ObjectShape(ctx.namespace, name, Field.allFrom(ctx, schema)); } - public void addBodyField(Field field) { - bodyFields.put(field.name(), field); + protected final Map bodyFields = new TreeMap<>(); + + protected ObjectShape(Namespace parent, String className, Collection bodyFields) { + super(parent, className); + bodyFields.forEach(f -> this.bodyFields.put(f.name(), f)); } public Collection bodyFields() { return bodyFields.values(); } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java index f23c4754d2..db490109b9 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java @@ -8,37 +8,65 @@ package org.opensearch.client.codegen.model; -import org.opensearch.client.codegen.utils.Strings; - import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.TreeMap; +import org.openapi4j.parser.model.v3.Operation; +import org.openapi4j.parser.model.v3.Path; +import org.opensearch.client.codegen.utils.Schemas; +import org.opensearch.client.codegen.utils.Strings; public class RequestShape extends ObjectShape { - public static String requestClassName(String id) { - return Strings.toPascalCase(id) + "Request"; - } - - public static String responseClassName(String id) { - return Strings.toPascalCase(id) + "Response"; + public static RequestShape from(Context ctx, String httpPath, Path path, String method, Operation operation) { + List bodyFields = Schemas.resolveRequestBodySchema(ctx.openApiCtx, operation) + .map(schema -> Field.allFrom(ctx, schema)) + .orElseGet(ArrayList::new); + + List queryParams = Field.allFrom(ctx, path, operation, "query"); + List pathParams = Field.allFrom(ctx, path, operation, "path"); + + return new RequestShape( + ctx.namespace, + Schemas.getOperationNameExtension(operation), + operation.getDescription(), + method, + httpPath, + bodyFields, + queryParams, + pathParams + ); } private final String id; private final String description; private final String httpMethod; - private final String httpPath; private final Map queryParams = new TreeMap<>(); private final Map pathParams = new TreeMap<>(); private final Map fields = new TreeMap<>(); - - public RequestShape(String namespace, String id, String description, String httpMethod, String httpPath) { - super(namespace, requestClassName(id)); + private final Collection httpPathParts; + + private RequestShape( + Namespace parent, + String id, + String description, + String httpMethod, + String httpPath, + Collection bodyFields, + Collection queryParams, + Collection pathParams) { + super(parent, requestClassName(id), bodyFields); this.id = id; this.description = description; this.httpMethod = httpMethod; - this.httpPath = httpPath; + queryParams.forEach(f -> this.queryParams.put(f.name(), f)); + pathParams.forEach(f -> this.pathParams.put(f.name(), f)); + this.fields.putAll(this.bodyFields); + this.fields.putAll(this.queryParams); + this.fields.putAll(this.pathParams); + this.httpPathParts = HttpPathPart.partsFrom(httpPath, this.pathParams); } public String id() { @@ -54,31 +82,7 @@ public String httpMethod() { } public Collection httpPathParts() { - List parts = new ArrayList<>(); - boolean isParameter = false; - StringBuilder content = new StringBuilder(); - for (char c : httpPath.toCharArray()) { - if (c == '{') { - if (content.length() > 0) { - parts.add(new HttpPathPart(isParameter, content.toString())); - } - content = new StringBuilder(); - isParameter = true; - } else if (c == '}') { - if (content.length() > 0) { - parts.add(new HttpPathPart(isParameter, content.toString())); - } - content = new StringBuilder(); - isParameter = false; - } else { - content.append(c); - } - } - if (content.length() > 0) { - parts.add(new HttpPathPart(isParameter, content.toString())); - } - - return parts; + return Collections.unmodifiableCollection(httpPathParts); } public String responseType() { @@ -102,33 +106,11 @@ public Collection fields() { return fields.values(); } - @Override - public void addBodyField(Field field) { - super.addBodyField(field); - fields.put(field.name(), field); - } - - public void addQueryParam(Field field) { - queryParams.put(field.name(), field); - fields.put(field.name(), field); - } - - public void addPathParam(Field field) { - pathParams.put(field.name(), field); - fields.put(field.name(), field); + public static String requestClassName(String id) { + return Strings.toPascalCase(id) + "Request"; } - public class HttpPathPart { - public final boolean isParameter; - public final String content; - - public HttpPathPart(boolean isParameter, String content) { - this.isParameter = isParameter; - this.content = content; - } - - public Field parameter() { - return isParameter ? pathParams.get(content) : null; - } + public static String responseClassName(String id) { + return Strings.toPascalCase(id) + "Response"; } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java index 18e8f7b2ca..99aad488fc 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java @@ -8,24 +8,32 @@ package org.opensearch.client.codegen.model; +import java.io.File; +import org.opensearch.client.codegen.Renderer; +import org.opensearch.client.codegen.exceptions.RenderException; + public abstract class Shape { - protected final String namespace; + protected final Namespace parent; private final String className; - public Shape(String namespace, String className) { - this.namespace = namespace; + public Shape(Namespace parent, String className) { + this.parent = parent; this.className = className; } - public String namespace() { - return this.namespace; + public Namespace parent() { + return this.parent; } public String packageName() { - return "org.opensearch.client.opensearch." + this.namespace.replace("_", "").toLowerCase(); + return parent.packageName(); } public String className() { return this.className; } + + public void render(Renderer renderer, File outputDir) throws RenderException { + renderer.render(this, new File(outputDir, this.className + ".java")); + } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/MediaType.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/MediaType.java new file mode 100644 index 0000000000..d39d8d987f --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/MediaType.java @@ -0,0 +1,7 @@ +package org.opensearch.client.codegen.utils; + +public class MediaType { + public static final String JSON = "application/json"; + + private MediaType() {} +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Schemas.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Schemas.java index 77363d0dbc..568489cf00 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Schemas.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Schemas.java @@ -8,20 +8,46 @@ package org.opensearch.client.codegen.utils; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Stream; +import org.openapi4j.core.exception.DecodeException; +import org.openapi4j.core.model.OAIContext; +import org.openapi4j.core.model.reference.Reference; import org.openapi4j.core.model.v3.OAI3SchemaKeywords; +import org.openapi4j.parser.model.AbsRefOpenApiSchema; import org.openapi4j.parser.model.v3.AbsExtendedOpenApiSchema; import org.openapi4j.parser.model.v3.AbsExtendedRefOpenApiSchema; +import org.openapi4j.parser.model.v3.Operation; +import org.openapi4j.parser.model.v3.Parameter; +import org.openapi4j.parser.model.v3.Path; +import org.openapi4j.parser.model.v3.RequestBody; import org.openapi4j.parser.model.v3.Schema; public final class Schemas { - public static String getType(Schema schema) { return schema != null ? schema.getType() : null; } - public static boolean is(Schema schema, String type) { return type.equals(getType(schema)); } + public static String getType(Schema schema) { + return schema != null ? schema.getType() : null; + } - public static boolean isObject(Schema schema) { return is(schema, OAI3SchemaKeywords.TYPE_OBJECT); } + public static boolean is(Schema schema, String type) { + return type.equals(getType(schema)); + } - public static boolean isString(Schema schema) { return is(schema, OAI3SchemaKeywords.TYPE_STRING); } + public static boolean isObject(Schema schema) { + return is(schema, OAI3SchemaKeywords.TYPE_OBJECT); + } - public static boolean hasEnums(Schema schema) { return schema != null && schema.hasEnums(); } + public static boolean isString(Schema schema) { + return is(schema, OAI3SchemaKeywords.TYPE_STRING); + } + + public static boolean hasEnums(Schema schema) { + return schema != null && schema.hasEnums(); + } public static String getNamespaceExtension(AbsExtendedOpenApiSchema schema) { return (String) getExtension(schema, "x-namespace"); @@ -35,10 +61,6 @@ public static String getOperationNameExtension(AbsExtendedOpenApiSchema schem return (String) getExtension(schema, "x-operation-name"); } - public static String getOperationNameExtension(AbsExtendedRefOpenApiSchema schema) { - return (String) getExtension(schema, "x-operation-name"); - } - public static Object getExtension(AbsExtendedOpenApiSchema schema, String key) { return schema.getExtensions().get(key); } @@ -46,4 +68,51 @@ public static Object getExtension(AbsExtendedOpenApiSchema schema, String key public static Object getExtension(AbsExtendedRefOpenApiSchema schema, String key) { return schema.getExtensions().get(key); } + + public static > Optional resolve(OAIContext context, S schema, Class clazz) { + while (schema != null && schema.isRef()) { + Reference ref = schema.getReference(context); + try { + schema = ref.getMappedContent(clazz); + } catch (DecodeException e) { + throw new RuntimeException("Failed to decode reference as " + clazz + ": " + ref, e); + } + } + return Optional.ofNullable(schema); + } + + public static Optional resolve(OAIContext context, RequestBody body) { + return resolve(context, body, RequestBody.class); + } + + public static Optional resolve(OAIContext context, Schema schema) { + return resolve(context, schema, Schema.class); + } + + public static Optional resolveRequestBodySchema(OAIContext context, Operation operation) { + return Schemas.resolve(context, operation.getRequestBody()) + .map(body -> body.getContentMediaType(MediaType.JSON)) + .flatMap(media -> Schemas.resolve(context, media.getSchema())); + } + + public static Optional resolveResponseBodySchema(OAIContext context, Operation operation) { + return Optional.ofNullable(operation.getResponse("200")) + .map(response -> response.getContentMediaType(MediaType.JSON)) + .flatMap(media -> Schemas.resolve(context, media.getSchema())); + } + + public static void forEachProperty(Schema schema, TriConsumer propertyVisitor) { + Map properties = schema.getProperties(); + + if (properties == null) return; + + Set requiredFields = new HashSet<>(schema.hasRequiredFields() ? schema.getRequiredFields() : new ArrayList<>(0)); + + properties.forEach((name, propertySchema) -> propertyVisitor.accept(name, propertySchema, requiredFields.contains(name))); + } + + public static Stream getParametersIn(OAIContext context, Path path, Operation operation, String in) { + return Stream.of(path.getParametersIn(context, in), operation.getParametersIn(context, in)) + .flatMap(List::stream); + } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/TriConsumer.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/TriConsumer.java new file mode 100644 index 0000000000..e5518a9a3c --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/TriConsumer.java @@ -0,0 +1,6 @@ +package org.opensearch.client.codegen.utils; + +@FunctionalInterface +public interface TriConsumer { + void accept(T t, U u, V v); +} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Client.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Client.mustache index f8a1b8ebf9..7df929f47b 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Client.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Client.mustache @@ -5,6 +5,9 @@ package {{packageName}}; import org.opensearch.client.ApiClient; import org.opensearch.client.opensearch._types.OpenSearchException; import org.opensearch.client.opensearch._types.ErrorResponse; +{{#children}} +import {{packageName}}.{{className}}; +{{/children}} import org.opensearch.client.transport.OpenSearchTransport; import org.opensearch.client.transport.JsonEndpoint; import org.opensearch.client.transport.TransportOptions; @@ -29,17 +32,23 @@ public class {{className}} extends ApiClient public {{className}} withTransportOptions(@Nullable TransportOptions transportOptions) { return new {{className}}(this.transport, transportOptions); } +{{#children}} + + public {{className}} {{#camelCase}}{{name}}{{/camelCase}}() { + return new {{className}}(this.transport, this.transportOptions); + } +{{/children}} {{#operations}} - public {{#async}}CompletableFuture<{{/async}}{{responseType}}{{#async}}>{{/async}} {{name}}({{requestType}} request) throws IOException, OpenSearchException { - JsonEndpoint<{{requestType}}, {{responseType}}, ErrorResponse> endpoint = (JsonEndpoint<{{requestType}}, {{responseType}}, ErrorResponse>) {{requestType}}._ENDPOINT; + public {{#async}}CompletableFuture<{{/async}}{{responseType}}{{#async}}>{{/async}} {{#camelCase}}{{id}}{{/camelCase}}({{className}} request) throws IOException, OpenSearchException { + JsonEndpoint<{{className}}, {{responseType}}, ErrorResponse> endpoint = (JsonEndpoint<{{className}}, {{responseType}}, ErrorResponse>) {{className}}._ENDPOINT; return this.transport.performRequest{{#async}}Async{{/async}}(request, endpoint, this.transportOptions); } - public final {{#async}}CompletableFuture<{{/async}}{{responseType}}{{#async}}>{{/async}} {{name}}(Function<{{requestType}}.Builder, ObjectBuilder<{{requestType}}>> fn) + public final {{#async}}CompletableFuture<{{/async}}{{responseType}}{{#async}}>{{/async}} {{#camelCase}}{{id}}{{/camelCase}}(Function<{{className}}.Builder, ObjectBuilder<{{className}}>> fn) throws IOException, OpenSearchException { - return {{name}}(fn.apply(new {{requestType}}.Builder()).build()); + return {{#camelCase}}{{id}}{{/camelCase}}(fn.apply(new {{className}}.Builder()).build()); } {{/operations}} } \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache index 1a9e737210..ea813102ae 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache @@ -8,7 +8,7 @@ import org.opensearch.client.json.JsonpDeserializable; @JsonpDeserializable public enum {{className}} implements JsonEnum { {{#variants}} - {{name}}({{#dq}}{{wireName}}{{/dq}}), + {{name}}({{#quoted}}{{wireName}}{{/quoted}}), {{/variants}} ; diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Constructor.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Constructor.mustache index 7d7cd67e2b..a3e794456b 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Constructor.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Constructor.mustache @@ -2,7 +2,7 @@ {{#fields}} {{#type.isListOrMap}} {{#required}} - this.{{name}} = ApiTypeHelper.unmodifiableRequired(builder.{{name}}, this, {{#dq}}{{name}}{{/dq}}); + this.{{name}} = ApiTypeHelper.unmodifiableRequired(builder.{{name}}, this, {{#quoted}}{{name}}{{/quoted}}); {{/required}} {{^required}} this.{{name}} = ApiTypeHelper.unmodifiable(builder.{{name}}); @@ -10,7 +10,7 @@ {{/type.isListOrMap}} {{^type.isListOrMap}} {{#required}} - this.{{name}} = ApiTypeHelper.requireNonNull(builder.{{name}}, this, {{#dq}}{{name}}{{/dq}}); + this.{{name}} = ApiTypeHelper.requireNonNull(builder.{{name}}, this, {{#quoted}}{{name}}{{/quoted}}); {{/required}} {{^required}} this.{{name}} = builder.{{name}}; diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache index 241b2a0c7f..b9b15f1ad8 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache @@ -2,6 +2,6 @@ protected static void setup{{className}}Deserializer(ObjectDeserializer<{{className}}.Builder> op) { {{#bodyFields}} - op.add(Builder::{{name}}, {{{type.deserializer}}}, {{#dq}}{{wireName}}{{/dq}}); + op.add(Builder::{{name}}, {{{type.deserializer}}}, {{#quoted}}{{wireName}}{{/quoted}}); {{/bodyFields}} } \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache index 0658f16b0a..d263eb00e5 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache @@ -9,7 +9,7 @@ {{^required}} if ({{#type.isDefined}}this.{{name}}{{/type.isDefined}}) { {{/required}} - generator.writeKey({{#dq}}{{wireName}}{{/dq}}); + generator.writeKey({{#quoted}}{{wireName}}{{/quoted}}); {{#type.serializer}}this.{{name}}{{/type.serializer}} {{^required}} } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache index 32d7cf7dd5..90c77caebe 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache @@ -51,7 +51,7 @@ public class {{className}} extends RequestBase{{#hasRequestBody}} implements Jso public static final Endpoint<{{className}}, {{responseType}}, ErrorResponse> _ENDPOINT = new SimpleEndpoint<>( // Request method request -> { - return {{#dq}}{{httpMethod}}{{/dq}}; + return {{#quoted}}{{httpMethod}}{{/quoted}}; }, // Request path request -> { @@ -61,7 +61,7 @@ public class {{className}} extends RequestBase{{#hasRequestBody}} implements Jso SimpleEndpoint.pathEncode({{#parameter.type.queryParamify}}request.{{parameter.name}}{{/parameter.type.queryParamify}}, buf); {{/isParameter}} {{^isParameter}} - buf.append({{#dq}}{{content}}{{/dq}}); + buf.append({{#quoted}}{{content}}{{/quoted}}); {{/isParameter}} {{/httpPathParts}} return buf.toString(); @@ -71,7 +71,7 @@ public class {{className}} extends RequestBase{{#hasRequestBody}} implements Jso Map params = new HashMap<>(); {{#queryParams}} if ({{#type.isDefined}}request.{{name}}{{/type.isDefined}}) { - params.put({{#dq}}{{wireName}}{{/dq}}, {{#type.queryParamify}}request.{{name}}{{/type.queryParamify}}); + params.put({{#quoted}}{{wireName}}{{/quoted}}, {{#type.queryParamify}}request.{{name}}{{/type.queryParamify}}); } {{/queryParams}} return params; From f92b8eb9d389cf73e2609780cd87369b395bf0c5 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Fri, 3 Mar 2023 21:00:41 +1300 Subject: [PATCH 17/50] Less code more templates Signed-off-by: Thomas Farr --- .../org/opensearch/client/codegen/Main.java | 2 +- .../opensearch/client/codegen/Renderer.java | 84 +++++++----- .../client/codegen/model/Context.java | 8 ++ .../client/codegen/model/HttpPathPart.java | 8 ++ .../client/codegen/model/Namespace.java | 10 +- .../client/codegen/model/Shape.java | 2 +- .../opensearch/client/codegen/model/Type.java | 120 +++++------------- .../client/codegen/utils/MediaType.java | 8 ++ .../client/codegen/utils/TriConsumer.java | 8 ++ .../templates/ObjectShape/Builder.mustache | 20 +-- .../ObjectShape/Deserialize.mustache | 2 +- .../templates/ObjectShape/Fields.mustache | 2 +- .../templates/ObjectShape/Getters.mustache | 2 +- .../templates/ObjectShape/Serialize.mustache | 7 +- .../codegen/templates/RequestShape.mustache | 7 +- .../templates/Type/deserializer.mustache | 14 ++ .../templates/Type/queryParamify.mustache | 21 +++ .../templates/Type/serializer.mustache | 23 ++++ 18 files changed, 212 insertions(+), 136 deletions(-) create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/deserializer.mustache create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/queryParamify.mustache create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/serializer.mustache diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/Main.java b/java-codegen/src/main/java/org/opensearch/client/codegen/Main.java index e38eaf0802..4655072fb3 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/Main.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/Main.java @@ -42,7 +42,7 @@ public static void main(String[] args) { outputDir = new File(outputDir, root.packageName().replace('.', '/')); - root.render(new Renderer(), outputDir); + root.render(Renderer.INSTANCE, outputDir); } catch (Throwable e) { e.printStackTrace(System.err); System.exit(1); diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java b/java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java index 7988ccad24..67ecc112c8 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/Renderer.java @@ -14,10 +14,6 @@ import com.samskivert.mustache.Mustache; import com.samskivert.mustache.MustacheException; import com.samskivert.mustache.Template; -import java.util.function.Function; -import org.apache.commons.text.StringEscapeUtils; -import org.opensearch.client.codegen.exceptions.RenderException; - import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -28,63 +24,85 @@ import java.util.HashMap; import java.util.Map; import java.util.MissingResourceException; +import java.util.function.Function; +import org.apache.commons.text.StringEscapeUtils; +import org.opensearch.client.codegen.exceptions.RenderException; import org.opensearch.client.codegen.utils.Strings; public class Renderer { - private static Mustache.Lambda transformer(Function transform) { + public static final Renderer INSTANCE = new Renderer(); + + public static Mustache.Lambda transformer(Function transform) { return ((frag, out) -> out.write(transform.apply(frag.execute()))); } + public static Mustache.Lambda templateLambda(String templateName, Function contextGetter) { + return (frag, out) -> { + try { + Renderer.INSTANCE.render(templateName, contextGetter.apply(frag), out); + } catch (RenderException e) { + throw new RuntimeException(e); + } + }; + } + private static final Map lambdas = new HashMap<>() {{ put("quoted", transformer(s -> '\"' + StringEscapeUtils.escapeJava(s) + '\"')); put("camelCase", transformer(Strings::toCamelCase)); + put("toLower", transformer(String::toLowerCase)); }}; private final Mustache.Compiler compiler; private final Formatter formatter; - public Renderer() { - compiler = Mustache.compiler().withLoader(name -> { - InputStream stream = Renderer.class.getResourceAsStream("templates/" + name + ".mustache"); - if (stream == null) { - throw new MissingResourceException("Unable to find template", Renderer.class.getName(), name); - } - return new InputStreamReader(stream); - }); + private Renderer() { + compiler = Mustache.compiler() + .escapeHTML(false) + .withLoader(name -> { + InputStream stream = Renderer.class.getResourceAsStream("templates/" + name + ".mustache"); + if (stream == null) { + throw new MissingResourceException("Unable to find template", Renderer.class.getName(), name); + } + return new InputStreamReader(stream); + } + ); + formatter = new Formatter( JavaFormatterOptions.builder() - .style(JavaFormatterOptions.Style.AOSP) - .formatJavadoc(true) - .build()); + .style(JavaFormatterOptions.Style.AOSP) + .formatJavadoc(true) + .build()); } - public String render(Object object, String templateName) throws RenderException { + public void render(String templateName, Object context, Writer out) throws RenderException { try { - Template template = compiler.loadTemplate(templateName); - Writer writer = new StringWriter(); + compiler.loadTemplate(templateName) + .execute(context, lambdas, out); + } catch (MustacheException e) { + throw new RenderException("Failed to render: " + context, e); + } + } - template.execute(object, lambdas, writer); + public String renderJava(String templateName, Object context) throws RenderException { + Writer writer = new StringWriter(); - String output = writer.toString(); + render(templateName, context, writer); - try { - output = formatter.formatSource(output); - } catch (FormatterException e) { - output = "// FAILED FORMATTING: " + e + "\n\n" + output; - } + String output = writer.toString(); - return output; - } catch (MustacheException e) { - throw new RenderException("Failed to render: " + object, e); + try { + return formatter.formatSource(output); + } catch (FormatterException e) { + return "// FAILED FORMATTING: " + e + "\n\n" + output; } } - public void render(Object object, File outputFile) throws RenderException { - render(object, object.getClass().getSimpleName(), outputFile); + public void renderJava(Object context, File outputFile) throws RenderException { + renderJava(context.getClass().getSimpleName(), context, outputFile); } - public void render(Object object, String templateName, File outputFile) throws RenderException { - String output = render(object, templateName); + public void renderJava(String templateName, Object context, File outputFile) throws RenderException { + String output = renderJava(templateName, context); try (Writer writer = new FileWriter(outputFile)) { writer.write(output); } catch (IOException e) { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Context.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Context.java index 343a5d66c6..d58312058c 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Context.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Context.java @@ -1,3 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.codegen.model; import org.openapi4j.core.model.OAIContext; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/HttpPathPart.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/HttpPathPart.java index 5870a2f6d9..8896e9a74f 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/HttpPathPart.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/HttpPathPart.java @@ -1,3 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.codegen.model; import java.util.ArrayList; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java index e7592d1016..78fdf39851 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java @@ -1,3 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.codegen.model; import java.io.File; @@ -129,7 +137,7 @@ public void render(Renderer renderer, File outputDir) throws RenderException { private static class Client extends Shape { private final boolean async; - public Client(Namespace parent, boolean async) { + private Client(Namespace parent, boolean async) { super(parent, "OpenSearch" + Strings.toPascalCase(parent.name) + (async ? "Async" : "") + "Client"); this.async = async; } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java index 99aad488fc..fa7248f7c1 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java @@ -34,6 +34,6 @@ public String className() { } public void render(Renderer renderer, File outputDir) throws RenderException { - renderer.render(this, new File(outputDir, this.className + ".java")); + renderer.renderJava(this, new File(outputDir, this.className + ".java")); } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java index c867bac064..34bc88c777 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java @@ -10,14 +10,15 @@ import com.samskivert.mustache.Mustache; import org.openapi4j.parser.model.v3.Schema; +import org.opensearch.client.codegen.Renderer; import org.opensearch.client.codegen.utils.Schemas; -import java.io.IOException; -import java.io.Writer; import java.util.Arrays; import java.util.Set; import java.util.stream.Collectors; +import static org.opensearch.client.codegen.Renderer.templateLambda; + public class Type { private static final Set PRIMITIVES = Set.of( "String", @@ -112,6 +113,10 @@ public Type listValueType() { public boolean isListOrMap() { return isList() || isMap(); } + public boolean isString() { + return "String".equals(name); + } + public boolean isPrimitive() { return PRIMITIVES.contains(name); } public boolean isBuiltIn() { return isListOrMap() || isPrimitive() || "JsonData".equals(name); } @@ -132,93 +137,38 @@ public Type builderFuncType() { return new Type(null, "Function", builderType(), new Type(null, "ObjectBuilder", this)); } - public Mustache.Lambda isDefined() { - return (frag, out) -> { - String value = frag.execute(); - if (isListOrMap()) { - out.write("ApiTypeHelper.isDefined(" + value + ")"); - } else { - out.write(value + " != null"); - } - }; - } - public Mustache.Lambda serializer() { - return (frag, out) -> serializer(frag.execute(), out, 0); - } - - private void serializer(String value, Writer out, int depth) throws IOException { - if (isMap()) { - String item = "item" + depth; - out.write("generator.writeStartObject();\n"); - out.write("for (" + mapEntryType() + " " + item + " : " + value + ".entrySet()) {\n"); - out.write(" generator.writeKey(" + item + ".getKey());\n"); - mapValueType().serializer(item + ".getValue()", out, depth + 1); - out.write("\n}\n"); - out.write("generator.writeEnd();"); - } else if (isList()) { - String item = "item" + depth; - out.write("generator.writeStartArray();\n"); - out.write("for (" + listValueType() + " " + item + " : " + value + ") {\n"); - listValueType().serializer(item, out, depth + 1); - out.write("\n}\n"); - out.write("generator.writeEnd();"); - } else if (isPrimitive()) { - out.write("generator.write(" + value + ");"); - } else { - out.write(value + ".serialize(generator, mapper);"); - } - } - - public String deserializer() { - switch (name) { - case "String": - return "JsonpDeserializer.stringDeserializer()"; - - case "boolean": - case "Boolean": - return "JsonpDeserializer.booleanDeserializer()"; - - case "int": - case "Integer": - return "JsonpDeserializer.integerDeserializer()"; - - case "long": - case "Long": - return "JsonpDeserializer.longDeserializer()"; - - case "float": - case "Float": - return "JsonpDeserializer.floatDeserializer()"; - - case "double": - case "Double": - return "JsonpDeserializer.doubleDeserializer()"; - - case "List": - return "JsonpDeserializer.arrayDeserializer(" + listValueType().deserializer() + ")"; - - case "Map": - return "JsonpDeserializer.stringMapDeserializer(" + mapValueType().deserializer() + ")"; - - default: - return name + "._DESERIALIZER"; + return Renderer.templateLambda( + "Type/serializer", + frag -> new SerializerLambdaContext( + Type.this, + frag.execute(), + frag.context() instanceof SerializerLambdaContext + ? ((SerializerLambdaContext) frag.context()).depth + 1 + : 0 + ) + ); + } + + private static class SerializerLambdaContext { + public final Type type; + public final String value; + public final int depth; + + private SerializerLambdaContext(Type type, String value, int depth) { + this.type = type; + this.value = value; + this.depth = depth; } } public Mustache.Lambda queryParamify() { - return (frag, out) -> out.write(queryParamify(frag.execute())); - } - - public String queryParamify(String value) { - if (Schemas.isString(schema) || "String".equals(name)) { - return Schemas.hasEnums(schema) ? value + ".jsonValue()" : value; - } else if (isPrimitive()) { - return "String.valueOf(" + value + ")"; - } else if (isList()) { - return value + ".stream().map(v -> " + listValueType().queryParamify("v") + ").collect(Collectors.joining(\",\"))"; - } - - throw new UnsupportedOperationException("Don't know how to queryParamify " + value + " with type: " + this); + return templateLambda( + "Type/queryParamify", + frag -> new Object() { + final Type type = Type.this; + final String value = frag.execute(); + } + ); } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/MediaType.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/MediaType.java index d39d8d987f..da2fd7308f 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/MediaType.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/MediaType.java @@ -1,3 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.codegen.utils; public class MediaType { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/TriConsumer.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/TriConsumer.java index e5518a9a3c..899c3bd3a7 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/TriConsumer.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/TriConsumer.java @@ -1,3 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + package org.opensearch.client.codegen.utils; @FunctionalInterface diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache index bfee40ecde..984615c9e4 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache @@ -3,47 +3,47 @@ */ public static class Builder extends ObjectBuilderBase implements ObjectBuilder<{{className}}> { {{#fields}} - private {{{type.boxed}}} {{name}}; + private {{type.boxed}} {{name}}; {{/fields}} {{#fields}} {{#type.isMap}} - public final Builder {{name}}({{{type}}} map) { + public final Builder {{name}}({{type}} map) { this.{{name}} = _mapPutAll(this.{{name}}, map); return this; } - public final Builder {{name}}({{{type.mapKeyType}}} key, {{{type.mapValueType}}} value) { + public final Builder {{name}}({{type.mapKeyType}} key, {{type.mapValueType}} value) { this.{{name}} = _mapPut(this.{{name}}, key, value); return this; } {{/type.isMap}} {{#type.isList}} - public final Builder {{name}}({{{type}}} list) { + public final Builder {{name}}({{type}} list) { this.{{name}} = _listAddAll(this.{{name}}, list); return this; } - public final Builder {{name}}({{{type.listValueType}}} value, {{{type.listValueType}}}... values) { + public final Builder {{name}}({{type.listValueType}} value, {{type.listValueType}}... values) { this.{{name}} = _listAdd(this.{{name}}, value, values); return this; } {{#type.listValueType.hasBuilder}} - public final Builder {{name}}({{{type.listValueType.builderFuncType}}} fn) { - return {{name}}(fn.apply(new {{{type.listValueType.builderType}}}()).build()); + public final Builder {{name}}({{type.listValueType.builderFuncType}} fn) { + return {{name}}(fn.apply(new {{type.listValueType.builderType}}()).build()); } {{/type.listValueType.hasBuilder}} {{/type.isList}} {{^type.isListOrMap}} - public final Builder {{name}}({{{type}}} value) { + public final Builder {{name}}({{type}} value) { this.{{name}} = value; return this; } {{#type.hasBuilder}} - public final Builder {{name}}({{{type.builderFuncType}}} fn) { - return {{name}}(fn.apply(new {{{type.builderType}}}()).build()); + public final Builder {{name}}({{type.builderFuncType}} fn) { + return {{name}}(fn.apply(new {{type.builderType}}()).build()); } {{/type.hasBuilder}} {{/type.isListOrMap}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache index b9b15f1ad8..5fbfe12e51 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache @@ -2,6 +2,6 @@ protected static void setup{{className}}Deserializer(ObjectDeserializer<{{className}}.Builder> op) { {{#bodyFields}} - op.add(Builder::{{name}}, {{{type.deserializer}}}, {{#quoted}}{{wireName}}{{/quoted}}); + op.add(Builder::{{name}}, {{#type}}{{>Type/deserializer}}{{/type}}, {{#quoted}}{{wireName}}{{/quoted}}); {{/bodyFields}} } \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Fields.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Fields.mustache index 6822decb32..d9d417b64e 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Fields.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Fields.mustache @@ -3,5 +3,5 @@ {{^required}} @Nullable {{/required}} - private final {{{type}}} {{name}}; + private final {{type}} {{name}}; {{/fields}} \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Getters.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Getters.mustache index cac3b57373..7762c86867 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Getters.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Getters.mustache @@ -1,6 +1,6 @@ {{#fields}} - public final {{{type}}} {{name}}() { + public final {{type}} {{name}}() { return this.{{name}}; } {{/fields}} \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache index d263eb00e5..d9315a27d7 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache @@ -7,7 +7,12 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { {{#bodyFields}} {{^required}} - if ({{#type.isDefined}}this.{{name}}{{/type.isDefined}}) { + {{#type.isListOrMap}} + if (ApiTypeHelper.isDefined(this.{{name}})) { + {{/type.isListOrMap}} + {{^type.isListOrMap}} + if (this.{{name}} != null) { + {{/type.isListOrMap}} {{/required}} generator.writeKey({{#quoted}}{{wireName}}{{/quoted}}); {{#type.serializer}}this.{{name}}{{/type.serializer}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache index 90c77caebe..05194250e5 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache @@ -70,7 +70,12 @@ public class {{className}} extends RequestBase{{#hasRequestBody}} implements Jso request -> { Map params = new HashMap<>(); {{#queryParams}} - if ({{#type.isDefined}}request.{{name}}{{/type.isDefined}}) { + {{#type.isListOrMap}} + if (ApiTypeHelper.isDefined(request.{{name}})) { + {{/type.isListOrMap}} + {{^type.isListOrMap}} + if (request.{{name}} != null) { + {{/type.isListOrMap}} params.put({{#quoted}}{{wireName}}{{/quoted}}, {{#type.queryParamify}}request.{{name}}{{/type.queryParamify}}); } {{/queryParams}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/deserializer.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/deserializer.mustache new file mode 100644 index 0000000000..52c4913328 --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/deserializer.mustache @@ -0,0 +1,14 @@ +{{#isPrimitive}} + JsonpDeserializer.{{#toLower}}{{boxed.name}}{{/toLower}}Deserializer() +{{/isPrimitive}} +{{^isPrimitive}} + {{#isList}} + JsonpDeserializer.arrayDeserializer({{#listValueType}}{{>Type/deserializer}}{{/listValueType}}) + {{/isList}} + {{#isMap}} + JsonpDeserializer.stringMapDeserializer({{#mapValueType}}{{>Type/deserializer}}{{/mapValueType}}) + {{/isMap}} + {{^isListOrMap}} + {{name}}._DESERIALIZER + {{/isListOrMap}} +{{/isPrimitive}} \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/queryParamify.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/queryParamify.mustache new file mode 100644 index 0000000000..1782729fa3 --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/queryParamify.mustache @@ -0,0 +1,21 @@ +{{#type.isString}} + {{value}} +{{/type.isString}} +{{^type.isString}} + {{#type.isEnum}} + {{value}}.jsonValue() + {{/type.isEnum}} + {{^type.isEnum}} + {{#type.isPrimitive}} + String.valueOf({{value}}) + {{/type.isPrimitive}} + {{^type.isPrimitive}} + {{#type.isList}} + {{value}}.stream().map(v -> {{#type.listValueType.queryParamify}}v{{/type.listValueType.queryParamify}}).collect(Collectors.joining(",")) + {{/type.isList}} + {{^type.isList}} + ERROR: Unsupported queryParamify of {{type}} + {{/type.isList}} + {{/type.isPrimitive}} + {{/type.isEnum}} +{{/type.isString}} \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/serializer.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/serializer.mustache new file mode 100644 index 0000000000..afef833ec8 --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/serializer.mustache @@ -0,0 +1,23 @@ +{{#type.isMap}} + generator.writeStartObject(); + for ({{type.mapEntryType}} item{{depth}} : {{value}}.entrySet()) { + generator.writeKey(item{{depth}}.getKey()); + {{#type.mapValueType.serializer}}item{{depth}}.getValue(){{/type.mapValueType.serializer}} + } + generator.writeEnd(); +{{/type.isMap}} +{{#type.isList}} + generator.writeStartArray(); + for ({{type.listValueType}} item{{depth}} : {{value}}) { + {{#type.listValueType.serializer}}item{{depth}}{{/type.listValueType.serializer}} + } + generator.writeEnd(); +{{/type.isList}} +{{^type.isListOrMap}} + {{#type.isPrimitive}} + generator.write({{value}}); + {{/type.isPrimitive}} + {{^type.isPrimitive}} + {{value}}.serialize(generator, mapper); + {{/type.isPrimitive}} +{{/type.isListOrMap}} \ No newline at end of file From 82abb0d325c8e3fb8dea1b6308591af2765eac0c Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Fri, 26 Jan 2024 12:48:27 +1300 Subject: [PATCH 18/50] Simplify http path part Signed-off-by: Thomas Farr --- .../client/codegen/model/HttpPathPart.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/HttpPathPart.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/HttpPathPart.java index 8896e9a74f..1bd95ed65f 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/HttpPathPart.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/HttpPathPart.java @@ -18,23 +18,19 @@ public static Collection partsFrom(String httpPath, Map parts = new ArrayList<>(); boolean isParameter = false; StringBuilder content = new StringBuilder(); + for (char c : httpPath.toCharArray()) { - if (c == '{') { - if (content.length() > 0) { - parts.add(from(isParameter, content.toString(), pathParams)); - } - content = new StringBuilder(); - isParameter = true; - } else if (c == '}') { + if (c == '{' || c == '}') { if (content.length() > 0) { parts.add(from(isParameter, content.toString(), pathParams)); } content = new StringBuilder(); - isParameter = false; + isParameter = c == '{'; } else { content.append(c); } } + if (content.length() > 0) { parts.add(from(isParameter, content.toString(), pathParams)); } From 29561069219e64c0ce3c214bbe0635a9a337594d Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Tue, 30 Jan 2024 15:33:55 +1300 Subject: [PATCH 19/50] Fixes Signed-off-by: Thomas Farr --- .../opensearch/client/opensearch/Bytes.java | 51 + .../client/opensearch/ExpandWildcards.java | 45 + .../opensearch/client/opensearch/Time.java | 47 + .../OpenSearchCatAsyncClient.java} | 35 +- .../opensearch/cat/OpenSearchCatClient.java | 60 + .../cat/SegmentReplicationRequest.java | 375 + .../cat/SegmentReplicationResponse.java | 72 + .../OpenSearchRemoteStoreClient.java | 56 - .../remotestore/RemoteStoreRestoreInfo.java | 149 - .../RemoteStoreRestoreShardsInfo.java | 130 - .../remotestore/RestoreRequest.java | 161 - .../remotestore/RestoreResponse.java | 115 - java-codegen/OpenSearch.openapi.json | 61135 ++++++++++++++++ java-codegen/build.gradle.kts | 3 +- .../org/opensearch/client/codegen/Main.java | 9 +- .../client/codegen/model/HttpPathPart.java | 28 +- .../client/codegen/model/Namespace.java | 11 +- .../client/codegen/model/OperationGroup.java | 51 + .../client/codegen/model/RequestShape.java | 16 +- .../opensearch/client/codegen/model/Type.java | 4 +- .../client/codegen/utils/Either.java | 109 + .../client/codegen/utils/Extensions.java | 55 + .../client/codegen/utils/Schemas.java | 21 +- .../codegen/templates/ObjectShape.mustache | 1 + .../codegen/templates/RequestShape.mustache | 15 +- .../templates/Type/queryParamify.mustache | 10 +- 26 files changed, 62097 insertions(+), 667 deletions(-) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/Bytes.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/ExpandWildcards.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/Time.java rename java-client/src/generated/java/org/opensearch/client/opensearch/{remotestore/OpenSearchRemoteStoreAsyncClient.java => cat/OpenSearchCatAsyncClient.java} (50%) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/cat/OpenSearchCatClient.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/cat/SegmentReplicationRequest.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/cat/SegmentReplicationResponse.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/OpenSearchRemoteStoreClient.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RemoteStoreRestoreInfo.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RemoteStoreRestoreShardsInfo.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RestoreRequest.java delete mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/remotestore/RestoreResponse.java create mode 100644 java-codegen/OpenSearch.openapi.json create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/model/OperationGroup.java create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/utils/Either.java create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/utils/Extensions.java diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/Bytes.java b/java-client/src/generated/java/org/opensearch/client/opensearch/Bytes.java new file mode 100644 index 0000000000..5e29cb4126 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/Bytes.java @@ -0,0 +1,51 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +// ---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +// ---------------------------------------------------- + +package org.opensearch.client.opensearch; + +import org.opensearch.client.json.JsonEnum; +import org.opensearch.client.json.JsonpDeserializable; + +@JsonpDeserializable +public enum Bytes implements JsonEnum { + B("b"), + K("k"), + Kb("kb"), + M("m"), + Mb("mb"), + G("g"), + Gb("gb"), + T("t"), + Tb("tb"), + P("p"), + Pb("pb"), + ; + + private final String jsonValue; + private final String[] aliases; + + Bytes(String jsonValue, String... aliases) { + this.jsonValue = jsonValue; + this.aliases = aliases; + } + + public String jsonValue() { + return this.jsonValue; + } + + public String[] aliases() { + return this.aliases; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = + new JsonEnum.Deserializer<>(Bytes.values()); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ExpandWildcards.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ExpandWildcards.java new file mode 100644 index 0000000000..cc8ea90e0b --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ExpandWildcards.java @@ -0,0 +1,45 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +// ---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +// ---------------------------------------------------- + +package org.opensearch.client.opensearch; + +import org.opensearch.client.json.JsonEnum; +import org.opensearch.client.json.JsonpDeserializable; + +@JsonpDeserializable +public enum ExpandWildcards implements JsonEnum { + All("all"), + Open("open"), + Closed("closed"), + Hidden("hidden"), + None("none"), + ; + + private final String jsonValue; + private final String[] aliases; + + ExpandWildcards(String jsonValue, String... aliases) { + this.jsonValue = jsonValue; + this.aliases = aliases; + } + + public String jsonValue() { + return this.jsonValue; + } + + public String[] aliases() { + return this.aliases; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = + new JsonEnum.Deserializer<>(ExpandWildcards.values()); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/Time.java b/java-client/src/generated/java/org/opensearch/client/opensearch/Time.java new file mode 100644 index 0000000000..5a6511007c --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/Time.java @@ -0,0 +1,47 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +// ---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +// ---------------------------------------------------- + +package org.opensearch.client.opensearch; + +import org.opensearch.client.json.JsonEnum; +import org.opensearch.client.json.JsonpDeserializable; + +@JsonpDeserializable +public enum Time implements JsonEnum { + D("d"), + H("h"), + M("m"), + S("s"), + Ms("ms"), + Micros("micros"), + Nanos("nanos"), + ; + + private final String jsonValue; + private final String[] aliases; + + Time(String jsonValue, String... aliases) { + this.jsonValue = jsonValue; + this.aliases = aliases; + } + + public String jsonValue() { + return this.jsonValue; + } + + public String[] aliases() { + return this.aliases; + } + + public static final JsonEnum.Deserializer