github.com/ravendb/ravendb-go-client@v0.0.0-20240229102137-4474ee7aa0fa/serverwide/operations/operation_demote_cluster_node.go (about) 1 package operations 2 3 import ( 4 "encoding/json" 5 "github.com/ravendb/ravendb-go-client" 6 "net/http" 7 ) 8 9 type OperationDemoteClusterNode struct { 10 Node string `json:"Node"` 11 } 12 13 func (operation *OperationDemoteClusterNode) GetCommand(conventions *ravendb.DocumentConventions) (ravendb.RavenCommand, error) { 14 return &demoteNodeCommand{ 15 RaftCommandBase: ravendb.RaftCommandBase{ 16 RavenCommandBase: ravendb.RavenCommandBase{ 17 ResponseType: ravendb.RavenCommandResponseTypeObject, 18 }, 19 }, 20 parent: operation, 21 }, nil 22 } 23 24 type demoteNodeCommand struct { 25 ravendb.RaftCommandBase 26 parent *OperationDemoteClusterNode 27 } 28 29 func (c *demoteNodeCommand) CreateRequest(node *ravendb.ServerNode) (*http.Request, error) { 30 url := node.URL + "/admin/cluster/demote?nodeTag=" + c.parent.Node 31 return http.NewRequest(http.MethodPost, url, nil) 32 } 33 34 func (c *demoteNodeCommand) SetResponse(response []byte, fromCache bool) error { 35 return json.Unmarshal(response, c.parent) 36 }