porkbungo

package module
v3.0.0-...-24f9f89 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: MIT Imports: 5 Imported by: 0

README

porkbungo

Documentation

Index

Constants

View Source
const (
	// Hostname to force the use of IPv4
	IPv4ApiHost = "api-ipv4.porkbun.com"
	// Porkbun API hostname
	APIHost = "porkbun.com"
	// Porkbun API base path
	BasePath = "/api/json"
	// Porkbun API version
	APIVersion = "v3"
	// connect to API with http(s)
	APIProto = "https"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	// Status indicating the command was not successful
	Status string `json:"status"`
	// Error message
	Message string `json:"message"`
}

type BooleanType

type BooleanType string

Type to represent yes or no

const (
	Yes BooleanType = "yes"
	No  BooleanType = "no"
)

type Client

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

Client is a wrapper around the Resty client

func NewClient

func NewClient() (client Client)

NewClient factory to create a new Client struct

func NewClientWithAPIKeys

func NewClientWithAPIKeys(keys *Keys) (client Client)

NewClient factory to create a new client with the the specified API keys

func (*Client) CreateDNSRecord

func (c *Client) CreateDNSRecord(ctx context.Context, opts RecordOptions) (int, error)

Create a DNS record

func (*Client) CreateURLForward

func (c *Client) CreateURLForward(ctx context.Context, opts URLForwardOptions) error

Create a URL forward for the specified domain

func (*Client) DeleteRecordByID

func (c *Client) DeleteRecordByID(ctx context.Context, domain string, id int, keys *Keys) error

Delete a specific DNS record by it's ID

func (*Client) DeleteRecordsByNameAndType

func (c *Client) DeleteRecordsByNameAndType(ctx context.Context, opts RecordOptions) error

Delete all records for the domain that match a particular subdomain/name and type. If name is not provided, it will delete records for the root with the specified type

func (*Client) DeleteURLForward

func (c *Client) DeleteURLForward(ctx context.Context, domain string, forwardId string, keys *Keys) error

Delete the specified URL forwarding for a domain

func (*Client) EditRecordByID

func (c *Client) EditRecordByID(ctx context.Context, opts RecordOptions) error

Edit a DNS record using the Second level domain and the ID of the dns record

func (*Client) EditRecordsByNameAndType

func (c *Client) EditRecordsByNameAndType(ctx context.Context, opts RecordOptions) error

Edit all records for the domain that match a specific subdomain and type

func (*Client) GetAllDomains

func (c *Client) GetAllDomains(ctx context.Context, keys *Keys) ([]Domain, error)

Get all domain names for the current account

func (*Client) GetAllRecords

func (c *Client) GetAllRecords(ctx context.Context, domain string, keys *Keys) ([]Record, error)

Retrieve all editable DNS records for a specified domain

func (*Client) GetDomainPricing

func (c *Client) GetDomainPricing(ctx context.Context) (*DomainPricing, error)

Checks default domain pricing information for all supported TLDs.

func (*Client) GetNameServers

func (c *Client) GetNameServers(ctx context.Context, domain string, keys *Keys) ([]string, error)

Get Authoritative nameservers listed at the registry for the specified domain

func (*Client) GetRecordByID

func (c *Client) GetRecordByID(ctx context.Context, domain string, id int, keys *Keys) (*Record, error)

Retrieve a specific DNS record by the given record ID

func (*Client) GetRecordsByNameAndType

func (c *Client) GetRecordsByNameAndType(ctx context.Context, opts RecordOptions) ([]Record, error)

retrieve all records for the domain that match a particular subdomain/name and type. If name is not provided, it will retrieve records for the root with the specified type

func (*Client) GetSSLBundle

func (c *Client) GetSSLBundle(ctx context.Context, opts SSLBundleOptions) (*SSLBundle, error)

func (*Client) GetUrlForwards

func (c *Client) GetUrlForwards(ctx context.Context, domain string, keys *Keys) ([]URLForward, error)

Get URL forwarding for the specified domain

func (*Client) SetAPIKeys

func (c *Client) SetAPIKeys(keys *Keys)

SetAPIKeys sets the API keys for to be used with all the requests from this client. The API keys can be overridden for individual requests using the requests options

func (*Client) UpdateNameServers

func (c *Client) UpdateNameServers(ctx context.Context, opts UpdateNameServerOptions) error

Update the authoritative nameservers for the specified domain

func (*Client) UseIPv4

func (c *Client) UseIPv4(value bool)

Force client to use IPv4

type Domain

