b589fbfbd9
* ci: switch to go1.12.12 on machine executors - This brings in recent ci changes from the release/1.2.x branch. * go mod vendor * ci: remove ent build tags * ci: fix gopath * go mod vendor * ci: ensure yarn install * ci: add debug commands * ci: debugging * ci: increment yarn cache; remove debugging * ci: remove redundant yarn install
44 lines
868 B
Go
44 lines
868 B
Go
package rabbithole
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
// ClusterName represents a RabbitMQ cluster name (identifier).
|
|
type ClusterName struct {
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
// GetClusterName returns current cluster name.
|
|
func (c *Client) GetClusterName() (rec *ClusterName, err error) {
|
|
req, err := newGETRequest(c, "cluster-name/")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if err = executeAndParseRequest(c, req, &rec); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return rec, nil
|
|
}
|
|
|
|
// SetClusterName sets cluster name.
|
|
func (c *Client) SetClusterName(cn ClusterName) (res *http.Response, err error) {
|
|
body, err := json.Marshal(cn)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req, err := newRequestWithBody(c, "PUT", "cluster-name", body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if res, err = executeRequest(c, req); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return res, nil
|
|
}
|