/* * 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. * * Modifications Copyright OpenSearch Contributors. See * GitHub history for details. */ package org.opensearch.ad.transport; import static org.opensearch.action.ValidateActions.addValidationError; import java.io.IOException; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.ad.constant.ADCommonMessages; import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; public class DeleteAnomalyDetectorRequest extends ActionRequest { private String detectorID; public DeleteAnomalyDetectorRequest(StreamInput in) throws IOException { super(in); this.detectorID = in.readString(); } public DeleteAnomalyDetectorRequest(String detectorID) { super(); this.detectorID = detectorID; } public String getDetectorID() { return detectorID; } @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeString(detectorID); } @Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (Strings.isEmpty(detectorID)) { validationException = addValidationError(ADCommonMessages.AD_ID_MISSING_MSG, validationException); } return validationException; } }