dnsmadeeasy

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 9 Imported by: 4

README

DNS Made Easy API client

Go Reference

A Golang client for DNS Made Easy against their APIv2 endpoints

Testing

Create a .env file containing the varibles DME_API_TOKEN and DME_API_SECRET using credentials from your DNS Made Easy Sandbox account, then run go test -v

NOTE: depending on the load on the DNS Made Easy sandbox environment, it may take an inordinate amount of time to finish creating the two domains that are created during testing. If either of the TestSandboxIntegration/Cleanup_test_domains calls fail, it will be necessary to manually delete those domains.

Documentation

Index

Constants

View Source
const (
	DNSManagedPath string = "/dns/managed/"
	DNSRecordsPath string = "{domainId}/records"
	DNSRecordPath  string = "{domainId}/records/{recordId}"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseURL

type BaseURL string
const (
	Sandbox BaseURL = "https://api.sandbox.dnsmadeeasy.com/V2.0/"
	Prod    BaseURL = "https://api.dnsmadeeasy.com/V2.0/"
)

type Client

type Client struct {
	APIKey    string
	SecretKey string
	BaseURL   BaseURL
	// contains filtered or unexported fields
}

func GetClient

func GetClient(APIKey string, SecretKey string, url BaseURL) *Client

Construct a client using the supplied values

func (*Client) CreateDomain added in v1.0.0

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

Creates a new domain

func (*Client) CreateRecord added in v0.1.2

func (c *Client) CreateRecord(domainId int, record Record) (Record, error)

Creates a single record in the supplied domain

func (*Client) CreateRecords added in v0.1.2

func (c *Client) CreateRecords(domainId int, records []Record) ([]Record, error)

Create many records at once in the supplied domain

NOTE: is transactional; an error in creating any record causes none to be created

func (*Client) DeleteAllRecords added in v1.0.0

func (c *Client) DeleteAllRecords(domainID int) error

Deletes all records for the supplied domain

func (*Client) DeleteDomain added in v1.0.0

func (c *Client) DeleteDomain(domainID int) error

Removes a domain and all associated records

func (*Client) DeleteRecords added in v0.1.2

func (c *Client) DeleteRecords(domainId int, recordIds []int) ([]int, error)

Deletes records with numerical IDs for the supplied domain

NOTE: will silently continue if a recordId that doesn't belong to the given domainId is passed

func (*Client) EnumerateDomains

func (c *Client) EnumerateDomains() (map[string]int, error)

Returns a map of Name:ID for all domains managed by the given account

func (*Client) EnumerateRecords

func (c *Client) EnumerateRecords(domainId int) ([]Record, error)

func (*Client) GetDomain added in v1.0.0

func (c *Client) GetDomain(domainID int) (Domain, error)

Returns the domain record for a given domain ID

func (*Client) IdForDomain added in v0.1.2

func (c *Client) IdForDomain(domain string) (int, error)

Finds the numerical ID for a given domain name

func (*Client) UpdateRecords added in v0.1.4

func (c *Client) UpdateRecords(domainId int, records []Record) ([]Record, error)

type Domain

type Domain struct {
	ID                 int      `json:"id"`
	Name               string   `json:"name"`
	CreatedAt          int      `json:"created"`
	UpdatedAt          int      `json:"updated"`
	FolderID           int      `json:"folderId"`
	ProcessMulti       bool     `json:"processMulti"`
	ActiveThirdParties []string `json:"activeThirdParties"`
	GtdEnabled         bool     `json:"gtdEnabled"`

	// Identifies which action is currently pending
	// Values:
	//  0 - nothing pending
	//  1 - pending creation (usable but not fully created throughout the system)
	//  3 - pending deletion
	PendingActionID int `json:"pendingActionId"`
}

type DomainsResp

type DomainsResp struct {
	TotalRecords int      `json:"totalRecords"`
	TotalPages   int      `json:"totalPages"`
	Domains      []Domain `json:"data"`
	CurrentPage  int      `json:"page"`
}

type Record

type Record struct {
	// A unique name per record Type
	Name string `json:"name"`

	// A unique identifier for this record
	ID int `json:"id,omitempty"`

	// Can be one of: A, AAAA, ANAME, CNAME, HTTPRED, MX
	//                NS, PTR, SRV, TXT, SPF, or SOA
	Type string `json:"type"`

	// Differs per record type
	Value string `json:"value"`

	// 1 if the record is the record is domain specific
	// 0 if the record is part of a template
	Source int `json:"source,omitempty"`

	// The time to live of the record
	Ttl int `json:"ttl"`

	// Global Traffic Director location.
	// Values: DEFAULT, US_EAST, US_WEST, EUROPE,
	//         ASIA_PAC, OCREANIA, SOUTH_AMERICA
	GtdLocation string `json:"gtdLocation"`

	// The domain ID of this record
	SourceId int `json:"sourceId,omitempty"`

	// Indicates if DNS Failover is enabled for an A record
	Failover bool `json:"failover,omitempty"`

	// Indicates if System Monitoring is enabled for an A record
	Monitor bool `json:"monitor,omitempty"`

	// For HTTP Redirection Records
	HardLink bool `json:"hardLink,omitempty"`

	// Indicates if the record has dynamic DNS enabled
	DynamicDns bool `json:"dynamicDns,omitempty"`

	// Indicates if an A record is in failed status
	Failed bool `json:"failed,omitempty"`

	// The priority for an MX record
	MxLevel int `json:"mxLevel,omitempty"`

	// The priority for an SRV record
	Priority int `json:"priority,omitempty"`

	// The weight for an SRV record
	Weight int `json:"weight,omitempty"`

	// The port for an SRV record
	Port int `json:"port,omitempty"`
}

type RecordsResp

type RecordsResp struct {
	TotalRecords int      `json:"totalRecords"`
	TotalPages   int      `json:"totalPages"`
	Records      []Record `json:"data"`
	CurrentPage  int      `json:"page"`
}

Jump to

Keyboard shortcuts

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