cloudflare

package
v0.0.0-...-76c1feb Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// AutomaticTTL should be used to request cloudflare's Automatic TTL setting (which is 1).
	AutomaticTTL = 1
)

Variables

View Source
var ErrDuplicateZoneNameFound = fmt.Errorf("more than a single zone name found to match the requested zone name")

ErrDuplicateZoneNameFound is used when a user that is not permitted in a given zone attempt to perform an operation on that zone.

View Source
var ErrUserNotPermitted = fmt.Errorf("user not permitted in zone")

ErrUserNotPermitted is used when a user that is not permitted in a given zone attempt to perform an operation on that zone.

Functions

This section is empty.

Types

type CreateDNSRecordResponse

type CreateDNSRecordResponse struct {
	Success  bool                  `json:"success"`
	Errors   []interface{}         `json:"errors"`
	Messages []interface{}         `json:"messages"`
	Result   CreateDNSRecordResult `json:"result"`
}

CreateDNSRecordResponse is the JSON response for a DNS create request

type CreateDNSRecordResult

type CreateDNSRecordResult struct {
	ID         string      `json:"id"`
	Type       string      `json:"type"`
	Name       string      `json:"name"`
	Content    string      `json:"content"`
	Proxiable  bool        `json:"proxiable"`
	Proxied    bool        `json:"proxied"`
	TTL        uint        `json:"ttl"`
	Locked     bool        `json:"locked"`
	ZoneID     string      `json:"zone_id"`
	ZoneName   string      `json:"zone_name"`
	CreatedOn  string      `json:"created_on"`
	ModifiedOn string      `json:"modified_on"`
	Data       interface{} `json:"data"`
}

CreateDNSRecordResult is the result of the response for the DNS create request

type Cred

type Cred struct {
	// contains filtered or unexported fields
}

Cred contains the credentials used to authenticate with the cloudflare API.

func NewCred

func NewCred(authEmail string, authKey string) *Cred

NewCred creates a new credential structure used to authenticate with the cloudflare service.

func (*Cred) GetZoneID

func (c *Cred) GetZoneID(ctx context.Context, zoneDomainName string) (zoneID string, err error)

GetZoneID returns a zoneID that matches the requested zoneDomainName.

func (*Cred) GetZones

func (c *Cred) GetZones(ctx context.Context) (zones []Zone, err error)

GetZones returns a list of zones that are associated with cloudflare.

type DNS

type DNS struct {
	Cred
	// contains filtered or unexported fields
}

DNS is the cloudflare package main access class. Initiate an instance of this class to access the clouldflare APIs.

func NewDNS

func NewDNS(zoneID string, authEmail string, authKey string) *DNS

NewDNS create a new instance of clouldflare DNS services class

func (*DNS) ClearSRVRecord

func (d *DNS) ClearSRVRecord(ctx context.Context, name string, target string, service string, protocol string) error

ClearSRVRecord clears the DNS SRV record to the given content.

func (*DNS) CreateDNSRecord

func (d *DNS) CreateDNSRecord(ctx context.Context, recordType string, name string, content string, ttl uint, priority uint, proxied bool) error

CreateDNSRecord creates the DNS record with the given content.

func (*DNS) CreateSRVRecord

func (d *DNS) CreateSRVRecord(ctx context.Context, name string, target string, ttl uint, priority uint, port uint, service string, protocol string, weight uint) error

CreateSRVRecord creates the DNS record with the given content.

func (*DNS) DeleteDNSRecord

func (d *DNS) DeleteDNSRecord(ctx context.Context, recordID string) error

DeleteDNSRecord deletes a single DNS entry

func (*DNS) ExportZone

func (d *DNS) ExportZone(ctx context.Context) (exportedZoneBytes []byte, err error)

ExportZone exports the zone into a BIND config bytes array

func (*DNS) ListDNSRecord

func (d *DNS) ListDNSRecord(ctx context.Context, recordType string, name string, content string, order string, direction string, match string) ([]DNSRecordResponseEntry, error)

ListDNSRecord list the dns records that matches the given parameters.

func (*DNS) SetDNSRecord

func (d *DNS) SetDNSRecord(ctx context.Context, recordType string, name string, content string, ttl uint, priority uint, proxied bool) error

SetDNSRecord sets the DNS record to the given content.

