github.com/akamai/AkamaiOPEN-edgegrid-golang/v5@v5.0.0/pkg/gtm/gtm.go (about) 1 // Package gtm provides access to the Akamai GTM V1_4 APIs 2 // 3 // See: https://techdocs.akamai.com/gtm/reference/api 4 package gtm 5 6 import ( 7 "errors" 8 "net/http" 9 10 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v5/pkg/session" 11 ) 12 13 var ( 14 // ErrStructValidation is returned returned when given struct validation failed 15 ErrStructValidation = errors.New("struct validation") 16 ) 17 18 type ( 19 // GTM is the gtm api interface 20 GTM interface { 21 Domains 22 Properties 23 Datacenters 24 Resources 25 ASMaps 26 GeoMaps 27 CidrMaps 28 } 29 30 gtm struct { 31 session.Session 32 } 33 34 // Option defines a GTM option 35 Option func(*gtm) 36 37 // ClientFunc is a gtm client new method, this can used for mocking 38 ClientFunc func(sess session.Session, opts ...Option) GTM 39 ) 40 41 // Client returns a new dns Client instance with the specified controller 42 func Client(sess session.Session, opts ...Option) GTM { 43 p := >m{ 44 Session: sess, 45 } 46 47 for _, opt := range opts { 48 opt(p) 49 } 50 return p 51 } 52 53 // Exec overrides the session.Exec to add dns options 54 func (p *gtm) Exec(r *http.Request, out interface{}, in ...interface{}) (*http.Response, error) { 55 56 return p.Session.Exec(r, out, in...) 57 }