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