Documentation
¶
Index ¶
- type Client
- func (c *Client) CreateRecord(domain string, opts *CreateRecord) (*Record, error)
- func (c *Client) DestroyRecord(domain string, id string) error
- func (c *Client) NewRequest(params map[string]string, method string, action string) (*http.Request, error)
- func (c *Client) RetrieveRecord(domain string, id string) (*Record, error)
- func (c *Client) RetrieveRecordsByName(domain string, name string, wildcard bool) ([]Record, error)
- func (c *Client) UpdateRecord(domain string, id string, opts *UpdateRecord) error
- type CreateRecord
- type Record
- type RecordResponse
- type RecordsResponse
- type UpdateRecord
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// Access Token
Token string
// User Email
Email string
// URL to the DO API to use
URL string
// HttpClient is the client to use. Default will be
// used if not provided.
Http *http.Client
}
Client provides a client to the CloudflAre API
func NewClient ¶
func NewClient(email string, token string) (*Client, error)
NewClient returns a new cloudflare client, requires an authorization token. You can generate an OAuth token by visiting the Apps & API section of the CloudflAre control panel for your account.
func (*Client) CreateRecord ¶
func (c *Client) CreateRecord(domain string, opts *CreateRecord) (*Record, error)
CreateRecord creates a record from the parameters specified and returns an error if it fails. If no error and the name is returned, the Record was succesfully created.
func (*Client) DestroyRecord ¶
func (c *Client) DestroyRecord(domain string, id string) error
DestroyRecord destroys a record by the ID specified and returns an error if it fails. If no error is returned, the Record was succesfully destroyed.
func (*Client) NewRequest ¶
func (c *Client) NewRequest(params map[string]string, method string, action string) (*http.Request, error)
Creates a new request with the params
func (*Client) RetrieveRecord ¶
func (c *Client) RetrieveRecord(domain string, id string) (*Record, error)
RetrieveRecord gets a record by the ID specified and returns a Record and an error. An error will be returned for failed requests with a nil Record.
func (*Client) RetrieveRecordsByName ¶
func (c *Client) RetrieveRecordsByName(domain string, name string, wildcard bool) ([]Record, error)
func (*Client) UpdateRecord ¶
func (c *Client) UpdateRecord(domain string, id string, opts *UpdateRecord) error
UpdateRecord destroys a record by the ID specified and returns an error if it fails. If no error is returned, the Record was succesfully updated.
type CreateRecord ¶
type CreateRecord struct {
Type string
Name string
Content string
Ttl string
Priority string
}
CreateRecord contains the request parameters to create a new record.
type Record ¶
type Record struct {
Id string `json:"rec_id"`
Domain string `json:"zone_name"`
Name string `json:"display_name"`
FullName string `json:"name"`
Value string `json:"content"`
Type string `json:"type"`
Priority string `json:"prio"`
Ttl string `json:"ttl"`
}
Record is used to represent a retrieved Record. All properties are set as strings.
type RecordResponse ¶
type RecordResponse struct {
Response struct {
Rec struct {
Record Record `json:"obj"`
} `json:"rec"`
} `json:"response"`
Result string `json:"result"`
Message string `json:"msg"`
}
type RecordsResponse ¶
type RecordsResponse struct {
Response struct {
Recs struct {
Records []Record `json:"objs"`
} `json:"recs"`
} `json:"response"`
Result string `json:"result"`
Message string `json:"msg"`
}
func (*RecordsResponse) FindRecord ¶
func (r *RecordsResponse) FindRecord(id string) (*Record, error)
func (*RecordsResponse) FindRecordByName ¶
func (r *RecordsResponse) FindRecordByName(name string, wildcard bool) ([]Record, error)
type UpdateRecord ¶
type UpdateRecord struct {
Type string
Name string
Content string
Ttl string
Priority string
}
UpdateRecord contains the request parameters to update a record.