dreamhostapi

package module
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package dreamhostapi contains functions for interacting with the Dreamhost API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UpdateDNSRecord

func UpdateDNSRecord(domain string, currentIP string, newIPAddress string, apiKey string, comment string) (commandResult, commandResult, error)

updateDNSRecord returns a commandResult after using the Dreamhost API to first add the new IP address and, if successful, deleting the old one. If adding a record does not succeed, either through underlying error (web, JSON unmarshalling) or because the API was not successful, it will not continue to the deletion.

func UpdateZoneFile

func UpdateZoneFile(command string, domain string, IPAddress string, apiKey string, comment string) (commandResult, error)

UpdateZoneFile returns a commandResult after using the Dreamhost API to either add or delete an IP address from a domain in Dreamhost and any errors. In the case of a success, it should only contain one record in the slice. It returns an empty struct in the case of any errors in the web-layer, JSON demarshalling, or API non-success result. Currently implemented commands for the command parameter are:

  • "add" to add a value (typically IP address) to a record (typically a domain).
  • "del" to remove a value (typically IP address) from a record (typically a domain).

func WebGet

func WebGet(url string) (string, int, error)

webGet returns the body as a string, an int representing the HTTP status code, and any errors.

Types

type DnsRecord

type DnsRecord struct {
	Record    string // the URL
	Zone      string // This is the base of the URL. If Record is www.google.com, Zone is google.com
	Value     string // this is what the zone points to - usually IP address
	Editable  string // 0 or 1 value, but comes back as a string
	ZoneType  string `json:"type"` // zone type: A,CNAME,NS,NAPTR,SRV,TXT, or AAAA
	Comment   string // comment that can be added to a record
	AccountId string `json:"account_id"` // the account associated with this record
}

DnsRecord is a DNS Record on Dreamhost

func (DnsRecord) String

func (r DnsRecord) String() string

type DnsRecords

type DnsRecords struct {
	Data   []DnsRecord `json:"data"`
	Result string      `json:"result"`
}

dnsRecords holds an array of DnsRecord structs returned by the Dreamhost API

func GetDNSRecords

func GetDNSRecords(apiKey string) (DnsRecords, error)

getDNSRecords returns a DnsRecords struct containing all of the DNS records that correspond to this apiKey and any errors. It returns an empty struct in the case of any errors in the web-layer, JSON demarshalling, or API non-success result.

type DreamhostAPIError

type DreamhostAPIError string

func (DreamhostAPIError) Error

func (apiErr DreamhostAPIError) Error() string

Jump to

Keyboard shortcuts

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