func (*DNS) SetSRVRecord

func (d *DNS) SetSRVRecord(ctx context.Context, name string, target string, ttl uint, priority uint, port uint, service string, protocol string, weight uint) error

SetSRVRecord sets the DNS SRV record to the given content.

func (*DNS) UpdateDNSRecord

func (d *DNS) UpdateDNSRecord(ctx context.Context, recordID string, recordType string, name string, content string, ttl uint, priority uint, proxied bool) error

UpdateDNSRecord update the DNS record with the given content.

func (*DNS) UpdateSRVRecord

func (d *DNS) UpdateSRVRecord(ctx context.Context, recordID string, name string, target string, ttl uint, priority uint, port uint, service string, protocol string, weight uint) error

UpdateSRVRecord update the DNS record with the given content.

type DNSRecordResponseEntry

type DNSRecordResponseEntry struct {
	ID         string `json:"id"`
	Type       string `json:"type"`
	Name       string `json:"name"`
	Content    string `json:"content"`
	Proxiable  bool   `json:"proxiable"`
	Proxied    bool   `json:"proxied"`
	TTL        int    `json:"ttl"`
	Priority   int    `json:"priority"`
	Locked     bool   `json:"locked"`
	ZoneID     string `json:"zone_id"`
	ZoneName   string `json:"zone_name"`
	ModifiedOn string `json:"modified_on"`
	CreatedOn  string `json:"created_on"`
}

DNSRecordResponseEntry represent a single returned DNS record entry

type DNSRecordResponseResultInfo

type DNSRecordResponseResultInfo struct {
	Page       int `json:"page"`
	PerPage    int `json:"per_page"`
	TotalPages int `json:"total_pages"`
	Count      int `json:"count"`
	TotalCount int `json:"total_count"`
}

DNSRecordResponseResultInfo is paging status for the returned JSON structure ListDNSRecordResponse

type DeleteDNSRecordResponse

type DeleteDNSRecordResponse struct {
	Success  bool                  `json:"success"`
	Errors   []interface{}         `json:"errors"`
	Messages []interface{}         `json:"messages"`
	Result   DeleteDNSRecordResult `json:"result"`
}

DeleteDNSRecordResponse is the JSON response for a DNS delete request

type DeleteDNSRecordResult

type DeleteDNSRecordResult struct {
	ID string `json:"id"`
}

DeleteDNSRecordResult is the JSON result for a DNS delete request

type GetZonesResult

type GetZonesResult struct {
	Success    bool                 `json:"success"`
	Errors     []interface{}        `json:"errors"`
	Messages   []interface{}        `json:"messages"`
	Result     []GetZonesResultItem `json:"result"`
	ResultInfo GetZonesResultPage   `json:"result_info"`
}

GetZonesResult is the JSON response for a DNS create request

type GetZonesResultItem

type GetZonesResultItem struct {
	ID                  string   `json:"id"`
	Name                string   `json:"name"`
	Status              string   `json:"status"`
	Paused              bool     `json:"paused"`
	Type                string   `json:"type"`
	DevelopmentMode     int      `json:"development_mode"`
	NameServers         []string `json:"name_servers"`
	OriginalNameServers []string `json:"original_name_servers"`
}

GetZonesResultItem is the result of the response for the DNS create request

type GetZonesResultPage

type GetZonesResultPage struct {
	Page       int `json:"page"`
	PerPage    int `json:"per_page"`
	TotalPages int `json:"total_pages"`
	Count      int `json:"count"`
	TotalCount int `json:"total_count"`
}

GetZonesResultPage is the result of the response for the DNS create request

type ListDNSRecordError

type ListDNSRecordError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

ListDNSRecordError is the JSON data structure for a single error during list dns records request

type ListDNSRecordResponse

type ListDNSRecordResponse struct {
	Result     []DNSRecordResponseEntry    `json:"result"`
	ResultInfo DNSRecordResponseResultInfo `json:"result_info"`
	Errors     []ListDNSRecordError        `json:"errors"`
	Messages   []interface{}               `json:"messages"`
}

ListDNSRecordResponse is the JSON data structure returned when we list the dns records

type Zone

type Zone struct {
	DomainName string
	ZoneID     string
}

Zone represent a single zone on the cloudflare API.

Jump to

Keyboard shortcuts

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