-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature/extensions] Provide Extension API to OpenSearch (#4100)
* Provide Extension API to OpenSearch Signed-off-by: Daniel Widdis <[email protected]> * Add tests Signed-off-by: Daniel Widdis <[email protected]> * Add javadocs Signed-off-by: Daniel Widdis <[email protected]> * Add parsing of API requests Signed-off-by: Daniel Widdis <[email protected]> * Tweak API parsing for more flexible user formatting Signed-off-by: Daniel Widdis <[email protected]> * Remove forbidden toUpperCase usage Signed-off-by: Daniel Widdis <[email protected]> * Fix failing test as we now register four handlers Signed-off-by: Daniel Widdis <[email protected]> * Rename Api to RestApi Signed-off-by: Daniel Widdis <[email protected]> * Fix errors in previous merge conflict resolution Signed-off-by: Daniel Widdis <[email protected]> * Rename RestApi to RestActions Signed-off-by: Daniel Widdis <[email protected]> * Fix tests to fail on the correct wrong thing Signed-off-by: Daniel Widdis <[email protected]> * More verbose variable name Signed-off-by: Daniel Widdis <[email protected]> * Fix license header Signed-off-by: Daniel Widdis <[email protected]> * Fixing NodeGatewayStartedShards bwc (de)serialization issues (#4258) Signed-off-by: Andriy Redko <[email protected]> Signed-off-by: Andriy Redko <[email protected]> * Fixing NodeGatewayStartedShards bwc (de)serialization issues (#4258) Signed-off-by: Andriy Redko <[email protected]> Signed-off-by: Andriy Redko <[email protected]> * Fix tests to account for TotalHits uncertainty Signed-off-by: Daniel Widdis <[email protected]> Signed-off-by: Daniel Widdis <[email protected]> Signed-off-by: Andriy Redko <[email protected]> Co-authored-by: Andriy Redko <[email protected]>
- Loading branch information
Showing
7 changed files
with
327 additions
and
80 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
server/src/main/java/org/opensearch/extensions/RegisterRestActionsRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package org.opensearch.extensions; | ||
|
||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
import org.opensearch.transport.TransportRequest; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Request to register extension REST actions | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class RegisterRestActionsRequest extends TransportRequest { | ||
private String nodeId; | ||
private List<String> restActions; | ||
|
||
public RegisterRestActionsRequest(String nodeId, List<String> restActions) { | ||
this.nodeId = nodeId; | ||
this.restActions = new ArrayList<>(restActions); | ||
} | ||
|
||
public RegisterRestActionsRequest(StreamInput in) throws IOException { | ||
super(in); | ||
nodeId = in.readString(); | ||
restActions = in.readStringList(); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeString(nodeId); | ||
out.writeStringCollection(restActions); | ||
} | ||
|
||
public String getNodeId() { | ||
return nodeId; | ||
} | ||
|
||
public List<String> getRestActions() { | ||
return new ArrayList<>(restActions); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "RestActionsRequest{nodeId=" + nodeId + ", restActions=" + restActions + "}"; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) return true; | ||
if (obj == null || getClass() != obj.getClass()) return false; | ||
RegisterRestActionsRequest that = (RegisterRestActionsRequest) obj; | ||
return Objects.equals(nodeId, that.nodeId) && Objects.equals(restActions, that.restActions); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(nodeId, restActions); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
server/src/main/java/org/opensearch/extensions/RegisterRestActionsResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package org.opensearch.extensions; | ||
|
||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
import org.opensearch.transport.TransportResponse; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Response to register REST Actions request. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class RegisterRestActionsResponse extends TransportResponse { | ||
private String response; | ||
|
||
public RegisterRestActionsResponse(String response) { | ||
this.response = response; | ||
} | ||
|
||
public RegisterRestActionsResponse(StreamInput in) throws IOException { | ||
response = in.readString(); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeString(response); | ||
} | ||
|
||
public String getResponse() { | ||
return response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.