Skip to content

Commit

Permalink
feature: added SnapshotAllIndicesWithBodyParams function
Browse files Browse the repository at this point in the history
  • Loading branch information
sarwaan001 committed Dec 29, 2024
1 parent 0c26877 commit aef7e71
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions es.go
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,34 @@ func (c *Client) SnapshotAllIndices(repository string, snapshot string) error {
return err
}

func (c *Client) SnapshotAllIndicesWithBodyParams(repository string, snapshot string, bodyParams map[string]interface{}) error {
if repository == "" {
return errors.New("empty string for repository is not allowed")
}

if snapshot == "" {
return errors.New("empty string for snapshot is not allowed")
}

if bodyParams == nil {
return errors.New("no body params provided, please use SnapshotAllIndices Function instead")
}

parsedJson, parsingErr := json.Marshal(bodyParams)

if parsingErr != nil {
return parsingErr
}

agent := c.buildPutRequest(fmt.Sprintf("_snapshot/%s/%s", repository, snapshot)).
Set("Content-Type", "application/json").
Send(parsedJson)

_, err := handleErrWithBytes(agent)

return err
}

// Restore an index or indices on the cluster
//
// Use case: You want to restore a particular index or indices onto your cluster with a new name.
Expand Down

0 comments on commit aef7e71

Please sign in to comment.