-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add Snapshot Create API #533
Add Snapshot Create API #533
Conversation
snapshot_create.go
Outdated
"net/url" | ||
"time" | ||
|
||
"github.com/olivere/elastic/uritemplates" |
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.
This must be "gopkg.in/olivere/elastic.v5/uritemplates"
. The generator need some polish, I'm sorry.
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.
No problem, the generator is pretty good 👍
Accepted *bool `json:"accepted"` | ||
|
||
// Snapshot is available when waitForCompletion is true. | ||
Snapshot *struct { |
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.
The *struct
, although valid, doesn't look that good. Does ES always send back the snapshot
? We have to look it up in the Java source. If it does, we should make it a normal struct
, not a pointer to a struct.
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.
No, ES does not send the snapshot
field when waitForCompletion
is false.
snapshot_create.go
Outdated
Snapshot *struct { | ||
Snapshot string `json:"snapshot"` | ||
UUID string `json:"uuid"` | ||
VersionID int `json:"version_id"` |
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.
Did you compare these fields with what ES really sends, or did you make an educated guess? I typically consult the Java source to see what fields (and their types) ES really sends and, more often than not, I find fields that are undocumented but sent anyway.
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.
On my previous commit I compared these field with what ES really sends (turning logging on), but today I made a new commit consulting the java source code.
snapshot_create.go
Outdated
StartTimeInMillis int64 `json:"start_time_in_millis"` | ||
EndTime time.Time `json:"end_time"` | ||
EndTimeInMillis int64 `json:"end_time_in_millis"` | ||
DurationInMillis int `json:"duration_in_millis"` |
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.
This e.g. should be int64
if StartTimeInMillis
is int64
as well.
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.
👍
snapshot_create.go
Outdated
EndTimeInMillis int64 `json:"end_time_in_millis"` | ||
DurationInMillis int `json:"duration_in_millis"` | ||
Failures []interface{} `json:"failures"` | ||
Shards struct { |
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.
There is a shardsInfo
in errors.go
that you can use here.
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.
👍
The PR is looking good. Can you please take a look at those comments, so I can merge in the next run. I'm off for vacation next week so it'll take a few more days, I'm afraid. |
Thanks @olivere, I looked at your comments and pushed some changes. |
It'll roll with 5.0.39. Thanks. |
Thanks @olivere, can I backport it to v3? |
@wedneyyuri Sure. That seems to be really easy. All you need to do is change some import paths. |
This PR adds support for Elasticsearch's snapshot create API.
Example program: