Documentation ¶
Overview ¶
Package namecheap - Golang client for Namecheap's API
To use this project you'll need to either pull down the source or vendor it into your project.
Once added to your project there are two ways to construct a Client
namecheap.New() // reads environmental variables namecheap.NewClient(username, apiuser string, token string, ip string, useSandbox)
The following environmental variables are supported:
NAMECHEAP_USERNAME Username: e.g. adamdecaf NAMECHEAP_API_USER ApiUser: e.g. adamdecaf NAMECHEAP_TOKEN From https://ap.www.namecheap.com/Profile/Tools/ApiAccess NAMECHEAP_IP Your IP (must be whitelisted) NAMECHEAP_USE_SANDBOX Use sandbox environment
The public methods are viewable here: https://godoc.org/github.com/adamdecaf/namecheap
Please raise an issue or pull request if you run into problems. Thanks!
Index ¶
- func CheckRecordType(recordType string) bool
- func HashString(s string) int
- func HashStrings(strings []string) string
- type Client
- func (c *Client) AddRecord(domain string, record *Record) (*Record, error)
- func (c *Client) CreateHash(record *Record) int
- func (c *Client) DeleteRecord(domain string, hashId int) error
- func (c *Client) FindRecordByHash(hashId int, records []Record) (*Record, error)
- func (c *Client) GetDomains() ([]Domain, error)
- func (c *Client) GetHosts(domain string) ([]Record, error)
- func (c *Client) GetNS(domain string) ([]string, error)
- func (c *Client) NewRequest(body map[string]string) (*http.Request, error)
- func (c *Client) ReadRecord(domain string, hashId int) (*Record, error)
- func (c *Client) RemoveRecordByHash(hashId int, records []Record) []Record
- func (c *Client) ResetNS(domain string) error
- func (c *Client) SetHosts(domain string, records []Record) ([]Record, error)
- func (c *Client) SetNS(domain string, servers []string) ([]string, error)
- func (c *Client) UpdateRecord(domain string, hashId int, record *Record) error
- type Domain
- type DomainsResponse
- type NSListResponse
- type NSSetCustomRepsonse
- type NSSetDefaultResponse
- type Record
- type RecordsCreateResult
- type RecordsResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckRecordType ¶
func HashString ¶
HashString hashes a string to a unique hashcode.
crc32 returns a uint32, but for our use we need and non negative integer. Here we cast to an integer and invert it if the result is negative.
func HashStrings ¶
HashStrings hashes a list of strings to a unique hashcode.
Types ¶
type Client ¶
type Client struct { // Access Token Token string // ApiUser ApiUser string // TODO(adam): What's this for? difference with Username? // Username Username string // URL to the DO API to use URL string // IP that is whitelisted Ip string // HttpClient is the client to use. A client with // default values will be used if not provided. Http *http.Client }
Client provides a client to the Namecheap API
func NewClient ¶
func NewClient(username string, apiuser string, token string, ip string, useSandbox bool) (*Client, error)
NewClient creates a Client instance from the provided configuration typically users call New() with environment variables set instead.
func (*Client) CreateHash ¶
func (*Client) FindRecordByHash ¶
func (*Client) GetDomains ¶
GetDomains retrieves all the domains available on account.
func (*Client) NewRequest ¶
NewRequest creates a new request with the params
func (*Client) RemoveRecordByHash ¶
type DomainsResponse ¶
type NSListResponse ¶
type NSListResponse struct { XMLName xml.Name `xml:"ApiResponse"` Errors []struct { Message string `xml:",chardata"` Number string `xml:"Number,attr"` } `xml:"Errors>Error"` CommandResponse struct { DomainDNSGetListResult []string `xml:"DomainDNSGetListResult>Nameserver"` } `xml:"CommandResponse"` }
type NSSetCustomRepsonse ¶
type NSSetCustomRepsonse struct { XMLName xml.Name `xml:"ApiResponse"` Errors []struct { Message string `xml:",chardata"` Number string `xml:"Number,attr"` } `xml:"Errors>Error"` CommandResponse struct { DomainDNSSetCustomResult struct { Domain string `xml:"Domain,attr"` Updated bool `xml:"Updated,attr"` } `xml:"DomainDNSSetCustomResult"` } `xml:"CommandResponse"` }
type NSSetDefaultResponse ¶
type NSSetDefaultResponse struct { XMLName xml.Name `xml:"ApiResponse"` Errors []struct { Message string `xml:",chardata"` Number string `xml:"Number,attr"` } `xml:"Errors>Error"` CommandResponse struct { DomainDNSSetDefaultResult struct { Domain string `xml:"Domain,attr"` Updated bool `xml:"Updated,attr"` } `xml:"DomainDNSSetDefaultResult"` } `xml:"CommandResponse"` }
type Record ¶
type Record struct { Name string `xml:"Name,attr"` FriendlyName string `xml:"FriendlyName,attr"` Address string `xml:"Address,attr"` MXPref int `xml:"MXPref,attr"` AssociatedAppTitle string `xml:"AssociatedAppTitle,attr"` Id int `xml:"HostId,attr"` RecordType string `xml:"Type,attr"` TTL int `xml:"TTL,attr"` IsActive bool `xml:"IsActive,attr"` IsDDNSEnabled bool `xml:"IsDDNSEnabled,attr"` }
Record is used to represent a retrieved Record. All properties are set as strings.
func RemoveParkingRecords ¶
type RecordsCreateResult ¶
type RecordsCreateResult struct { XMLName xml.Name `xml:"ApiResponse"` Errors []struct { Message string `xml:",chardata"` Number string `xml:"Number,attr"` } `xml:"Errors>Error"` CommandResponse struct { DomainDNSSetHostsResult struct { Domain string `xml:"Domain,attr"` IsSuccess bool `xml:"IsSuccess,attr"` } `xml:"DomainDNSSetHostsResult"` } `xml:"CommandResponse"` }