-
Notifications
You must be signed in to change notification settings - Fork 4
Add support for ES REST API as generic commands #43
Conversation
Codecov Report
@@ Coverage Diff @@
## main #43 +/- ##
==========================================
+ Coverage 64.74% 65.54% +0.79%
==========================================
Files 21 28 +7
Lines 1268 1457 +189
==========================================
+ Hits 821 955 +134
- Misses 353 404 +51
- Partials 94 98 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Added curl, get, put, post, delete commands to execute appropriate REST Action. Added integration tests.
Since elasticsearch can support output format as json/yaml, allow user to add it as argument. if no value is passed, default by elasticsearch will be returned.
curl command accept a filter_path parameter that can be used to filter the response returned by Elasticsearch. This parameter takes a comma separated list of filters.
commands/curl.go
Outdated
//curlCommand is base command for Elasticsearch REST APIs. | ||
var curlCommand = &cobra.Command{ | ||
Use: curlCommandName, | ||
Short: "Manage elasticsearch core features", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Capitalize elasticsearch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack
commands/curl.go
Outdated
var curlCommand = &cobra.Command{ | ||
Use: curlCommandName, | ||
Short: "Manage elasticsearch core features", | ||
Long: "Use curl command to configure and access features directly", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rephrase: "Use the curl command to execute any REST API calls against the cluster."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack
var curlPutExample = ` | ||
# Create a knn index from mapping setting saved in file "knn-mapping.json" | ||
odfe-cli curl put --path "my-knn-index" \ | ||
--data "@some-location/knn-mapping.json" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiousity: is prefixing file input with @ a convention in another cli?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, usually there will be two different flags. This i borrowed from curl. Do you prefer as another flag "--data-file-path" something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is how curl does it, thats fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! This feature opens up many use cases for community to use CLI. Thanks for working on this.
Added gateway, controller to represent any REST API and execute.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.