cloudflare

package module
v0.0.0-...-5806792 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2014 License: MIT Imports: 5 Imported by: 1

README

Cloudflare API

This is a library for use in conjunction with the Cloudflare API.

It is neither complete nor very stable. It includes a very basic cloudflare command to add and remove dns records from a given zone.

Parameters

Environment variables:

CF_TOKEN = <Your API token>
CF_EMAIL = <You Cloudflare account email>
CZ_ZONE  = <The zone to use for all operations> (optional, can be set via the -z flag)

Add a record

./cloudflare [-z consulted.com] add -c [content] -n [name] -t [type]

This will also update the record to be immediately Cloudflare proxy enabled (orange cloud)

Remove a record

./cloudflare [-z zone] delete -c [content]

Removal will ask for your confirmation, however, you can pass the -y flag to skip the confirmation. All records with a given content will be deleted.

Documentation

Index

Constants

View Source
const (
	AutomaticTtl = "1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CfRecordResponse

type CfRecordResponse struct {
	Request struct {
		Act string `json:"act"`
	} `json:"request"`
	Response struct {
		Rec struct {
			Record Record `json:"obj"`
		} `json:"rec"`
	} `json:"response"`
	Result string `json:"result"`
	Msg    string `json:"msg"`
}

type CfResponse

type CfResponse struct {
	Request struct {
		Act string `json:"act"`
	} `json:"request"`
	Response struct {
		Zones   ZoneList   `json:"zones"`
		Records RecordList `json:"recs"`
	} `json:"response"`
	Result string `json:"result"`
	Msg    string `json:"msg"`
}

type Client

type Client struct {
	Email, Token string
}

func (*Client) AddRecord

func (client *Client) AddRecord(zone Zone, record Record) (r Record, err error)

func (*Client) GetRecordList

func (client *Client) GetRecordList(zone Zone, offset int) (records RecordList, err error)

func (*Client) GetZoneList

func (client *Client) GetZoneList() (zones ZoneList, err error)

func (*Client) RemoveRecord

func (client *Client) RemoveRecord(zone Zone, record Record) (success bool, err error)

func (*Client) UpdateRecord

func (client *Client) UpdateRecord(zone Zone, record Record) (r Record, err error)

type Record

type Record struct {
	RecId          string      `json:"rec_id"`
	RecTag         string      `json:"rec_tag"`
	ZoneName       string      `json:"zone_name"`
	Name           string      `json:"name"`
	DisplayName    string      `json:"display_name"`
	Type           string      `json:"type"`
	Prio           interface{} `json:"prio"`
	Content        string      `json:"content"`
	DisplayContent string      `json:"display_content"`
	Ttl            string      `json:"ttl"`
	TtlCeil        int         `json:"ttl_ceil"`
	SslId          interface{} `json:"ssl_id"`
	SslStatus      interface{} `json:"ssl_status"`
	SslExpiresOn   interface{} `json:"ssl_expires_on"`
	AutoTtl        int         `json:"auto_ttl"`
	ServiceMode    string      `json:"service_mode"`
	Props          struct {
		Proxiable   int `json:"proxiable"`
		CloudOn     int `json:"cloud_on"`
		CfOpen      int `json:"cf_open"`
		Ssl         int `json:"ssl"`
		ExpiredSsl  int `json:"expired_ssl"`
		ExpiringSsl int `json:"expiring_ssl"`
		PendingSsl  int `json:"pending_ssl"`
	} `json:"props"`
}

type RecordList

type RecordList struct {
	HasMore bool     `json:"has_more"`
	Count   int      `json:"count"`
	Records []Record `json:"objs"`
}

func (*RecordList) Find

func (list *RecordList) Find(content string) (record Record, err error)

func (*RecordList) FindAll

func (list *RecordList) FindAll(content string) (records *RecordList)

type Zone

type Zone struct {
	ZoneId          string        `json:"zone_id"`
	UserId          string        `json:"user_id"`
	ZoneName        string        `json:"zone_name"`
	DisplayName     string        `json:"display_name"`
	ZoneStatus      string        `json:"zone_status"`
	ZoneMode        string        `json:"zone_mode"`
	HostId          interface{}   `json:"host_id"`
	ZoneType        string        `json:"zone_type"`
	HostPubname     interface{}   `json:"host_pubname"`
	HostWebsite     interface{}   `json:"host_website"`
	Vtxt            interface{}   `json:"vtxt"`
	Fqdns           []string      `json:"fqdns"`
	Step            string        `json:"step"`
	ZoneStatusClass string        `json:"zone_status_class"`
	ZoneStatusDesc  string        `json:"zone_status_desc"`
	NsVanityMap     []interface{} `json:"ns_vanity_map"`
	OrigRegistrar   string        `json:"orig_registrar"`
	OrigDnshost     interface{}   `json:"orig_dnshost"`
	OrigNsNames     string        `json:"orig_ns_names"`
	Props           struct {
		DnsCname       int           `json:"dns_cname"`
		DnsPartner     int           `json:"dns_partner"`
		DnsAnonPartner int           `json:"dns_anon_partner"`
		Plan           string        `json:"plan"`
		Pro            int           `json:"pro"`
		ExpiredPro     int           `json:"expired_pro"`
		ProSub         int           `json:"pro_sub"`
		PlanSub        int           `json:"plan_sub"`
		Ssl            int           `json:"ssl"`
		ExpiredSsl     int           `json:"expired_ssl"`
		ExpiredRsPro   int           `json:"expired_rs_pro"`
		ResellerPro    int           `json:"reseller_pro"`
		ResellerPlans  []interface{} `json:"reseller_plans"`
		ForceInteral   int           `json:"force_interal"`
		SslNeeded      int           `json:"ssl_needed"`
		AlexaRank      int           `json:"alexa_rank"`
		HasVanity      int           `json:"has_vanity"`
	} `json:"props"`
	ConfirmCode struct {
		ZoneDelete     string `json:"zone_delete"`
		ZoneDeactivate string `json:"zone_deactivate"`
		ZoneDevMode1   string `json:"zone_dev_mode1"`
	} `json:"confirm_code"`
	Allow []string `json:"allow"`
}

type ZoneList

type ZoneList struct {
	HasMore bool   `json:"has_more"`
	Count   int    `json:"count"`
	Zones   []Zone `json:"objs"`
}

func (*ZoneList) Find

func (z *ZoneList) Find(name string) (zone Zone, err error)

Directories

Path Synopsis
Godeps
_workspace/src/github.com/voxelbrain/goptions
package goptions implements a flexible parser for command line options.
package goptions implements a flexible parser for command line options.
cmd

Jump to

Keyboard shortcuts

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