github.com/akamai/AkamaiOPEN-edgegrid-golang/v5@v5.0.0/pkg/hapi/hapi.go (about) 1 // Package hapi provides access to the Akamai Edge Hostnames APIs 2 // 3 // See: https://techdocs.akamai.com/edge-hostnames/reference/api 4 package hapi 5 6 import ( 7 "errors" 8 9 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v5/pkg/session" 10 ) 11 12 var ( 13 // ErrStructValidation is returned when given struct validation failed 14 ErrStructValidation = errors.New("struct validation") 15 ) 16 17 type ( 18 // HAPI is the hapi api interface 19 HAPI interface { 20 EdgeHostnames 21 } 22 23 hapi struct { 24 session.Session 25 } 26 27 // Option defines a HAPI option 28 Option func(*hapi) 29 30 // ClientFunc is a hapi client new method, this can be used for mocking 31 ClientFunc func(sess session.Session, opts ...Option) HAPI 32 ) 33 34 // Client returns a new hapi Client instance with the specified controller 35 func Client(sess session.Session, opts ...Option) HAPI { 36 h := &hapi{ 37 Session: sess, 38 } 39 40 for _, opt := range opts { 41 opt(h) 42 } 43 return h 44 }