github.com/akamai/AkamaiOPEN-edgegrid-golang/v4@v4.1.0/pkg/dns/dns.go (about)

     1  // Package dns provides access to the Akamai DNS V2 APIs
     2  //
     3  // See: https://techdocs.akamai.com/edge-dns/reference/edge-dns-api
     4  package dns
     5  
     6  import (
     7  	"errors"
     8  	"net/http"
     9  
    10  	"github.com/akamai/AkamaiOPEN-edgegrid-golang/v4/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  	// DNS is the dns api interface
    20  	DNS interface {
    21  		Zones
    22  		TSIGKeys
    23  		Authorities
    24  		Records
    25  		RecordSets
    26  	}
    27  
    28  	dns struct {
    29  		session.Session
    30  	}
    31  
    32  	// Option defines a DNS option
    33  	Option func(*dns)
    34  
    35  	// ClientFunc is a dns client new method, this can used for mocking
    36  	ClientFunc func(sess session.Session, opts ...Option) DNS
    37  )
    38  
    39  // Client returns a new dns Client instance with the specified controller
    40  func Client(sess session.Session, opts ...Option) DNS {
    41  	p := &dns{
    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 *dns) Exec(r *http.Request, out interface{}, in ...interface{}) (*http.Response, error) {
    53  
    54  	return p.Session.Exec(r, out, in...)
    55  }