/
gtm.go
57 lines (46 loc) · 1.11 KB
/
gtm.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
54
55
56
57
// Package gtm provides access to the Akamai GTM V1_4 APIs
//
// See: https://techdocs.akamai.com/gtm/reference/api
package gtm
import (
"errors"
"net/http"
"github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session"
)
var (
// ErrStructValidation is returned returned when given struct validation failed
ErrStructValidation = errors.New("struct validation")
)
type (
// GTM is the gtm api interface
GTM interface {
Domains
Properties
Datacenters
Resources
ASMaps
GeoMaps
CidrMaps
}
gtm struct {
session.Session
}
// Option defines a GTM option
Option func(*gtm)
// ClientFunc is a gtm client new method, this can used for mocking
ClientFunc func(sess session.Session, opts ...Option) GTM
)
// Client returns a new dns Client instance with the specified controller
func Client(sess session.Session, opts ...Option) GTM {
p := >m{
Session: sess,
}
for _, opt := range opts {
opt(p)
}
return p
}
// Exec overrides the session.Exec to add dns options
func (p *gtm) Exec(r *http.Request, out interface{}, in ...interface{}) (*http.Response, error) {
return p.Session.Exec(r, out, in...)
}