type Domain struct {
	Domain       string `json:"domain"`
	Status       string `json:"status"`
	TLD          string `json:"tld"`
	CreateDate   string `json:"createDate"`
	ExpireDate   string `json:"expireDate"`
	SecurityLock string `json:"securityLock"`
	WhoisPrivacy string `json:"whoisPrivacy"`
	AutoRenew    int    `json:"autoRenew,string"`
	NotLocal     int    `json:"notLocal"`
}

Domain represents a second level domain owned by the account

type DomainPricing

type DomainPricing struct {
	Status  string `json:"status"`
	Pricing map[string]struct {
		Registration string `json:"registration"`
		Renewal      string `json:"renewal"`
		Transfer     string `json:"transfer"`
	} `json:"pricing"`
}

Domain Pricing represents the response of the domain pricing API

type ForwardType

type ForwardType string

Constants are the redirect types that can be assigned to a URL Forward

const (
	Temporary ForwardType = "temporary"
	Permanent ForwardType = "permanent"
)

type Keys

type Keys struct {
	// API Key usually starts with 'pk1_'
	APIKey string `json:"apikey"`
	// Secret key, usually starts with 'sk1_'
	SecretAPIKey string `json:"secretapikey"`
}

type Record

type Record struct {
	ID       string     `json:"id"`
	Name     string     `json:"name"`
	Type     RecordType `json:"type"`
	Content  string     `json:"content"`
	TTL      string     `json:"ttl"`
	Priority string     `json:"prio"`
	Notes    string     `json:"notes"`
}

DNS record

type RecordOptions

type RecordOptions struct {
	*Keys
	// ID of DNS record created
	ID string `json:"-"`
	// Second level domain
	Domain string `json:"-"`
	// The subdomain for the record being created or updated, not including the domain itself.
	// Leave blank to create/update record on root. Use * to create/update wildcard
	Name string `json:"name,omitempty"`
	// Type of record being created/updated
	Type RecordType `json:"type,omitempty"`
	// Answer content for the record.
	Content string `json:"content,omitempty"`
	// The time to live for the record. The minimum allowed and default
	// is 600 seconds
	TTL int `json:"ttl,omitempty"`
	// Priority of the record, for the record types that support it
	Priority int `json:"prio,omitempty"`
}

RecordOptions fields are those accepted by various methods

type RecordType

type RecordType string
const (
	A     RecordType = "A"
	MX    RecordType = "MX"
	CNAME RecordType = "CNAME"
	ALIAS RecordType = "ALIAS"
	TXT   RecordType = "TXT"
	NS    RecordType = "NS"
	AAAA  RecordType = "AAAA"
	SRV   RecordType = "SRV"
	TLSA  RecordType = "TLSA"
	CAA   RecordType = "CAA"
)

RecordType constants are the DNS record types that can be created

type SSLBundle

type SSLBundle struct {
	Status     string `json:"status"`
	IntermCert string `json:"intermediatecertificate"`
	CertChain  string `json:"certificatechain"`
	PrivateKey string `json:"privatekey"`
	PublicKey  string `json:"publickey"`
}

type SSLBundleOptions

type SSLBundleOptions struct {
	*Keys
	Domain string `json:"-"` // This field is not part of the request body
}

type URLForward

type URLForward struct {
	// Subdomain id
	Id string `json:"id"`
	// Name of subdomain
	Subdomain string `json:"subdomain"`
	// URL forwarding destination
	Location string `json:"location"`
	// Type of forward temporary or permanent
	Type ForwardType `json:"type"`
	// Whether URI path is included in redirection
	IncludePath BooleanType `json:"includePath"`
	//Forward all subdomains of this domain/subdomain
	Wildcard BooleanType `json:"wildcard"`
}

URL forward returned from porkbun API

type URLForwardOptions

type URLForwardOptions struct {
	*Keys
	// [Optional] A subdomain that you would like to add email forwarding for.
	SubDomain string `json:"subdomain,omitempty"`
	// Destination for URL forwarding
	Location string `json:"location"`
	//	Type of forward.
	//	Valid types: [permament,temporary]
	Type ForwardType `json:"type"`
	//	Include or don't include URI path in redirection.
	// Valid: [yes,no]
	IncludePath BooleanType `json:"includePath"`
	// Forward all subdomains of this domain
	// Valid: [yes,no]
	Wildcard BooleanType `json:"wildcard"`
	Domain   string      `json:"-"`
}

Options for creating a URL Forward

type UpdateNameServerOptions

type UpdateNameServerOptions struct {
	*Keys
	Nameservers []string `json:"ns"`
	Domain      string   `json:"-"`
}

UpdateNSOptions fields

Jump to

Keyboard shortcuts

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