Skip to content

Commit

Permalink
Use instructions from #11844 to run the plugin.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Jan 11, 2024
1 parent 48221f7 commit 5cae02a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
44 changes: 35 additions & 9 deletions plugins/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ A plugin that returns the OpenSearch API in the OpenAPI format.

### Build and Test

```sh
./gradlew :plugins:api:build
```

You can run various test suites individually.

```sh
./gradlew :plugins:api:test # unit tests
./gradlew :plugins:api:integTest # integration tests
Expand All @@ -12,25 +18,45 @@ A plugin that returns the OpenSearch API in the OpenAPI format.

### Run

Modify `gradle/run.gradle`.
When you run OpenSearch with `./gradlew run -PinstalledPlugins="['api']"` you should see the plugin loaded in the logs.

```
[2023-09-27T08:35:48,627][INFO ][o.o.p.PluginsService] [runTask-0] loaded plugin [api]
```

Alternately you can modify `gradle/run.gradle`.

```gradle
testClusters {
runTask {
testDistribution = 'archive'
plugin(':plugins:api')
}
}
```

When you run OpenSearch with `./gradlew run` you should see the plugin loaded in the logs.

```
[2023-09-27T08:35:48,627][INFO ][o.o.p.PluginsService] [runTask-0] loaded plugin [api]
```

### Test
### Try

```sh
$ curl http://localhost:9200/_plugins/api
```

Returns an OpenAPI spec.

```json
{
"openapi": "3.0.1",
"info": {
"title": "opensearch",
"description": "The OpenSearch Project: https://opensearch.org/",
"version": "3.0.0-SNAPSHOT"
},
"paths": {
"/_nodes": {
"get": {}
},
"/_cluster/state/:metric": {
"get": {}
},
...
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.xcontent.ToXContentObject;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.core.xcontent.XContentParser;
import org.opensearch.rest.RestController;

import java.io.IOException;
import java.util.Objects;

public class APIResponse extends ActionResponse implements ToXContentObject {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@

import org.apache.hc.core5.http.ParseException;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.opensearch.Version;
import org.opensearch.client.Request;
import org.opensearch.client.Response;
import org.opensearch.common.xcontent.json.JsonXContent;
import org.opensearch.plugin.api.action.APIResponse;
import org.opensearch.plugins.Plugin;
import org.opensearch.test.OpenSearchIntegTestCase;

Expand Down

0 comments on commit 5cae02a

Please sign in to comment.