Help us shape the future of Go! Take the 2026 Go Developer Survey

dnsmadeeasy

package module
v0.0.0-...-37c0bc8 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2014 License: BSD-2-Clause Imports: 10 Imported by: 0

README

dnsmadeeasy

DNS Made Easy Golang Api

This API is a work in progress and is not production ready.

Please feel free to report bugs, fix bugs, implement missing API calls and do pull requests.

I'm also new to go, so please feel free to comment on the code itself, pointing out flaws, non idiomatic go, and other mistakes!

How to install?

go get github.com/huguesalary/dnsmadeeasy

How to use?

package main

import (
	"github.com/huguesalary/dnsmadeeasy"
)

func main() {
	client := dnsmadeeasy.NewClient("yourapikey", "yourapisecret")
	domain := client.CreateDomain("yourdomain.com")

	record := &dnsmadeeasy.Record{}
	record.Type = "A"
	record.Name = "a-record"
	record.Value = "127.0.0.1"
	record.GtdLocation = "DEFAULT"
	record.Ttl = 86600
	client.AddRecord(domain.Id, rec)
}

Known Issue(s)

  • Because the DNS Made Easy test API SSL certificates are not valid, the code forcefully disable SSL verification. This will be fixed soon.

Documentation

Overview

package dnsmadeeasy provides a client for the DNS Made Easy API The API Reference is currently available at: http://www.dnsmadeeasy.com/wp-content/uploads/2014/07/API-Docv2.pdf

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Code     int      `json:"-"`
	Messages []string `json:"error"`
}

Represents an API Error. Code corresponds to the HTTP Status Code returned by the API. Messages is a list of error messages returned by the DNS Made Easy API

func (*APIError) Error

func (a *APIError) Error() string

type Client

type Client struct {
	APIKey    string
	APISecret string
	Version   string
	Url       string
}

A Client is the basic type of this package. It provides methods for interacting with the DNS Made Easy API.

func NewClient

func NewClient(key, secret string) *Client

NewClient returns an instance of Client ready to be used for communication with DNS Made Easy's API

func (*Client) AddRecord

func (c *Client) AddRecord(domainId uint32, record *Record) error

func (*Client) CreateDomain

func (c *Client) CreateDomain(domainName string) (*Domain, error)

func (*Client) CreateDomains

func (c *Client) CreateDomains(domainNames []string) ([]uint32, error)

CreateDomains creates all the domains passed in its argument. When multiple domains are created at once, the API only returns domain ids.

func (*Client) DelRecord

func (c *Client) DelRecord(domainId, recordId uint32) error

func (*Client) DeleteDomain

func (c *Client) DeleteDomain(id uint32) error

func (*Client) DeleteDomains

func (c *Client) DeleteDomains(ids []uint32) error

func (*Client) GetDomainById

func (c *Client) GetDomainById(id uint32) (*Domain, error)

func (*Client) GetDomainByName

func (c *Client) GetDomainByName(name string) (*Domain, error)

func (*Client) GetDomainRecords

func (c *Client) GetDomainRecords(id uint32) ([]*Record, error)

func (*Client) GetDomains

func (c *Client) GetDomains() (*DomainList, error)

func (*Client) UpdDomains

func (c *Client) UpdDomains(ids []uint32, fields map[string]interface{}) error

func (*Client) UpdRecord

func (c *Client) UpdRecord(domainId uint32, record *Record) error

type Domain

type Domain struct {
	ActiveThirdParties  []string
	Created             int64
	DelegateNameServers []string
	FolderId            int
	GtdEnabled          bool
	Id                  uint32
	Name                string
	NameServers         []struct {
		Fqdn string
		Ipv4 net.IP
		Ipv6 net.IP
	}
	PendingActionId int
	ProcessMulti    bool
	Updated         int64
}

Domain represents a DNS Made Easy domain

type DomainList

type DomainList struct {
	Domains      []Domain `json:"data"`
	Page         int
	TotalPages   int
	TotalRecords int
}

DomainList represents a list of Domains

type DomainRecords

type DomainRecords struct {
	Records      []*Record `json:"data"`
	Domain       Domain
	Page         int
	TotalPages   int
	TotalRecords int
}

DomainRecords holds a list of Records associated to a specific Domain

type Record

type Record struct {
	DynamicDns  bool     `json:",omitempty"`
	Failed      bool     `json:",omitempty"`
	Failover    bool     `json:",omitempty"`
	GtdLocation string   `json:"gtdLocation"`
	HardLink    bool     `json:",omitempty"`
	Id          uint32   `json:"id,omitempty"`
	Monitor     bool     `json:",omitempty"`
	Name        string   `json:"name"`
	Source      int      `json:",omitempty"`
	SourceId    int      `json:",omitempty"`
	Ttl         int      `json:"ttl"`
	Type        string   `json:"type"`
	Value       string   `json:"value"`
	Error       []string `json:"error,omitempty"`
}

A Record represents a DNS record (A, CNAME, AAAA, etc.)

Jump to

Keyboard shortcuts

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