dnsimple

package module
Version: v0.0.0-...-0adf7d0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2016 License: MPL-2.0 Imports: 11 Imported by: 157

README

dnsimple

This package provides the dnsimple package which offers an interface to the DNSimple API.

It's intentionally designed to make heavy use of built-ins and strings in place of custom data structures and proper types. It also only implements specific endpoints, and doesn't have full API coverage.

For those reasons, I recommend looking elsewhere if you just need a standard DNSimple API client.

Documentation

The full documentation is available on Godoc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeRecord

type ChangeRecord struct {
	Name  string // name of the record
	Value string // where the record points
	Type  string // type, i.e a, mx
	Ttl   string // TTL of record
}

ChangeRecord contains the request parameters to create or update a record.

type Client

type Client struct {
	// Access Token
	Token string

	// User Email
	Email string

	// Domain Token
	DomainToken string

	// URL to the DO API to use
	URL string

	// HttpClient is the client to use. A client with
	// default values will be used if not provided.
	Http *http.Client
}

Client provides a client to the DNSimple API

func NewClient

func NewClient(email string, token string) (*Client, error)

NewClient returns a new dnsimple client, requires an authorization token. You can generate an OAuth token by visiting the Apps & API section of the DNSimple control panel for your account.

func NewClientWithDomainToken

func NewClientWithDomainToken(domainToken string) (*Client, error)

func (*Client) CreateRecord

func (c *Client) CreateRecord(domain string, opts *ChangeRecord) (string, error)

CreateRecord creates a record from the parameters specified and returns an error if it fails. If no error and an ID is returned, the Record was succesfully created.

func (*Client) DestroyRecord

func (c *Client) DestroyRecord(domain string, id string) error

DestroyRecord destroys a record by the ID specified and returns an error if it fails. If no error is returned, the Record was succesfully destroyed.

func (*Client) GetDomains

func (c *Client) GetDomains() ([]Domain, error)

GetDomains retrieves all the domains for a given account.

func (*Client) GetRecords

func (c *Client) GetRecords(domain string) ([]Record, error)

GetRecords retrieves all the records for the given domain.

func (*Client) NewRequest

func (c *Client) NewRequest(body map[string]interface{}, method string, endpoint string) (*http.Request, error)

Creates a new request with the params

func (*Client) RetrieveRecord

func (c *Client) RetrieveRecord(domain string, id string) (*Record, error)

RetrieveRecord gets a record by the ID specified and returns a Record and an error. An error will be returned for failed requests with a nil Record.

func (*Client) UpdateRecord

func (c *Client) UpdateRecord(domain string, id string, opts *ChangeRecord) (string, error)

UpdateRecord updated a record from the parameters specified and returns an error if it fails.

type DNSimpleError

type DNSimpleError struct {
	Errors map[string][]string `json:"errors"`
}

DNSimpleError is the error format that they return to us if there is a problem

func (*DNSimpleError) Join

func (d *DNSimpleError) Join() string

type Domain

type Domain struct {
	Id             int       `json:"id"`
	UserId         int       `json:"user_id"`
	RegistrantId   int       `json:"registrant_id"`
	Name           string    `json:"name"`
	UnicodeName    string    `json:"unicode_name"`
	Token          string    `json:"token"`
	State          string    `json:"state"`
	Language       string    `json:"language"`
	Lockable       bool      `json:"lockable"`
	AutoRenew      bool      `json:"auto_renew"`
	WhoisProtected bool      `json:"whois_protected"`
	RecordCount    int       `json:"record_count"`
	ServiceCount   int       `json:"service_count"`
	ExpiresOn      string    `json:"expires_on"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
}

type DomainResponse

type DomainResponse struct {
	Domain Domain `json:"domain"`
}

type Record

type Record struct {
	Name       string `json:"name"`
	Content    string `json:"content"`
	DomainId   int64  `json:"domain_id"`
	Id         int64  `json:"id"`
	Prio       int64  `json:"prio"`
	RecordType string `json:"record_type"`
	Ttl        int64  `json:"ttl"`
}

Record is used to represent a retrieved Record. All properties are set as strings.

func (*Record) StringDomainId

func (r *Record) StringDomainId() string

Returns the domain id

func (*Record) StringId

func (r *Record) StringId() string

Returns the id

func (*Record) StringPrio

func (r *Record) StringPrio() string

Returns the string for prio

func (*Record) StringTtl

func (r *Record) StringTtl() string

Returns the string for Locked

type RecordResponse

type RecordResponse struct {
	Record Record `json:"record"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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