diff --git a/src/main/kotlin/org/opensearch/indexmanagement/transform/action/start/StartTransformRequest.kt b/src/main/kotlin/org/opensearch/indexmanagement/transform/action/start/StartTransformRequest.kt index a6514c6df..4846c1283 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/transform/action/start/StartTransformRequest.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/transform/action/start/StartTransformRequest.kt @@ -5,24 +5,30 @@ package org.opensearch.indexmanagement.transform.action.start +import org.opensearch.action.ActionRequest import org.opensearch.action.ActionRequestValidationException import org.opensearch.action.ValidateActions.addValidationError -import org.opensearch.action.update.UpdateRequest import org.opensearch.core.common.io.stream.StreamInput import org.opensearch.core.common.io.stream.StreamOutput import java.io.IOException -class StartTransformRequest : UpdateRequest { +class StartTransformRequest : ActionRequest { + + val id: String + get() = field + @Throws(IOException::class) - constructor(sin: StreamInput) : super(sin) + constructor(sin: StreamInput) : super(sin) { + this.id = sin.readString() + } constructor(id: String) { - super.id(id) + this.id = id } override fun validate(): ActionRequestValidationException? { var validationException: ActionRequestValidationException? = null - if (super.id().isEmpty()) { + if (this.id.isEmpty()) { validationException = addValidationError("id is missing", validationException) } return validationException diff --git a/src/main/kotlin/org/opensearch/indexmanagement/transform/action/start/TransportStartTransformAction.kt b/src/main/kotlin/org/opensearch/indexmanagement/transform/action/start/TransportStartTransformAction.kt index b69187d89..3a2c21044 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/transform/action/start/TransportStartTransformAction.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/transform/action/start/TransportStartTransformAction.kt @@ -68,7 +68,7 @@ constructor( ConfigConstants.OPENSEARCH_SECURITY_USER_INFO_THREAD_CONTEXT, )}", ) - val getRequest = GetRequest(INDEX_MANAGEMENT_INDEX, request.id()) + val getRequest = GetRequest(INDEX_MANAGEMENT_INDEX, request.id) val user = buildUser(client.threadPool().threadContext) client.threadPool().threadContext.stashContext().use { client.get( @@ -117,7 +117,8 @@ constructor( actionListener: ActionListener, ) { val now = Instant.now().toEpochMilli() - request.index(INDEX_MANAGEMENT_INDEX).doc( + val updateReq = UpdateRequest(INDEX_MANAGEMENT_INDEX, request.id) + updateReq.doc( mapOf( Transform.TRANSFORM_TYPE to mapOf( @@ -127,7 +128,7 @@ constructor( ), ) client.update( - request, + updateReq, object : ActionListener { override fun onResponse(response: UpdateResponse) { if (response.result == DocWriteResponse.Result.UPDATED) { diff --git a/src/test/kotlin/org/opensearch/indexmanagement/transform/action/RequestTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/transform/action/RequestTests.kt index 540fd6476..1365aa631 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/transform/action/RequestTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/transform/action/RequestTests.kt @@ -152,12 +152,12 @@ class RequestTests : OpenSearchTestCase() { fun `test start transform request`() { val id = "some_id" - val req = StartTransformRequest(id).index(INDEX_MANAGEMENT_INDEX) + val req = UpdateRequest(INDEX_MANAGEMENT_INDEX, id) val out = BytesStreamOutput().apply { req.writeTo(this) } val streamedReq = StartTransformRequest(buildStreamInputForTransforms(out)) - assertEquals(id, streamedReq.id()) + assertEquals(id, streamedReq.id) } fun `test stop transform request`() {