forked from michaelklishin/rabbit-hole
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cluster.go
43 lines (35 loc) · 868 Bytes
/
cluster.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
}