Skip to content
This repository was archived by the owner on Apr 15, 2025. It is now read-only.

Commit 2f62b1b

Browse files
committed
Adding a license cluster command
1 parent 3dce9a2 commit 2f62b1b

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

es.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,3 +1802,24 @@ func (c *Client) RemoveIndexILMPolicy(index string) error {
18021802

18031803
return nil
18041804
}
1805+
1806+
// Function called LicenseCluster. This function takes a json document as a string which is the license to apply to the Elasticsearch cluster.
1807+
func (c *Client) LicenseCluster(license string) error {
1808+
// If the license is empty, return an error
1809+
if license == "" {
1810+
return errors.New("license is required")
1811+
}
1812+
1813+
// Build the request to apply the license to the cluster
1814+
agent := c.buildPutRequest("_license").
1815+
Set("Content-Type", "application/json").
1816+
Send(license)
1817+
1818+
// Execute the request
1819+
_, err := handleErrWithBytes(agent)
1820+
if err != nil {
1821+
return err
1822+
}
1823+
1824+
return nil
1825+
}

0 commit comments

Comments
 (0)