/
dns.go
53 lines (42 loc) · 1.03 KB
/
dns.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
50
51
52
53
// Package dns provides access to the Akamai DNS V2 APIs
package dns
import (
"errors"
"net/http"
"github.com/akamai/AkamaiOPEN-edgegrid-golang/v3/pkg/session"
)
var (
// ErrStructValidation is returned returned when given struct validation failed
ErrStructValidation = errors.New("struct validation")
)
type (
// DNS is the dns api interface
DNS interface {
Zones
TSIGKeys
Authorities
Records
RecordSets
}
dns struct {
session.Session
}
// Option defines a DNS option
Option func(*dns)
// ClientFunc is a dns client new method, this can used for mocking
ClientFunc func(sess session.Session, opts ...Option) DNS
)
// Client returns a new dns Client instance with the specified controller
func Client(sess session.Session, opts ...Option) DNS {
p := &dns{
Session: sess,
}
for _, opt := range opts {
opt(p)
}
return p
}
// Exec overrides the session.Exec to add dns options
func (p *dns) Exec(r *http.Request, out interface{}, in ...interface{}) (*http.Response, error) {
return p.Session.Exec(r, out, in...)
}