forked from AlaskaAirlines/go-infoblox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecord_srv.go
49 lines (44 loc) · 1.26 KB
/
record_srv.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
46
47
48
49
package infoblox
import "fmt"
// RecordSrv returns the SRV record resource
func (c *Client) RecordSrv() *Resource {
return &Resource{
conn: c,
wapiObject: "record:srv",
}
}
// RecordSrvObject defines the SRV record object's fields
type RecordSrvObject struct {
Object
Comment string `json:"comment,omitempty"`
Name string `json:"name,omitempty"`
Target string `json:"target,omitempty"`
Port int `json:"port,omitempty"`
Priority int `json:"priority,omitempty"`
Weight int `json:"weight,omitempty"`
Pref int `json:"pref,omitempty"`
Ttl int `json:"ttl,omitempty"`
View string `json:"view,omitempty"`
}
// RecordSrvObject instantiates an SRV record object with a WAPI ref
func (c *Client) RecordSrvObject(ref string) *RecordSrvObject {
a := RecordSrvObject{}
a.Object = Object{
Ref: ref,
r: c.RecordSrv(),
}
return &a
}
// GetRecordSrv fetches an SRV record from the Infoblox WAPI by its ref
func (c *Client) GetRecordSrv(ref string, opts *Options) (*RecordSrvObject, error) {
resp, err := c.RecordSrvObject(ref).get(opts)
if err != nil {
return nil, fmt.Errorf("Could not get created SRV record: %s", err)
}
var out RecordSrvObject
err = resp.Parse(&out)
if err != nil {
return nil, err
}
return &out, nil
}