github.com/akamai/AkamaiOPEN-edgegrid-golang/v8@v8.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  	"net/http"
     8  
     9  	"github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session"
    10  )
    11  
    12  type (
    13  	// DNS is the dns api interface
    14  	DNS interface {
    15  		Authorities
    16  		Data
    17  		Recordsets
    18  		Records
    19  		TSIGKeys
    20  		Zones
    21  	}
    22  
    23  	dns struct {
    24  		session.Session
    25  	}
    26  
    27  	// Option defines a DNS option
    28  	Option func(*dns)
    29  
    30  	// ClientFunc is a dns client new method, this can used for mocking
    31  	ClientFunc func(sess session.Session, opts ...Option) DNS
    32  )
    33  
    34  // Client returns a new dns Client instance with the specified controller
    35  func Client(sess session.Session, opts ...Option) DNS {
    36  	d := &dns{
    37  		Session: sess,
    38  	}
    39  
    40  	for _, opt := range opts {
    41  		opt(d)
    42  	}
    43  	return d
    44  }
    45  
    46  // Exec overrides the session.Exec to add dns options
    47  func (d *dns) Exec(r *http.Request, out interface{}, in ...interface{}) (*http.Response, error) {
    48  	return d.Session.Exec(r, out, in...)
    49  }