porkbun

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: MPL-2.0 Imports: 9 Imported by: 12

README

Go library for accessing the Porkbun API

Build Status PkgGoDev Go Report Card

An Porkbun API client written in Go.

porkbun is a Go client library for accessing the Porkbun API.

Examples

package main

import (
	"context"
	"fmt"

	"github.com/nrdcg/porkbun"
)

func main() {
	client := porkbun.New("secret", "key")

	ctx := context.Background()

	yourIP, err := client.Ping(ctx)
	if err != nil {
		panic(err)
	}

	fmt.Println(yourIP)
}

API Documentation

Documentation

Overview

Package porkbun contains a client of the DNS API of Porkdun.

Index

Constants

View Source
const DefaultTTL = "300"

DefaultTTL The minimum and the default is 300 seconds.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL    *url.URL
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

Client an API client for Porkdun.

func New

func New(secretAPIKey, apiKey string) *Client

New creates a new Client.

func (*Client) CreateRecord

func (c *Client) CreateRecord(ctx context.Context, domain string, record Record) (int, error)

CreateRecord creates a DNS record.

name (optional): The subdomain for the record being created, not including the domain itself. Leave blank to create a record on the root domain. Use * to create a wildcard record.
type: The type of record being created. Valid types are: A, MX, CNAME, ALIAS, TXT, NS, AAAA, SRV, TLSA, CAA
content: The answer content for the record.
ttl (optional): The time to live in seconds for the record. The minimum and the default is 300 seconds.
prio (optional) The priority of the record for those that support it.

func (*Client) DeleteRecord

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

DeleteRecord deletes a specific DNS record.

func (*Client) EditRecord

func (c *Client) EditRecord(ctx context.Context, domain string, id int, record Record) error

EditRecord edits a DNS record.

name (optional): The subdomain for the record being created, not including the domain itself. Leave blank to create a record on the root domain. Use * to create a wildcard record.
type: The type of record being created. Valid types are: A, MX, CNAME, ALIAS, TXT, NS, AAAA, SRV, TLSA, CAA
content: The answer content for the record.
ttl (optional): The time to live in seconds for the record. The minimum and the default is 300 seconds.
prio (optional) The priority of the record for those that support it.

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) (string, error)

Ping tests communication with the API.

func (*Client) RetrieveRecords

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

RetrieveRecords retrieve all editable DNS records associated with a domain.

func (*Client) RetrieveSSLBundle added in v0.3.0

func (c *Client) RetrieveSSLBundle(ctx context.Context, domain string) (SSLBundle, error)

RetrieveSSLBundle retrieve the SSL certificate bundle for the domain.

type Record

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

Record a DNS record.

type SSLBundle added in v0.3.0

type SSLBundle struct {
	IntermediateCertificate string `json:"intermediatecertificate"`
	CertificateChain        string `json:"certificatechain"`
	PrivateKey              string `json:"privatekey"`
	PublicKey               string `json:"publickey"`
}

SSLBundle a SSL certificate bundle.

type ServerError added in v0.2.0

type ServerError struct {
	StatusCode int    `json:"statusCode"`
	Message    string `json:"message,omitempty"`
}

ServerError the API server error.

func (ServerError) Error added in v0.2.0

func (a ServerError) Error() string

type Status

type Status struct {
	Status  string `json:"status"`
	Message string `json:"message,omitempty"`
}

Status the API response status.

func (Status) Error

func (a Status) Error() string

Jump to

Keyboard shortcuts

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