-
Notifications
You must be signed in to change notification settings - Fork 0
OpenSearch plugin - initial commit #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
291b28e
OpenSearch plugin - initial commit
richbenwell 1fe09dc
Fix fieldGroup visibility
richbenwell c60b132
Fix authMode default
richbenwell 9fb7911
Use visibility field instead of noMatch and add docs
richbenwell b9cd25c
Address Copilot PR review comments
richbenwell e080067
Remove trailing comma
richbenwell 2efb9c2
Fix length check
richbenwell 303e981
Remove whitespace
richbenwell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,6 @@ | ||
| ## Overview | ||
|
|
||
| Query OpenSearch databases using DSL. This plugin is primarily a wrapper around the `_search` API endpoint that allows for a range of queries. | ||
|
|
||
| See the [OpenSearch API docs](https://docs.opensearch.org/latest/api-reference/search-apis/search/) for more information. | ||
|
|
||
|
clarkd marked this conversation as resolved.
|
||
This file contains hidden or 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,28 @@ | ||
| { | ||
| "name": "indices", | ||
| "displayName": "Indices", | ||
| "baseDataSourceName": "httpRequestUnscoped", | ||
| "config": { | ||
| "httpMethod": "get", | ||
| "pagingConfig_mode": "none", | ||
| "pagingConfig_offset_base": 1, | ||
| "expandInnerObjects": true, | ||
| "endpointPath": "_cat/indices", | ||
|
richbenwell marked this conversation as resolved.
|
||
| "pathToData": "", | ||
| "getArgs": [], | ||
| "headers": [] | ||
|
richbenwell marked this conversation as resolved.
|
||
| }, | ||
| "timeframes": false, | ||
| "matches": "none", | ||
| "visibility": { | ||
| "type": "hidden" | ||
| }, | ||
| "metadata": [ | ||
| { | ||
| "name": "index", | ||
| "shape": "string", | ||
| "displayName": "Index", | ||
| "role": "value" | ||
| } | ||
| ] | ||
| } | ||
This file contains hidden or 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,32 @@ | ||
| if (data.aggregations && data.aggregations.length > 0) { | ||
|
richbenwell marked this conversation as resolved.
Outdated
|
||
|
|
||
| const agg = data.aggregations[Object.keys(data.aggregations).at(-1)]; // last aggregation to support pipelining | ||
|
|
||
| if(agg.buckets) { | ||
|
|
||
| result = agg.buckets; | ||
|
|
||
| } else if (agg.values) { | ||
|
|
||
| result = [agg.values]; | ||
|
|
||
| } else if (agg.value) { | ||
|
|
||
| result = [{ | ||
| value: agg.value | ||
| }]; | ||
|
|
||
| } else { | ||
|
|
||
| result = [agg]; | ||
|
|
||
| } | ||
|
|
||
| } else { | ||
|
|
||
| result = data.hits.hits.map(hit => hit._source); | ||
|
|
||
|
clarkd marked this conversation as resolved.
|
||
| } | ||
|
|
||
|
|
||
|
|
||
This file contains hidden or 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,50 @@ | ||
| { | ||
| "name": "search", | ||
| "displayName": "Search", | ||
|
clarkd marked this conversation as resolved.
|
||
| "baseDataSourceName": "httpRequestUnscoped", | ||
|
clarkd marked this conversation as resolved.
|
||
| "matches": "none", | ||
| "manualConfigApply": true, | ||
| "config": { | ||
| "httpMethod": "post", | ||
| "pagingConfig_mode": "none", | ||
| "pagingConfig_offset_base": 1, | ||
| "expandInnerObjects": true, | ||
| "endpointPath": "{{index}}/_search", | ||
| "postRequestScript": "search.js", | ||
| "getArgs": [], | ||
| "headers": [], | ||
| "postBody": "{{query}}" | ||
|
richbenwell marked this conversation as resolved.
|
||
| }, | ||
| "ui": [ | ||
| { | ||
| "name": "index", | ||
| "type": "autocomplete", | ||
| "label": "Index", | ||
| "validation": { | ||
| "required": true | ||
| }, | ||
| "placeholder": "Select index", | ||
| "isMulti": false, | ||
| "allowCustomValues": true, | ||
| "data": { | ||
| "source": "dataStream", | ||
| "dataStreamName": "indices" | ||
| } | ||
| }, | ||
| { | ||
| "name": "query", | ||
| "type": "json", | ||
| "defaultValue": { | ||
| "size": 100 | ||
| }, | ||
| "label": "Query body", | ||
| "help": "The Query DSL JSON. See [OpenSearch API docs](https://docs.opensearch.org/latest/api-reference/search-apis/search/#request-body).", | ||
|
clarkd marked this conversation as resolved.
|
||
| "validation": { | ||
| "required": true | ||
| } | ||
| } | ||
| ], | ||
| "supportsNoneTimeframe": true, | ||
| "requiresParameterTimeframe": true, | ||
| "defaultTimeframe": "none" | ||
| } | ||
This file contains hidden or 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,21 @@ | ||
| # Configuration | ||
|
|
||
| ## Instance URL | ||
|
clarkd marked this conversation as resolved.
|
||
|
|
||
| The base URL of your OpenSearch database. | ||
|
|
||
| For example: | ||
| `https://<your-opensearch-host>:9200` | ||
|
|
||
| Do *not* include the `/api` path. | ||
|
|
||
| ## Authentication | ||
|
richbenwell marked this conversation as resolved.
|
||
|
|
||
| The data source supports basic (username and password) or anonymous authentication. | ||
|
|
||
| If using basic authentication, ensure the user only has read permissions. | ||
|
|
||
| If using anonymous, ensure the endpoint is secured in some other form. | ||
|
|
||
| If you need to whitelist the IP addresses for SquaredUp these can be found on the [Data Security](https://docs.squaredup.com/reference/security/data-security) KB article. | ||
|
|
||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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,45 @@ | ||
| { | ||
| "name": "open-search", | ||
| "displayName": "OpenSearch", | ||
| "version": "1.0.3", | ||
|
clarkd marked this conversation as resolved.
|
||
| "author": { | ||
| "name": "SquaredUp Labs", | ||
| "type": "labs" | ||
| }, | ||
|
clarkd marked this conversation as resolved.
clarkd marked this conversation as resolved.
|
||
| "description": "Query OpenSearch databases using DSL.", | ||
|
clarkd marked this conversation as resolved.
|
||
| "category": "Database", | ||
| "type": "cloud", | ||
| "restrictedToPlatforms": [], | ||
| "importNotSupported": true, | ||
| "schemaVersion": "2.0", | ||
| "base": { | ||
|
richbenwell marked this conversation as resolved.
|
||
| "plugin": "WebAPI", | ||
| "majorVersion": "1", | ||
| "config": { | ||
| "authMode": "{{authMode}}", | ||
| "basicAuthUsername": "{{basicAuthUsername}}", | ||
| "basicAuthPassword": "{{basicAuthPassword}}", | ||
| "queryArgs": [], | ||
| "headers": [ | ||
| { | ||
| "key": "Content-Type", | ||
| "value": "application/json" | ||
| } | ||
| ], | ||
| "baseUrl": "{{instanceUrl}}", | ||
| "ignoreCertificateErrors": "{{ignoreCertificateErrors}}" | ||
| } | ||
| }, | ||
| "links": [ | ||
| { | ||
| "category": "documentation", | ||
| "url": "https://github.com/squaredup/plugins/blob/main/plugins/OpenSearch/v1/docs/setup.md", | ||
| "label": "Help adding this plugin" | ||
|
clarkd marked this conversation as resolved.
|
||
| }, | ||
| { | ||
| "category": "source", | ||
| "url": "https://github.com/squaredup/plugins/tree/main/plugins/OpenSearch/v1", | ||
| "label": "Repository" | ||
| } | ||
| ] | ||
| } | ||
This file contains hidden or 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,58 @@ | ||
| [ | ||
| { | ||
| "type": "text", | ||
| "name": "instanceUrl", | ||
| "label": "Instance URL", | ||
|
clarkd marked this conversation as resolved.
|
||
| "validation": { "required": true }, | ||
| "placeholder": "Enter the OpenSearch URL" | ||
|
clarkd marked this conversation as resolved.
|
||
| }, | ||
| { | ||
| "name": "authMode", | ||
| "type": "radio", | ||
| "label": "Authentication", | ||
| "help": "**Basic:** Authenticate with username and password. \n**Anonymous access:** No authentication required", | ||
|
clarkd marked this conversation as resolved.
|
||
| "defaultValue": "basic", | ||
| "validation": { | ||
| "required": true | ||
| }, | ||
| "options": [ | ||
| { | ||
| "label": "Basic", | ||
| "value": "basic" | ||
| }, | ||
| { | ||
| "label": "Anonymous access", | ||
| "value": "none" | ||
| } | ||
|
|
||
| ] | ||
| }, | ||
|
clarkd marked this conversation as resolved.
|
||
| { | ||
| "type": "fieldGroup", | ||
| "visible": { | ||
| "authMode": "basic" | ||
| }, | ||
| "fields": [ | ||
| { | ||
| "type": "text", | ||
| "name": "basicAuthUsername", | ||
| "label": "Username", | ||
| "validation": { "required": true }, | ||
| "placeholder": "Enter a username" | ||
| }, | ||
| { | ||
| "type": "password", | ||
| "name": "basicAuthPassword", | ||
| "label": "Password", | ||
| "validation": { "required": true }, | ||
| "placeholder": "Enter a password" | ||
|
richbenwell marked this conversation as resolved.
|
||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "type": "checkbox", | ||
| "name": "ignoreCertificateErrors", | ||
| "label": "Ignore certificate errors", | ||
| "help": "Ignore certificate errors when connecting to an OpenSearch instance with a self-signed certificate" | ||
| } | ||
| ] | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.