Skip to content
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

Implement DeleteSnapshot and DeleteSnapshotRepository #277

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions lib/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,46 @@ func (c *Conn) getSnapshots(repository, name string, args map[string]interface{}

return retval, nil
}

// DeleteSnapshotRepository deletes a snapshot repository. When a repository is deleted, Elasticsearch
// only removes the reference to the location where the repository is storing the snapshots.
// The snapshots themselves are left untouched and in place.
// http://www.elastic.co/guide/en/elasticsearch/reference/1.3/modules-snapshots.html
func (c *Conn) DeleteSnapshotRepository(repository string) (BaseResponse, error) {
var url string
var retval BaseResponse
url = fmt.Sprintf("/_snapshot/%s", repository)
body, err := c.DoCommand("DELETE", url, nil, nil)
if err != nil {
return retval, err
}
if err == nil {
jsonErr := json.Unmarshal(body, &retval)
if jsonErr != nil {
return retval, jsonErr
}
}

return retval, nil
}

// DeleteSnapshot deletes a snapshot from a repository. Elasticsearch deletes all files that are
// associated with the deleted snapshot and not used by any other snapshots.
// http://www.elastic.co/guide/en/elasticsearch/reference/1.3/modules-snapshots.html
func (c *Conn) DeleteSnapshot(repository, name string) (BaseResponse, error) {
var url string
var retval BaseResponse
url = fmt.Sprintf("/_snapshot/%s/%s", repository, name)
body, err := c.DoCommand("DELETE", url, nil, nil)
if err != nil {
return retval, err
}
if err == nil {
jsonErr := json.Unmarshal(body, &retval)
if jsonErr != nil {
return retval, jsonErr
}
}

return retval, nil
}