katapult

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 10 Imported by: 3

README

Katapult for libdns

Go Reference

This package implements the libdns interfaces for Katapult, allowing you to manage DNS records.

Authentication

To use this package you will need a Katapult API token, see the Katapult docs for more information.

Example

See the example/main.go file for a demonstration on how to use the package. The example can be ran by specifying the API token and zone:

LIBDNS_KATAPULT_API_TOKEN=your-api-token LIBDNS_KATAPULT_ZONE=your-domain go run ./example

The example can be modified to try different functions available on the provider.

Tests

The tests use the Katapult API, therefore you should create and use a new and empty domain/zone.

You can then set the API token and zone when running the tests:

LIBDNS_KATAPULT_API_TOKEN=your-api-token LIBDNS_KATAPULT_ZONE=your-domain go test

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHTTPClient

func NewHTTPClient() *http.Client

NewHTTPClient returns a configured HTTP client.

func RemoveTrailingDot

func RemoveTrailingDot(input string) string

Types

type DNSRecord

type DNSRecord struct {
	ID       string `json:"id"`
	Type     string `json:"type"`
	Name     string `json:"name"`
	FullName string `json:"full_name"`
	TTL      int    `json:"ttl"`
	Priority uint   `json:"priority"`
	Content  string `json:"content"`
}

DNSRecord represents a DNS record in the API response.

type DNSRecordAPIResponse

type DNSRecordAPIResponse struct {
	DNSRecord DNSRecord `json:"dns_record"`
}

DNSRecordAPIResponse represents an API response for a DNS record.

type DNSRecordsAPIResponse

type DNSRecordsAPIResponse struct {
	DNSRecords []DNSRecord `json:"dns_records"`
}

DNSRecordsAPIResponse represents an API response of DNS records.

type DeletionAPIResponse

type DeletionAPIResponse struct {
	Deleted bool `json:"deleted"`
}

DeletionAPIResponse represents an API response for a deletion.

type Provider

type Provider struct {
	APIToken string `json:"api_token,omitempty"`
}

Provider facilitates DNS record manipulation with Katapult.

func (*Provider) AppendRecords

func (p *Provider) AppendRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)

AppendRecords adds records to the zone. It returns the records that were added.

func (*Provider) DeleteRecords

func (p *Provider) DeleteRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)

DeleteRecords deletes the records from the zone. It returns the records that were deleted.

func (*Provider) DoRequest

func (p *Provider) DoRequest(ctx context.Context, method, url string, body interface{}, response interface{}) error

DoRequest performs an HTTP request and decodes the response.

func (*Provider) FromLibDNSRecord

func (p *Provider) FromLibDNSRecord(record libdns.Record) (interface{}, error)

FromLibDNSRecord converts a libdns.Record to an API request body.

func (*Provider) GetRecords

func (p *Provider) GetRecords(ctx context.Context, zone string) ([]libdns.Record, error)

GetRecords lists all the records in the zone.

func (*Provider) SetRecords

func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)

SetRecords sets the records in the zone, either by updating existing records or creating new ones. It returns the updated records.

func (*Provider) ToLibDNSRecord

func (p *Provider) ToLibDNSRecord(r DNSRecord) libdns.Record

ToLibDNSRecord converts a DNSRecord to a libdns.Record.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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