Skip to content

Commit

Permalink
[Backport 2.x] Re-generate client code using latest OpenSearch API sp…
Browse files Browse the repository at this point in the history
…ecification (2024-09-23) (opensearch-project#1113) (opensearch-project#1205)

* Re-generate client code using latest OpenSearch API specification (2024-09-23) (opensearch-project#1113)

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
(cherry picked from commit 230a92c)

* Regenerate tasks namespace (opensearch-project#1187)

* Fix codegen integer handling

Signed-off-by: Thomas Farr <tsfarr@amazon.com>

* Add failing tests

Signed-off-by: Thomas Farr <tsfarr@amazon.com>

* Begin re-generating `tasks.ListRequest` and `TaskExecutingNode`

renaming `State` to `TaskInfo`

Signed-off-by: Thomas Farr <tsfarr@amazon.com>

* Simplify client request methods

Signed-off-by: Thomas Farr <tsfarr@amazon.com>

* Re-generate _types.Retries

Signed-off-by: Thomas Farr <tsfarr@amazon.com>

* Handle types that are used in both abstract and concrete contexts

Signed-off-by: Thomas Farr <tsfarr@amazon.com>

* Re-generate tasks.ListResponse

Signed-off-by: Thomas Farr <tsfarr@amazon.com>

* Regenerate tasks.cancel

Signed-off-by: Thomas Farr <tsfarr@amazon.com>

* Regenerate tasks.get

Signed-off-by: Thomas Farr <tsfarr@amazon.com>

* spotless

Signed-off-by: Thomas Farr <tsfarr@amazon.com>

* Fixes

Signed-off-by: Thomas Farr <tsfarr@amazon.com>

---------

Signed-off-by: Thomas Farr <tsfarr@amazon.com>
(cherry picked from commit cb89246)

* Support new mechanism of defining deprecated enum variants in OpenAPI (opensearch-project#1198)

* Support new mechanism of defining deprecated enum variants in OpenAPI

Signed-off-by: Thomas Farr <tsfarr@amazon.com>

* Spotless

Signed-off-by: Thomas Farr <tsfarr@amazon.com>

---------

Signed-off-by: Thomas Farr <tsfarr@amazon.com>
(cherry picked from commit 432919c)

* Ensure codegen uptodate

Signed-off-by: Thomas Farr <tsfarr@amazon.com>

---------

Signed-off-by: Thomas Farr <tsfarr@amazon.com>
Co-authored-by: opensearch-trigger-bot[bot] <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com>
  • Loading branch information
Xtansia and opensearch-trigger-bot[bot] authored Sep 23, 2024
1 parent 9f2fbab commit f83cd4d
Show file tree
Hide file tree
Showing 54 changed files with 8,501 additions and 1,378 deletions.
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

0 comments on commit f83cd4d

Please sign in to comment.