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) LoadAll(domain string) (*RecordsResponse, error)
- func (c *Client) LoadAllAtIndex(domain string, index int) (*RecordsResponse, 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) RetrieveRecordByName(domain string, name string) (*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 ¶
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 ¶
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) LoadAllAtIndex ¶
func (c *Client) LoadAllAtIndex(domain string, index int) (*RecordsResponse, error)
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 ¶
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) RetrieveRecordByName ¶
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) 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 ¶
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"` }
func (*RecordResponse) GetRecord ¶
func (r *RecordResponse) GetRecord() (*Record, error)
type RecordsResponse ¶
type RecordsResponse struct { Response struct { Recs struct { Count int `json:"count"` HasMore bool `json:"has_more"` 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) (*Record, error)