cloudflare

package
v0.0.0-...-8b1022e Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2016 License: Apache-2.0, MPL-2.0 Imports: 9 Imported by: 0

README

cloudflare

This package provides the cloudflare package which offers an interface to the CloudFlare gAPI.

It's intentionally designed to make heavy use of built-ins and strings in place of custom data structures and proper types. It also only implements specific endpoints, and doesn't have full API coverage.

For those reasons, I recommend looking elsewhere if you just need a standard CloudFlare API client.

Documentation

The full documentation is available on Godoc

Documentation

Index

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

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) LoadAll

func (c *Client) LoadAll(domain string) (*RecordsResponse, error)

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

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) RetrieveRecordByName

func (c *Client) RetrieveRecordByName(domain string, name 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) 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"`
}

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)

type UpdateRecord

type UpdateRecord struct {
	Type        string
	Name        string
	Content     string
	Ttl         string
	Priority    string
	ServiceMode string
}

UpdateRecord contains the request parameters to update a record.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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