github.com/akamai/AkamaiOPEN-edgegrid-golang/v8@v8.1.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/v8/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  		ChangeRequests
    21  		EdgeHostnames
    22  	}
    23  
    24  	hapi struct {
    25  		session.Session
    26  	}
    27  
    28  	// Option defines a HAPI option
    29  	Option func(*hapi)
    30  
    31  	// ClientFunc is a hapi client new method, this can be used for mocking
    32  	ClientFunc func(sess session.Session, opts ...Option) HAPI
    33  )
    34  
    35  // Client returns a new hapi Client instance with the specified controller
    36  func Client(sess session.Session, opts ...Option) HAPI {
    37  	h := &hapi{
    38  		Session: sess,
    39  	}
    40  
    41  	for _, opt := range opts {
    42  		opt(h)
    43  	}
    44  	return h
    45  }