v0.6.0 Latest Latest

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

Go to latest
Published: Jan 9, 2018 License: MIT Imports: 10 Imported by: 148




View Source
const (
	DynAPIPrefix = "https://api.dynect.net/REST"


View Source
var (
	PollingInterval  = 1 * time.Second
	ErrPromotedToJob = errors.New("promoted to job")
	ErrRateLimited   = errors.New("too many requests")


This section is empty.


type AllDSFDetailedResponse added in v0.3.0

type AllDSFDetailedResponse struct {
	Data []DSFService `json:"data"`

DSFSResponse is used for holding the data returned by a call to "https://api.dynect.net/REST/DSF/" with 'detail: Y'.

type AllRecordsResponse

type AllRecordsResponse struct {
	Data []string `json:"data"`

Type AllRecordsResponse is a struct for holding a list of all URIs returned from an HTTP GET call to either https://api.dynect.net/REST/AllRecord/<zone> or https://api/dynect.net/REST/AllRecord/<zone>/<FQDN>/.

type BaseRecord

type BaseRecord struct {
	FQDN       string    `json:"fqdn"`
	RecordId   int       `json:"record_id"`
	RecordType string    `json:"record_type"`
	TTL        int       `json:"ttl"`
	Zone       string    `json:"zone"`
	RData      DataBlock `json:"rdata"`

The base struct for record data returned from the Dyn REST API.

It should never be directly passed to the *Client.Do() function for marshaling response data to. Instead, it should aid in the composition of a more-specific response struct.

type Client

type Client struct {
	Token        string
	CustomerName string
	Transport    http.RoundTripper
	// contains filtered or unexported fields

A client for use with DynECT's REST API.

func NewClient

func NewClient(customerName string) *Client

Creates a new Httpclient.

func (*Client) Do

func (c *Client) Do(method, endpoint string, requestData, responseData interface{}) error

func (*Client) LoggedIn

func (c *Client) LoggedIn() bool

func (*Client) Login

func (c *Client) Login(username, password string) error

Establishes a new session with the DynECT API.

func (*Client) Logout

func (c *Client) Logout() error

func (*Client) SetTransport added in v0.6.0

func (c *Client) SetTransport(t http.RoundTripper)

Sets the transport for the client.

func (*Client) Verbose

func (c *Client) Verbose(p bool)

Enable, or disable verbose output from the client.

This will enable (or disable) logging messages that explain what the client is about to do, like the endpoint it is about to make a request to. If the request fails with an unexpected HTTP response code, then the response body will be logged out, as well.

type ConvenientClient added in v0.3.0

type ConvenientClient struct {

ConvenientClient A client with extra helper methods for common actions

func NewConvenientClient added in v0.3.0

func NewConvenientClient(customerName string) *ConvenientClient

NewConvenientClient Creates a new ConvenientClient

func (*ConvenientClient) CreateRecord added in v0.3.0

func (c *ConvenientClient) CreateRecord(record *Record) error

CreateRecord Method to create a DNS record

func (*ConvenientClient) CreateZone added in v0.6.0

func (c *ConvenientClient) CreateZone(zone, rname, serialStyle, ttl string) error

CreateZone method to create a zone

func (*ConvenientClient) DeleteRecord added in v0.3.0

func (c *ConvenientClient) DeleteRecord(record *Record) error

DeleteRecord Method to delete a DNS record

func (*ConvenientClient) DeleteZone added in v0.6.0

func (c *ConvenientClient) DeleteZone(zone string) error

DeleteZone method to delete a zone

func (*ConvenientClient) DeleteZoneNode added in v0.6.0

func (c *ConvenientClient) DeleteZoneNode(zone string) error

DeleteZoneNode method to delete everything in a zone

func (*ConvenientClient) GetRecord added in v0.3.0

func (c *ConvenientClient) GetRecord(record *Record) error

GetRecord Method to get record details

func (*ConvenientClient) GetRecordID added in v0.3.0

func (c *ConvenientClient) GetRecordID(record *Record) error

GetRecordID finds the dns record ID by fetching all records for a FQDN

func (*ConvenientClient) GetZone added in v0.6.0

func (c *ConvenientClient) GetZone(z *Zone) error

GetZone method to read a zone

func (*ConvenientClient) PublishZone added in v0.3.0

func (c *ConvenientClient) PublishZone(zone string) error

PublishZone Publish a specific zone and the changes for the current session

func (*ConvenientClient) UpdateRecord added in v0.3.0

func (c *ConvenientClient) UpdateRecord(record *Record) error

UpdateRecord Method to update a DNS record

type CreateZoneBlock added in v0.6.0

type CreateZoneBlock struct {
	RName       string `json:"rname"`
	SerialStyle string `json:"serial_style,omitempty"`
	TTL         string `json:"ttl"`

CreateZoneBlock holds the request body for a zone create

type DSFNode added in v0.3.0

type DSFNode struct {
	Zone string `json:"zone"`
	FQDN string `json:"fqdn"`

type DSFRecord added in v0.3.0

type DSFRecord struct {
	Status         string   `json:"status"`
	Endpoints      []string `json:"endpoints"`
	RDataClass     string   `json:"rdata_class"`
	Weight         int      `json:"weight"`
	Eligible       string   `json:"eligible"`
	ID             string   `json:"dsf_record_id"`
	DSFRecordSetID string   `json:"dsf_record_set_id"`
	//RData           interface{} `json:"rdata"`
	EndpointUpCount int    `json:"endpoint_up_count"`
	Label           string `json:"label"`
	MasterLine      string `json:"master_line"`
	Torpidity       int    `json:"torpidity"`
	LastMonitored   int    `json:"last_monitored"`
	TTL             string `json:"ttl"`
	DSFServiceID    string `json:"service_id"`
	PendingChange   string `json:"pending_change"`
	Automation      string `json:"automation"`
	ReponseTime     int    `json:"response_time"`
	Publish         string `json:"publish",omit_empty`

type DSFRecordSet added in v0.3.0

type DSFRecordSet struct {
	Status        string      `json:"status"`
	Eligible      string      `json:"eligible"`
	ID            string      `json:"dsf_record_set_id"`
	MonitorID     string      `json:"dsf_monitor_id"`
	Label         string      `json:"label"`
	TroubleCount  string      `json:"trouble_count"`
	Records       []DSFRecord `json:"records"`
	FailCount     string      `json:"fail_count"`
	TorpidityMax  string      `json:"torpidity_max"`
	TTLDerived    string      `json:"ttl_derived"`
	LastMonitored string      `json:"last_monitored"`
	TTL           string      `json:"ttl"`
	ServiceID     string      `json:"service_id"`
	ServeCount    string      `json:"serve_count"`
	Automation    string      `json:"automation"`
	PendingChange string      `json:"pending_change"`

type DSFRecordSetChain added in v0.3.0

type DSFRecordSetChain struct {
	ID                string         `json:"dsf_record_set_failover_chain_id"`
	Status            string         `json:"status"`
	Core              string         `json:"core"`
	Label             string         `json:"label"`
	DSFResponsePoolID string         `json:"dsf_response_pool_id"`
	DSFServiceID      string         `json:"service_id"`
	PendingChange     string         `json:"pending_change"`
	DSFRecordSets     []DSFRecordSet `json:"record_sets"`

type DSFResponse added in v0.3.0

type DSFResponse struct {
	Data DSFService `json:"data"`

DSFResponse is used for holding the data returned by a call to "https://api.dynect.net/REST/DSF/SERVICE_ID".

type DSFResponsePool added in v0.3.0

type DSFResponsePool struct {
	ID            string              `json:"dsf_response_pool_id"`
	Label         string              `json:"label"`
	Automation    string              `json:"automation"`
	CoreSetCount  string              `json:"core_set_count"`
	Eligible      string              `json:"eligible"`
	PendingChange string              `json:"pending_change"`
	RsChains      []DSFRecordSetChain `json:"rs_chains"`
	Rulesets      []DSFRuleset        `json:"rulesets"`
	Status        string              `json:"status"`
	LastMonitored string              `json:"last_monitored"`
	Notifier      string              `json:"notifier"`

type DSFRuleset added in v0.3.0

type DSFRuleset struct {
	ID            string            `json:"dsf_ruleset_id`
	Label         string            `json:"label"`
	CriteriaType  string            `json:"criteria_type"`
	Criteria      interface{}       `json:"criteria"`
	Ordering      string            `json:"ordering"`
	Eligible      string            `json:"eligible"`
	PendingChange string            `json:"pending_change"`
	ResponsePools []DSFResponsePool `json:"response_pools"`

type DSFService added in v0.3.0

type DSFService struct {
	ID            string       `json:"service_id"`
	Label         string       `json:"label"`
	Active        string       `json:"active"`
	TTL           string       `json:"ttl"`
	PendingChange string       `json:"pending_change"`
	Notifiers     []Notifier   `json:"notifiers"`
	Nodes         []DSFNode    `json:"nodes"`
	Rulesets      []DSFRuleset `json:"rulesets"`

Type DSFService is used as a nested struct, which holds the data for a DSF Service returned by a call to "https://api.dynect.net/REST/DSF/SERVICE_ID".

func GetAllDSFServicesDetailed added in v0.3.0

func GetAllDSFServicesDetailed(c *Client) (error, []DSFService)

func GetDSFServiceDetailed added in v0.3.0

func GetDSFServiceDetailed(c *Client, id string) (error, DSFService)

type DataBlock

type DataBlock struct {
	// A, AAAA
	Address string `json:"address,omitempty" bson:"address,omitempty"`

	Alias string `json:"alias,omitempty" bson:"alias,omitempty"`

	Algorithm string `json:"algorithm,omitempty" bson:"algorithm,omitempty"`

	// LOC
	Altitude string `json:"altitude,omitempty" bson:"altitude,omitempty"`

	CName string `json:"cname,omitempty" bson:"cname,omitempty"`

	// CERT
	Certificate string `json:"certificate,omitempty" bson:"algorithm,omitempty"`

	DName string `json:"dname,omitempty" bson:"dname,omitempty"`

	Digest string `json:"digest,omitempty" bson:"digest,omitempty"`

	// DS
	DigestType string `json:"digtype,omitempty" bson:"digest_type,omitempty"`

	// KX, MX
	Exchange string `json:"exchange,omitempty" bson:"exchange,omitempty"`

	FPType string `json:"fptype,omitempty" bson:"fp_type,omitempty"`

	Fingerprint string `json:"fingerprint,omitempty" bson:"fingerprint,omitempty"`

	Flags string `json:"flags,omitempty" bson:"flags,omitempty"`

	// CERT
	Format string `json:"format,omitempty" bson:"format,omitempty"`

	GatewayType string `json:"gatetype,omitempty" bson:"gateway_type,omitempty"`

	// LOC
	HorizPre string `json:"horiz_pre,omitempty" bson:"horiz_pre,omitempty"`

	// DS
	KeyTag string `json:"keytag,omitempty" bson:"keytag,omitempty"`

	// LOC
	Latitude string `json:"latitude,omitempty" bson:"latitude,omitempty"`

	// LOC
	Longitude string `json:"longitude,omitempty" bson:"longitude,omitempty"`

	// PX
	Map822 string `json:"map822,omitempty" bson:"map_822,omitempty"`

	// PX
	MapX400 string `json:"mapx400,omitempty" bson:"map_x400,omitempty"`

	// RP
	Mbox string `json:"mbox,omitempty" bson:"mbox,omitempty"`

	// NS
	NSDName string `json:"nsdname,omitempty" bson:"nsdname,omitempty"`

	// NSAP
	NSAP string `json:"nsap,omitempty" bson:"nsap,omitempty"`

	Order string `json:"order,omitempty" bson:"order,omitempty"`

	// SRV
	Port string `json:"port,omitempty" bson:"port,omitempty"`

	Precendence string `json:"precendence,omitempty" bson:"precendence,omitempty"`

	Preference int `json:"preference,omitempty" bson:"preference,omitempty"`

	// SRV
	Priority int `json:"priority,omitempty" bson:"priority,omitempty"`

	Protocol string `json:"protocol,omitempty" bson:"protocol,omitempty"`

	// PTR
	PTRDname string `json:"ptrdname,omitempty" bson:"ptrdname,omitempty"`

	PublicKey string `json:"public_key,omitempty" bson:"public_key,omitempty"`

	Regexp string `json:"regexp,omitempty" bson:"regexp,omitempty"`

	Replacement string `json:"replacement,omitempty" bson:"replacement,omitempty"`

	// SOA
	RName string `json:"rname,omitempty" bson:"rname,omitempty"`

	Services string `json:"services,omitempty" bson:"services,omitempty"`

	// LOC
	Size string `json:"size,omitempty" bson:"size,omitempty"`

	// CERT
	Tag string `json:"tag,omitempty" bson:"tag,omitempty"`

	// SRV
	Target string `json:"target,omitempty" bson:"target,omitempty"`

	// RP
	TxtDName string `json:"txtdname,omitempty" bson:"txtdname,omitempty"`

	// SPF, TXT
	TxtData string `json:"txtdata,omitempty" bson:"txtdata,omitempty"`

	// LOC
	Version string `json:"version,omitempty" bson:"version,omitempty"`

	// LOC
	VertPre string `json:"vert_pre,omitempty" bson:"vert_pre,omitempty"`

	// SRV
	Weight string `json:"weight,omitempty" bson:"weight,omitempty"`

Type DataBlock is nested within the BaseRecord struct, and is used for holding record information.

The comment above each field indicates which record types you can expect the information to be provided.

type JobData added in v0.3.0

type JobData struct {
	Status   string         `json:"status"`
	Data     interface{}    `json:"data"`
	ID       int            `json:"job_id"`
	Messages []MessageBlock `json:"msgs"`

type LoginBlock

type LoginBlock struct {
	Username     string `json:"user_name"`
	Password     string `json:"password"`
	CustomerName string `json:"customer_name"`

This struct represents the request body that would be sent to the DynECT API for logging in and getting a session token for future requests.

type LoginDataBlock

type LoginDataBlock struct {
	Token   string `json:"token"`
	Version string `json:"version"`

Type LoginDataBlock holds the token and API version information from an HTTP POST call to https://api.dynect.net/REST/Session/.

It is nested within the LoginResponse struct.

type LoginResponse

type LoginResponse struct {
	Data LoginDataBlock `json:"data"`

Type LoginResponse holds the data returned by an HTTP POST call to https://api.dynect.net/REST/Session/.

type MessageBlock

type MessageBlock struct {
	Info      string `json:"INFO"`
	Source    string `json:"SOURCE"`
	ErrorCode string `json:"ERR_CD"`
	Level     string `json:"LVL"`

Type MessageBlock holds the message information from the server, and is nested within the ResponseBlock type.

type Notifier added in v0.3.0

type Notifier struct {
	ID         int    `json:"notifier_id"`
	Label      string `json:"label"`
	Recipients string `json:"recipients"`
	Active     string `json:"active"`

type PublishZoneBlock added in v0.3.0

type PublishZoneBlock struct {
	Publish bool `json:"publish"`

PublishZoneBlock holds the request body for a publish zone request https://help.dyn.com/update-zone-api/

type Record added in v0.3.0

type Record struct {
	ID    string
	Zone  string
	Name  string
	Value string
	Type  string
	FQDN  string
	TTL   string

Record simple struct to hold record details

type RecordRequest added in v0.3.0

type RecordRequest struct {
	RData DataBlock `json:"rdata"`
	TTL   string    `json:"ttl,omitempty"`

RecordRequest holds the request body for a record create/update

type RecordResponse

type RecordResponse struct {
	Data BaseRecord `json:"data"`

Type RecordResponse is used to hold the information for a single DNS record returned from Dyn's DynECT API.

type ResponseBlock

type ResponseBlock struct {
	Status   string         `json:"status"`
	JobId    int            `json:"job_id,omitempty"`
	Messages []MessageBlock `json:"msgs,omitempty"`

Type ResponseBlock holds the "header" information returned by any call to the DynECT API.

All response-type structs should include this as an anonymous/embedded field.

type Zone added in v0.6.0

type Zone struct {
	Serial      string
	SerialStyle string
	Zone        string
	Type        string

Zone struct to hold record details

type ZoneDataBlock

type ZoneDataBlock struct {
	Serial      int    `json:"serial"`
	SerialStyle string `json:"serial_style"`
	Zone        string `json:"zone"`
	ZoneType    string `json:"zone_type"`

Type ZoneDataBlock is used as a nested struct, which holds the data for a zone returned by a call to "https://api.dynect.net/REST/Zone/ZONE_NAME".

type ZoneResponse

type ZoneResponse struct {
	Data ZoneDataBlock `json:"data"`

ZoneResponse is used for holding the data returned by a call to "https://api.dynect.net/REST/Zone/ZONE_NAME".

type ZonesResponse

type ZonesResponse struct {
	Data []string `json:"data"`

ZonesResponse is used for holding the data returned by a call to "https://api.dynect.net/REST/Zone/".

Jump to

Keyboard shortcuts

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