namecheap

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupTestServer added in v1.0.0

func SetupTestServer(t *testing.T, hosts ...HostRecord) *httptest.Server

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(apiKey, apiUser string, opts ...ClientOption) (*Client, error)

func (*Client) GetHosts

func (c *Client) GetHosts(ctx context.Context, domain Domain) ([]HostRecord, error)

GetHosts returns the host records for the given domain.

func (*Client) GetTLDs added in v1.0.0

func (c *Client) GetTLDs(ctx context.Context) ([]TLD, error)

GetTLDs returns all TLDs available for namecheap.

func (*Client) SetHosts

func (c *Client) SetHosts(ctx context.Context, domain Domain, hosts []HostRecord) ([]HostRecord, error)

type ClientOption

type ClientOption func(*Client) error

func AutoDiscoverPublicIP

func AutoDiscoverPublicIP() ClientOption

func WithClientIP

func WithClientIP(ip string) ClientOption

func WithDiscoveryAddress

func WithDiscoveryAddress(address string) ClientOption

func WithEndpoint

func WithEndpoint(endpoint string) ClientOption

type Domain added in v1.0.0

type Domain struct {
	TLD string
	SLD string
}

type HostRecord

type HostRecord struct {
	// The domain or subdomain for which host record is set.
	Name string

	// RecordType the type of DNS record e.g. A, AAAA
	RecordType RecordType

	// Possible values are URL or IP address. The value for this parameter is based on RecordType.
	Address string

	// MX preference for host. Applicable for MX records only.
	MXPref string

	// EmailType Possible values are:
	// MXE - to set up your custom MXE record.
	// MX - to set up custom MX records of your mail provider.
	// FWD - to set up MX records for our Free Email Forwarding service.
	// OX - to set up MX records for our Private Email service.
	EmailType string

	// 60 to 60000
	// Default Value: 1800
	TTL uint16

	// Flag is an unsigned integer between 0 and 255.
	// The flag value is an 8-bit number, the most significant bit of which indicates
	// the criticality of understanding of a record by a CA.
	// It's recommended to use '0'
	Flag uint8

	// Tag is a non-zero sequence of US-ASCII letters and numbers in lower case.
	// For CAA records, possible values are:
	// - issue: specifies the certification authority that is authorized to issue a certificate
	// - issuewild: specifies the certification authority that is allowed to issue a wildcard certificate
	// - iodef: specifies the e-mail address or URL a CA should use to notify a client
	Tag string

	// HostID is the unique ID of the host record.
	// Readonly field.
	HostID string
}

func (HostRecord) AppendKey added in v1.0.0

func (h HostRecord) AppendKey() HostRecordKey

AppendKey is used to determine if a host record is new or an existing one when appending records. The libdns spec doesn't specify for AppendRecords how to determine if a record is new or existing but namecheap lets you have multiple records with the same name + type as long as the address is different.

func (HostRecord) DeleteKey added in v1.0.0

func (h HostRecord) DeleteKey() HostRecordKey

func (HostRecord) SetKey added in v1.0.0

func (h HostRecord) SetKey() HostRecordKey

type HostRecordKey added in v1.0.0

type HostRecordKey struct {
	Name       string
	RecordType RecordType
	TTL        uint16
	Address    string
}

type RecordType

type RecordType string

RecordType is the type of DNS Record.

const (
	A      RecordType = "A"
	AAAA   RecordType = "AAAA"
	ALIAS  RecordType = "ALIAS"
	CAA    RecordType = "CAA"
	CNAME  RecordType = "CNAME"
	MX     RecordType = "MX"
	MXE    RecordType = "MXE"
	NS     RecordType = "NS"
	TXT    RecordType = "TXT"
	URL    RecordType = "URL"
	URL301 RecordType = "URL301"
	FRAME  RecordType = "FRAME"
)

type TLD added in v1.0.0

type TLD struct {
	Name string `xml:"Name,attr"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL