Skip to content

Commit

Permalink
Generate the ml namespace (opensearch-project#1158)
Browse files Browse the repository at this point in the history
* Generate ml.register_model_group

Signed-off-by: Thomas Farr <[email protected]>

* Start neural search sample

Signed-off-by: Thomas Farr <[email protected]>

* Re-generate ShardStatistics

Signed-off-by: Thomas Farr <[email protected]>

* Re-generate ShardFailure

Signed-off-by: Thomas Farr <[email protected]>

* Re-generate Result

Signed-off-by: Thomas Farr <[email protected]>

* Re-generate WriteResponseBase

Signed-off-by: Thomas Farr <[email protected]>

* Generate ml.delete_model_group

Signed-off-by: Thomas Farr <[email protected]>

* Generate ml.register_model

Signed-off-by: Thomas Farr <[email protected]>

* Exclude legacy license from ml namespace

Signed-off-by: Thomas Farr <[email protected]>

* Generate ml.get_task

Signed-off-by: Thomas Farr <[email protected]>

* Generate ml.delete_task

Signed-off-by: Thomas Farr <[email protected]>

* Generate ml.delete_model

Signed-off-by: Thomas Farr <[email protected]>

* Generate ml.deploy_model

Signed-off-by: Thomas Farr <[email protected]>

* Generate ml.undeploy_model

Signed-off-by: Thomas Farr <[email protected]>

* Complete neural search sample

Signed-off-by: Thomas Farr <[email protected]>

* Generate ml.get_model

Signed-off-by: Thomas Farr <[email protected]>

* Add changelog entry

Signed-off-by: Thomas Farr <[email protected]>

* note

Signed-off-by: Thomas Farr <[email protected]>

* Fix tests

Signed-off-by: Thomas Farr <[email protected]>

---------

Signed-off-by: Thomas Farr <[email protected]>
(cherry picked from commit c6e61e1)
  • Loading branch information
Xtansia committed Aug 26, 2024
1 parent 815c219 commit 0caa844
Show file tree
Hide file tree
Showing 29 changed files with 3,895 additions and 72 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [Unreleased 2.x]
### Added
- Adds `queryImage` (query_image) field to `NeuralQuery`, following definition in ([Neural Query](https://opensearch.org/docs/latest/query-dsl/specialized/neural/)) ([#1137](https://github.com/opensearch-project/opensearch-java/pull/1138))
- Adds `cancelAfterTimeInterval` to `SearchRequest` and `MsearchRequest` ([#1147](https://github.com/opensearch-project/opensearch-java/pull/1147))
- Added `queryImage` (query_image) field to `NeuralQuery`, following definition in ([Neural Query](https://opensearch.org/docs/latest/query-dsl/specialized/neural/)) ([#1137](https://github.com/opensearch-project/opensearch-java/pull/1138))
- Added `cancelAfterTimeInterval` to `SearchRequest` and `MsearchRequest` ([#1147](https://github.com/opensearch-project/opensearch-java/pull/1147))
- Added the `ml` namespace operations ([#1158](https://github.com/opensearch-project/opensearch-java/pull/1158))

### Dependencies
- Bumps `commons-logging:commons-logging` from 1.3.3 to 1.3.4
Expand Down
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.delete_model_group.Request

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

private final String modelGroupId;

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

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

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

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

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

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

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

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

return new DeleteModelGroupRequest(this);
}
}

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

/**
* Endpoint "{@code ml.delete_model_group}".
*/
public static final Endpoint<DeleteModelGroupRequest, DeleteModelGroupResponse, ErrorResponse> _ENDPOINT = new SimpleEndpoint<>(
// Request method
request -> "DELETE",
// 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,
DeleteModelGroupResponse._DESERIALIZER
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* 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.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.ObjectBuilderDeserializer;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.opensearch._types.WriteResponseBase;
import org.opensearch.client.util.ObjectBuilder;

// typedef: ml.delete_model_group.Response

@JsonpDeserializable
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class DeleteModelGroupResponse extends WriteResponseBase {

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

private DeleteModelGroupResponse(Builder builder) {
super(builder);
}

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

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

/**
* Builder for {@link DeleteModelGroupResponse}.
*/
public static class Builder extends WriteResponseBase.AbstractBuilder<Builder> implements ObjectBuilder<DeleteModelGroupResponse> {
@Override
protected Builder self() {
return this;
}

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

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

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

protected static void setupDeleteModelGroupResponseDeserializer(ObjectDeserializer<DeleteModelGroupResponse.Builder> op) {
WriteResponseBase.setupWriteResponseBaseDeserializer(op);
}
}
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.delete_model.Request

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

private final String modelId;

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

private DeleteModelRequest(Builder builder) {
this.modelId = ApiTypeHelper.requireNonNull(builder.modelId, this, "modelId");
}

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

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

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

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

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

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

return new DeleteModelRequest(this);
}
}

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

/**
* Endpoint "{@code ml.delete_model}".
*/
public static final Endpoint<DeleteModelRequest, DeleteModelResponse, ErrorResponse> _ENDPOINT = new SimpleEndpoint<>(
// Request method
request -> "DELETE",
// Request path
request -> {
StringBuilder buf = new StringBuilder();
buf.append("/_plugins/_ml/models/");
SimpleEndpoint.pathEncode(request.modelId, buf);
return buf.toString();
},
// Request parameters
SimpleEndpoint.emptyMap(),
SimpleEndpoint.emptyMap(),
false,
DeleteModelResponse._DESERIALIZER
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* 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.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.ObjectBuilderDeserializer;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.opensearch._types.WriteResponseBase;
import org.opensearch.client.util.ObjectBuilder;

// typedef: ml.delete_model.Response

@JsonpDeserializable
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class DeleteModelResponse extends WriteResponseBase {

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

private DeleteModelResponse(Builder builder) {
super(builder);
}

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

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

/**
* Builder for {@link DeleteModelResponse}.
*/
public static class Builder extends WriteResponseBase.AbstractBuilder<Builder> implements ObjectBuilder<DeleteModelResponse> {
@Override
protected Builder self() {
return this;
}

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

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

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

protected static void setupDeleteModelResponseDeserializer(ObjectDeserializer<DeleteModelResponse.Builder> op) {
WriteResponseBase.setupWriteResponseBaseDeserializer(op);
}
}
Loading

0 comments on commit 0caa844

Please sign in to comment.