Skip to content

Commit

Permalink
Generate ml.get_model
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed Aug 26, 2024
1 parent ee7b226 commit c7649e8
Show file tree
Hide file tree
Showing 8 changed files with 481 additions and 76 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* 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 java.util.function.Function;
import javax.annotation.Generated;
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;

// typedef: ml.get_model_group.Request

/**
* Retrieves a model group.
*/
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class GetModelGroupRequest extends RequestBase {

private final String modelGroupId;

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

private GetModelGroupRequest(Builder builder) {
this.modelGroupId = ApiTypeHelper.requireNonNull(builder.modelGroupId, this, "modelGroupId");
}

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

/**
* Required - API name: {@code model_group_id}
*/
public final String modelGroupId() {
return this.modelGroupId;
}

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

/**
* Builder for {@link GetModelGroupRequest}.
*/
public static class Builder extends ObjectBuilderBase implements ObjectBuilder<GetModelGroupRequest> {
private String modelGroupId;

/**
* Required - API name: {@code model_group_id}
*/
public final Builder modelGroupId(String value) {
this.modelGroupId = value;
return this;
}

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

return new GetModelGroupRequest(this);
}
}

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

/**
* Endpoint "{@code ml.get_model_group}".
*/
public static final Endpoint<GetModelGroupRequest, GetModelGroupResponse, ErrorResponse> _ENDPOINT = new SimpleEndpoint<>(
// Request method
request -> "GET",
// Request path
request -> {
StringBuilder buf = new StringBuilder();
buf.append("/_plugins/_ml/model_groups/");
SimpleEndpoint.pathEncode(request.modelGroupId, buf);
return buf.toString();
},
// Request parameters
SimpleEndpoint.emptyMap(),
SimpleEndpoint.emptyMap(),
false,
GetModelGroupResponse._DESERIALIZER
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,258 @@
/*
* 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.ApiTypeHelper;
import org.opensearch.client.util.ObjectBuilder;
import org.opensearch.client.util.ObjectBuilderBase;

// typedef: ml.get_model_group.Response

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

private final String access;

@Nullable
private final Long createdTime;

private final String description;

@Nullable
private final Long lastUpdatedTime;

private final int latestVersion;

private final String name;

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

private GetModelGroupResponse(Builder builder) {
this.access = ApiTypeHelper.requireNonNull(builder.access, this, "access");
this.createdTime = builder.createdTime;
this.description = ApiTypeHelper.requireNonNull(builder.description, this, "description");
this.lastUpdatedTime = builder.lastUpdatedTime;
this.latestVersion = ApiTypeHelper.requireNonNull(builder.latestVersion, this, "latestVersion");
this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name");
}

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

/**
* Required - The model group access.
* <p>
* API name: {@code access}
* </p>
*/
public final String access() {
return this.access;
}

/**
* API name: {@code created_time}
*/
@Nullable
public final Long createdTime() {
return this.createdTime;
}

/**
* Required - The model group description.
* <p>
* API name: {@code description}
* </p>
*/
public final String description() {
return this.description;
}

/**
* API name: {@code last_updated_time}
*/
@Nullable
public final Long lastUpdatedTime() {
return this.lastUpdatedTime;
}

/**
* Required - The latest version.
* <p>
* API name: {@code latest_version}
* </p>
*/
public final int latestVersion() {
return this.latestVersion;
}

/**
* Required - The model group name.
* <p>
* API name: {@code name}
* </p>
*/
public final String name() {
return this.name;
}

/**
* 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) {
generator.writeKey("access");
generator.write(this.access);

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

generator.writeKey("description");
generator.write(this.description);

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

generator.writeKey("latest_version");
generator.write(this.latestVersion);

generator.writeKey("name");
generator.write(this.name);
}

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

/**
* Builder for {@link GetModelGroupResponse}.
*/
public static class Builder extends ObjectBuilderBase implements ObjectBuilder<GetModelGroupResponse> {
private String access;
@Nullable
private Long createdTime;
private String description;
@Nullable
private Long lastUpdatedTime;
private Integer latestVersion;
private String name;

/**
* Required - The model group access.
* <p>
* API name: {@code access}
* </p>
*/
public final Builder access(String value) {
this.access = value;
return this;
}

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

/**
* Required - The model group description.
* <p>
* API name: {@code description}
* </p>
*/
public final Builder description(String value) {
this.description = value;
return this;
}

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

/**
* Required - The latest version.
* <p>
* API name: {@code latest_version}
* </p>
*/
public final Builder latestVersion(int value) {
this.latestVersion = value;
return this;
}

/**
* Required - The model group name.
* <p>
* API name: {@code name}
* </p>
*/
public final Builder name(String value) {
this.name = value;
return this;
}

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

return new GetModelGroupResponse(this);
}
}
// ---------------------------------------------------------------------------------------------

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

protected static void setupGetModelGroupResponseDeserializer(ObjectDeserializer<GetModelGroupResponse.Builder> op) {
op.add(Builder::access, JsonpDeserializer.stringDeserializer(), "access");
op.add(Builder::createdTime, JsonpDeserializer.longDeserializer(), "created_time");
op.add(Builder::description, JsonpDeserializer.stringDeserializer(), "description");
op.add(Builder::lastUpdatedTime, JsonpDeserializer.longDeserializer(), "last_updated_time");
op.add(Builder::latestVersion, JsonpDeserializer.integerDeserializer(), "latest_version");
op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,32 @@ public final CompletableFuture<DeployModelResponse> deployModel(
return deployModel(fn.apply(new DeployModelRequest.Builder()).build());
}

// ----- Endpoint: ml.get_model_group

/**
* Retrieves a model group.
*/
public CompletableFuture<GetModelGroupResponse> getModelGroup(GetModelGroupRequest request) throws IOException, OpenSearchException {
@SuppressWarnings("unchecked")
JsonEndpoint<GetModelGroupRequest, GetModelGroupResponse, ErrorResponse> endpoint = (JsonEndpoint<
GetModelGroupRequest,
GetModelGroupResponse,
ErrorResponse>) GetModelGroupRequest._ENDPOINT;

return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}

/**
* Retrieves a model group.
*
* @param fn a function that initializes a builder to create the {@link GetModelGroupRequest}
*/
public final CompletableFuture<GetModelGroupResponse> getModelGroup(
Function<GetModelGroupRequest.Builder, ObjectBuilder<GetModelGroupRequest>> fn
) throws IOException, OpenSearchException {
return getModelGroup(fn.apply(new GetModelGroupRequest.Builder()).build());
}

// ----- Endpoint: ml.get_task

/**
Expand Down
Loading

0 comments on commit c7649e8

Please sign in to comment.