Skip to content

Commit

Permalink
Adding a license cluster command
Browse files Browse the repository at this point in the history
  • Loading branch information
dtaivpp committed Nov 7, 2024
1 parent 3dce9a2 commit 2f62b1b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions es.go
Original file line number Diff line number Diff line change
Expand Up @@ -1802,3 +1802,24 @@ func (c *Client) RemoveIndexILMPolicy(index string) error {

return nil
}

// Function called LicenseCluster. This function takes a json document as a string which is the license to apply to the Elasticsearch cluster.
func (c *Client) LicenseCluster(license string) error {
// If the license is empty, return an error
if license == "" {
return errors.New("license is required")
}

// Build the request to apply the license to the cluster
agent := c.buildPutRequest("_license").
Set("Content-Type", "application/json").
Send(license)

// Execute the request
_, err := handleErrWithBytes(agent)
if err != nil {
return err
}

return nil
}

0 comments on commit 2f62b1b

Please sign in to comment.