Documentation ¶
Index ¶
- func BuildDNSARecord(subdomain, domainName, ipAddress string) dns.Record
- func ConvertDNSRecordList(sdkRecords []sdk.DNSRecord) []dns.Record
- func FromCloudFlareDNSRecord(record sdk.DNSRecord) dns.Record
- func ToCloudFlareDNSRecord(record dns.Record) sdk.DNSRecord
- type DefaultClient
- func (c *DefaultClient) ApplyDNSARecord(ctx context.Context, subdomain, ipAddress string) (dns.Record, error)
- func (c *DefaultClient) CreateDNSARecord(ctx context.Context, record dns.Record) (dns.Record, error)
- func (c *DefaultClient) DeleteDNSARecord(ctx context.Context, record dns.Record) error
- func (c *DefaultClient) GetDNSRecord(ctx context.Context, recordID string) (dns.Record, error)
- func (c *DefaultClient) GetZoneID(ctx context.Context) (string, error)
- func (c *DefaultClient) ListDNSARecords(ctx context.Context, subdomain string) ([]sdk.DNSRecord, error)
- func (c *DefaultClient) UpdateDNSARecord(ctx context.Context, recordID string, record dns.Record) error
- type LoadOption
- type SDKClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildDNSARecord ¶
BuildDNSARecord constructs a consistent DNS record across the client
func ConvertDNSRecordList ¶
ConvertDNSRecordList converts a list of Cloudflare DNS records to locally-managed DNS Records
func FromCloudFlareDNSRecord ¶
FromCloudFlareDNSRecord converts a CloudFlare DNS Record struct to one managed and controlled by this client
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 ¶
DeleteDNSARecord deletes an existing DNS A record for the provided record ID
func (*DefaultClient) GetDNSRecord ¶
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