forked from nl2go/hrobot-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rdns.go
45 lines (36 loc) · 823 Bytes
/
rdns.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
44
45
package client
import (
"encoding/json"
"fmt"
"github.com/cluster-api-provider-hcloud/hrobot-go/models"
)
func (c *Client) RDnsGetList() ([]models.Rdns, error) {
url := c.baseURL + "/rdns"
bytes, err := c.doGetRequest(url)
if err != nil {
return nil, err
}
var rdnsList []models.RdnsResponse
err = json.Unmarshal(bytes, &rdnsList)
if err != nil {
return nil, err
}
var data []models.Rdns
for _, rdns := range rdnsList {
data = append(data, rdns.Rdns)
}
return data, nil
}
func (c *Client) RDnsGet(ip string) (*models.Rdns, error) {
url := fmt.Sprintf(c.baseURL+"/rdns/%s", ip)
bytes, err := c.doGetRequest(url)
if err != nil {
return nil, err
}
var rDnsResp models.RdnsResponse
err = json.Unmarshal(bytes, &rDnsResp)
if err != nil {
return nil, err
}
return &rDnsResp.Rdns, nil
}