From 811c7a81334aec5f8932fea9c827b6169464fc9f Mon Sep 17 00:00:00 2001 From: Jonas-Taha El Sesiy Date: Wed, 10 Nov 2021 18:10:15 +0100 Subject: [PATCH] Add PutAutoPilotRaftConfiguration to api (#12428) --- api/sys_raft.go | 19 +++++++++++++++++++ changelog/12428.txt | 3 +++ 2 files changed, 22 insertions(+) create mode 100644 changelog/12428.txt diff --git a/api/sys_raft.go b/api/sys_raft.go index 043a69801..cbf3a2020 100644 --- a/api/sys_raft.go +++ b/api/sys_raft.go @@ -368,3 +368,22 @@ func (c *Sys) RaftAutopilotConfiguration() (*AutopilotConfig, error) { return &result, err } + +// PutRaftAutopilotConfiguration allows modifying the raft autopilot configuration +func (c *Sys) PutRaftAutopilotConfiguration(opts *AutopilotConfig) error { + r := c.c.NewRequest("POST", "/v1/sys/storage/raft/autopilot/configuration") + + if err := r.SetJSONBody(opts); err != nil { + return err + } + + ctx, cancelFunc := context.WithCancel(context.Background()) + defer cancelFunc() + resp, err := c.c.RawRequestWithContext(ctx, r) + if err != nil { + return err + } + defer resp.Body.Close() + + return nil +} diff --git a/changelog/12428.txt b/changelog/12428.txt new file mode 100644 index 000000000..8daeb8acf --- /dev/null +++ b/changelog/12428.txt @@ -0,0 +1,3 @@ +```release-note:improvement +api: add api method for modifying raft autopilot configuration +```