cloudflare

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildDNSARecord

func BuildDNSARecord(subdomain, domainName, ipAddress string) dns.Record

BuildDNSARecord constructs a consistent DNS record across the client

func ConvertDNSRecordList

func ConvertDNSRecordList(sdkRecords []sdk.DNSRecord) []dns.Record

ConvertDNSRecordList converts a list of Cloudflare DNS records to locally-managed DNS Records

func FromCloudFlareDNSRecord

func FromCloudFlareDNSRecord(record sdk.DNSRecord) dns.Record

FromCloudFlareDNSRecord converts a CloudFlare DNS Record struct to one managed and controlled by this client

func ToCloudFlareDNSRecord added in v0.1.1

func ToCloudFlareDNSRecord(record dns.Record) sdk.DNSRecord

ToCloudFlareDNSRecord converts a local DNS record to one accepted by the CloudFlare SDK

Types

type DefaultClient

type DefaultClient struct {
	// Client *sdk.API
	Client     SDKClient
	AccountID  string
	DomainName string
	ZoneID     string
}

DefaultClient implements the cloudflare client

func NewClientWithToken

func NewClientWithToken(ctx context.Context, accountID, domain, token string, opts ...LoadOption) (*DefaultClient, error)

NewClientWithToken is an initializer specifically for using an API token

func (*DefaultClient) ApplyDNSARecord

func (c *DefaultClient) ApplyDNSARecord(ctx context.Context, subdomain, ipAddress string) (dns.Record, error)

ApplyDNSARecord creates or updates a DNS record without creating a duplicate. It will also delete other A records for the domain that don't match the provided IP address

func (*DefaultClient) CreateDNSARecord

func (c *DefaultClient) CreateDNSARecord(ctx context.Context, record dns.Record) (dns.Record, error)

CreateDNSARecord creates a new DNS A record for the provided subdomain and IP Address

func (*DefaultClient) DeleteDNSARecord

func (c *DefaultClient) DeleteDNSARecord(ctx context.Context, record dns.Record) error

DeleteDNSARecord deletes an existing DNS A record for the provided record ID

func (*DefaultClient) GetDNSRecord

func (c *DefaultClient) GetDNSRecord(ctx context.Context, recordID string) (dns.Record, error)

GetDNSRecord retrieves a DNS record by ID

func (*DefaultClient) GetZoneID

func (c *DefaultClient) GetZoneID(ctx context.Context) (string, error)

GetZoneID returns and caches the Zone ID for the current client

func (*DefaultClient) ListDNSARecords

func (c *DefaultClient) ListDNSARecords(ctx context.Context, subdomain string) ([]sdk.DNSRecord, error)

ListDNSARecords returns all DNS records for the provided subdomain

func (*DefaultClient) UpdateDNSARecord

func (c *DefaultClient) UpdateDNSARecord(ctx context.Context, recordID string, record dns.Record) error

UpdateDNSARecord updates an existing DNS A record for the provided subdomain and IP Address

type LoadOption

type LoadOption func(client *DefaultClient) error

LoadOption allows for modifying the client after it's created

type SDKClient

type SDKClient interface {
	ZoneIDByName(zoneName string) (string, error)
	DNSRecords(ctx context.Context, zoneID string, rr sdk.DNSRecord) ([]sdk.DNSRecord, error)
	DNSRecord(ctx context.Context, zoneID string, recordID string) (sdk.DNSRecord, error)
	CreateDNSRecord(ctx context.Context, zoneID string, rr sdk.DNSRecord) (*sdk.DNSRecordResponse, error)
	UpdateDNSRecord(ctx context.Context, zoneID string, recordID string, rr sdk.DNSRecord) error
	DeleteDNSRecord(ctx context.Context, zoneID string, recordID string) error
}

SDKClient wraps the SDK client for Cloudflare

Jump to

Keyboard shortcuts

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