api

package
v0.0.0-...-7a54e0b Latest Latest
Warning

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

Go to latest
Published: May 17, 2019 License: MIT Imports: 7 Imported by: 2

Documentation

Overview

Package api provides a basic interface for dealing with Name.com DNS API's.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

API Contains details required to access the Name.com API.

func NewAPIFromConfig

func NewAPIFromConfig(c Config) API

NewAPIFromConfig constructs a new Name.com API from a configuration.

func NewNameAPI

func NewNameAPI(username, token string, dev bool) API

NewNameAPI constructs a new Name.com API. If dev is true, then the API uses the development API, instead of the production API.

func (API) CreateDNSRecord

func (api API) CreateDNSRecord(domain string, record DNSRecord) error

CreateDNSRecord creates a DNS record for a given domain. The name field in DNSRecord is in the format [hostname].[domainname]

func (API) DeleteDNSRecord

func (api API) DeleteDNSRecord(domain, recordID string) error

DeleteDNSRecord deletes a DNS record for a given domain. The recordID can be retreived from GetDNSRecords.

func (API) GetDNSRecords

func (api API) GetDNSRecords(domain string) (records []DNSRecord, err error)

GetDNSRecords returns a slice of DNS records associated with a given domain.

type Config

type Config struct {
	Dev       bool     `json:"dev"`
	Domain    string   `json:"domain"`
	Hostnames []string `json:"hostnames"`
	Interval  int      `json:"interval"`
	Token     string   `json:"token"`
	Username  string   `json:"username"`
}

Config represents the configuration for a specific domain. Each domain can have multiple hostnames, including the root domain, where hostname is an empty string.

The interval is the polling time (in seconds) for daemon mode.

func LoadConfigs

func LoadConfigs(path string) ([]Config, error)

LoadConfigs loads configurations from a file. The configuration is stored as an array of JSON serialized Config structs.

type DNSRecord

type DNSRecord struct {
	RecordID   string `json:"record_id"`
	Name       string `json:"name"`
	Type       string `json:"type"`
	Content    string `json:"content"`
	TTL        string `json:"ttl"`
	CreateDate string `json:"create_date"`
}

DNSRecord contains information about a Name.com DNS record.

Jump to

Keyboard shortcuts

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