Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Backport 2.x] Re-generate client code using latest OpenSearch API specification (2024-09-23) (#1113) #1205

Merged
merged 4 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ public ErrorCause build() {
return new ErrorCause(this);
}
}

// ---------------------------------------------------------------------------------------------

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ public ShardFailure build() {
return new ShardFailure(this);
}
}

// ---------------------------------------------------------------------------------------------

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ public ShardStatistics build() {
return new ShardStatistics(this);
}
}

// ---------------------------------------------------------------------------------------------

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ public final BuilderT version(long value) {

protected abstract BuilderT self();
}

// ---------------------------------------------------------------------------------------------

protected static <BuilderT extends AbstractBuilder<BuilderT>> void setupWriteResponseBaseDeserializer(ObjectDeserializer<BuilderT> op) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,289 @@
/*
* 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.ml;

import jakarta.json.stream.JsonGenerator;
import java.util.function.Function;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.ObjectBuilderDeserializer;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.util.ObjectBuilder;
import org.opensearch.client.util.ObjectBuilderBase;

// typedef: ml.Action

@JsonpDeserializable
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class Action implements PlainJsonSerializable {

@Nullable
private final String actionType;

@Nullable
private final Headers headers;

@Nullable
private final String method;

@Nullable
private final String postProcessFunction;

@Nullable
private final String preProcessFunction;

@Nullable
private final String requestBody;

@Nullable
private final String url;

// ---------------------------------------------------------------------------------------------

private Action(Builder builder) {
this.actionType = builder.actionType;
this.headers = builder.headers;
this.method = builder.method;
this.postProcessFunction = builder.postProcessFunction;
this.preProcessFunction = builder.preProcessFunction;
this.requestBody = builder.requestBody;
this.url = builder.url;
}

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

/**
* API name: {@code action_type}
*/
@Nullable
public final String actionType() {
return this.actionType;
}

/**
* API name: {@code headers}
*/
@Nullable
public final Headers headers() {
return this.headers;
}

/**
* API name: {@code method}
*/
@Nullable
public final String method() {
return this.method;
}

/**
* API name: {@code post_process_function}
*/
@Nullable
public final String postProcessFunction() {
return this.postProcessFunction;
}

/**
* API name: {@code pre_process_function}
*/
@Nullable
public final String preProcessFunction() {
return this.preProcessFunction;
}

/**
* API name: {@code request_body}
*/
@Nullable
public final String requestBody() {
return this.requestBody;
}

/**
* API name: {@code url}
*/
@Nullable
public final String url() {
return this.url;
}

/**
* Serialize this object to JSON.
*/
@Override
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
generator.writeStartObject();
serializeInternal(generator, mapper);
generator.writeEnd();
}

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
if (this.actionType != null) {
generator.writeKey("action_type");
generator.write(this.actionType);
}

if (this.headers != null) {
generator.writeKey("headers");
this.headers.serialize(generator, mapper);
}

if (this.method != null) {
generator.writeKey("method");
generator.write(this.method);
}

if (this.postProcessFunction != null) {
generator.writeKey("post_process_function");
generator.write(this.postProcessFunction);
}

if (this.preProcessFunction != null) {
generator.writeKey("pre_process_function");
generator.write(this.preProcessFunction);
}

if (this.requestBody != null) {
generator.writeKey("request_body");
generator.write(this.requestBody);
}

if (this.url != null) {
generator.writeKey("url");
generator.write(this.url);
}
}

// ---------------------------------------------------------------------------------------------

/**
* Builder for {@link Action}.
*/
public static class Builder extends ObjectBuilderBase implements ObjectBuilder<Action> {
@Nullable
private String actionType;
@Nullable
private Headers headers;
@Nullable
private String method;
@Nullable
private String postProcessFunction;
@Nullable
private String preProcessFunction;
@Nullable
private String requestBody;
@Nullable
private String url;

/**
* API name: {@code action_type}
*/
public final Builder actionType(@Nullable String value) {
this.actionType = value;
return this;
}

/**
* API name: {@code headers}
*/
public final Builder headers(@Nullable Headers value) {
this.headers = value;
return this;
}

/**
* API name: {@code headers}
*/
public final Builder headers(Function<Headers.Builder, ObjectBuilder<Headers>> fn) {
return headers(fn.apply(new Headers.Builder()).build());
}

/**
* API name: {@code method}
*/
public final Builder method(@Nullable String value) {
this.method = value;
return this;
}

/**
* API name: {@code post_process_function}
*/
public final Builder postProcessFunction(@Nullable String value) {
this.postProcessFunction = value;
return this;
}

/**
* API name: {@code pre_process_function}
*/
public final Builder preProcessFunction(@Nullable String value) {
this.preProcessFunction = value;
return this;
}

/**
* API name: {@code request_body}
*/
public final Builder requestBody(@Nullable String value) {
this.requestBody = value;
return this;
}

/**
* API name: {@code url}
*/
public final Builder url(@Nullable String value) {
this.url = value;
return this;
}

/**
* Builds a {@link Action}.
*
* @throws NullPointerException if some of the required fields are null.
*/
public Action build() {
_checkSingleUse();

return new Action(this);
}
}

// ---------------------------------------------------------------------------------------------

/**
* Json deserializer for {@link Action}
*/
public static final JsonpDeserializer<Action> _DESERIALIZER = ObjectBuilderDeserializer.lazy(
Builder::new,
Action::setupActionDeserializer
);

protected static void setupActionDeserializer(ObjectDeserializer<Action.Builder> op) {
op.add(Builder::actionType, JsonpDeserializer.stringDeserializer(), "action_type");
op.add(Builder::headers, Headers._DESERIALIZER, "headers");
op.add(Builder::method, JsonpDeserializer.stringDeserializer(), "method");
op.add(Builder::postProcessFunction, JsonpDeserializer.stringDeserializer(), "post_process_function");
op.add(Builder::preProcessFunction, JsonpDeserializer.stringDeserializer(), "pre_process_function");
op.add(Builder::requestBody, JsonpDeserializer.stringDeserializer(), "request_body");
op.add(Builder::url, JsonpDeserializer.stringDeserializer(), "url");
}
}
Loading
Loading