github.com/akamai/AkamaiOPEN-edgegrid-golang/v2@v2.17.0/pkg/configdns/dns.go (about)

     1  // Package dns provides access to the Akamai DNS V2 APIs
     2  package dns
     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  	// DNS is the dns api interface
    18  	DNS interface {
    19  		Zones
    20  		TSIGKeys
    21  		Authorities
    22  		Records
    23  		RecordSets
    24  	}
    25  
    26  	dns struct {
    27  		session.Session
    28  	}
    29  
    30  	// Option defines a DNS option
    31  	Option func(*dns)
    32  
    33  	// ClientFunc is a dns client new method, this can used for mocking
    34  	ClientFunc func(sess session.Session, opts ...Option) DNS
    35  )
    36  
    37  // Client returns a new dns Client instance with the specified controller
    38  func Client(sess session.Session, opts ...Option) DNS {
    39  	p := &dns{
    40  		Session: sess,
    41  	}
    42  
    43  	for _, opt := range opts {
    44  		opt(p)
    45  	}
    46  	return p
    47  }
    48  
    49  // Exec overrides the session.Exec to add dns options
    50  func (p *dns) Exec(r *http.Request, out interface{}, in ...interface{}) (*http.Response, error) {
    51  
    52  	return p.Session.Exec(r, out, in...)
    53  }