godaddygo

package module
v1.3.20 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2021 License: MIT Imports: 10 Imported by: 8

README

godaddygo

Check us out on pkg.go.dev


Table of Contents


Intro


Pull requests welcome! We would like to eventually support each GoDaddy Gateway endpoint, not just domain/DNS related tasks

Installation

  • go get -u github.com/oze4/godaddygo
  • See here for more on how to obtain an Gateway key and Gateway secret from GoDaddy (click 'Gateway Keys')

Usage

Basic Usage

Bare minimum what you need to get started (aka how you will typically use this package):

package main

import (
	"github.com/oze4/godaddygo"
)

func main() {
	key := "<your_key>"
	secret := "<your_secret>"

	// Target production GoDaddy API
	// 99% of the time this is what you are looking for
	api, err := godaddygo.NewProduction(key, secret)
	if err != nil {
		panic(err.Error())
	}
	
	// Target version 1 of production API
	godaddy := api.V1() 

	// Now have access to all GoDaddy production V1 Gateway endpoints (via `godaddy`)
	dom := godaddy.Domain("foo.bar")
	// Get domain details
	dom.GetDetails(ctx)
	// Domain records
	domRecs := myDomain.Records()
	domRecs.List(ctx)
	domRecs.Add(ctx, someDNSRecord)
	domRecs.FindByType(ctx, godaddygo.RecordTypeA)
	// View all domains for your account
	godaddy.ListDomains(ctx)
	// Check availability for domain
	godaddy.CheckAvailability(ctx, "baz.bar")
	// Purchase domain
	godaddy.Purchase(ctx, myNewDomain)

	// etc...
}

Custom Client

package main

import (
	"net/http"

	"github.com/oze4/godaddygo"
)

func main() {
	key := "<your_key>"
	secret := "<your_secret>"
	// Target production API (godaddygo.APIDevEnv | godaddygo.APIProdEnv)
	target := godaddygo.APIProdEnv 

	// Build new config
	myConfig := godaddygo.NewConfig(key, secret, target)
	// Build custom client
	myClient := &http.Client{}

	// Establish "connection" with API
	api, err := godaddygo.WithClient(myClient, myConfig)
	if err != nil {
		panic(err.Error())
	}

	// Target version 1 of the production API
	godaddy := api.V1()

	// Now have access to all GoDaddy production V1 Gateway endpoints (via `godaddy`)
	dom := godaddy.Domain("foo.bar")
	// Get domain details
	dom.GetDetails(ctx)
	// Domain records
	domRecs := myDomain.Records()
	domRecs.List(ctx)
	domRecs.Add(ctx, someDNSRecord)
	domRecs.FindByType(ctx, godaddygo.RecordTypeA)
	// View all domains for your account
	godaddy.ListDomains(ctx)
	// Check availability for domain
	godaddy.CheckAvailability(ctx, "baz.bar")
	// Purchase domain
	godaddy.Purchase(ctx, myNewDomain)

	// etc...
}

Features

Please see here for more information on GoDaddy Gateway endpoints

  • Abuse
  • Aftermarket
  • Agreements
  • Certificates
  • Countries
  • Domains
    • Check domain availability
    • Get all DNS records
    • Get all DNS records of specific type
    • Get specific DNS record
    • Set DNS record(s)
    • Add/create DNS record(s)
    • Purchase domain
    • Purchase privacy for domain
    • Remove privacy for domain
  • Orders
  • Shoppers
  • Subscriptions




mattoestreich.com


Documentation

Index

Constants

View Source
const (
	// Env variables - which godaddy api to target
	APIProdEnv APIEnv = "prod"
	APIDevEnv         = "dev"

	// Allowed API Versions - which version of the godaddy api to target
	APIVersion1 APIVersion = "v1"
	APIVersion2            = "v2"

	// DNS record types
	RecordTypeA     RecordType = "A"
	RecordTypeAAAA             = "AAAA"
	RecordTypeCNAME            = "CNAME"
	RecordTypeMX               = "MX"
	RecordTypeNS               = "NS"
	RecordTypeSOA              = "SOA"
	RecordTypeSRV              = "SRV"
	RecordTypeTXT              = "TXT"

	// Domain statuses (added "Domain" prefix to legacy constants)
	DomainStatusActive    = "ACTIVE"
	DomainStatusCancelled = "CANCELLED"
	// Legacy Domain statuses (to support rename)
	StatusActive    = "ACTIVE"
	StatusCancelled = "CANCELLED"
)

Constants

View Source
const (
	// MaxHTTPClientTimeout in seconds is the defalt max http client timeout
	// https://medium.com/@nate510/don-t-use-go-s-default-http-client-4804cb19f779
	// 1 minute by default
	MaxHTTPClientTimeout = time.Second * 60
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API added in v1.3.1

type API interface {
	V1() V1
	V2() V2
}

API knows which version to target

func NewDevelopment added in v1.3.6

func NewDevelopment(key string, secret string) (API, error)

NewDevelopment targets GoDaddy development API

func NewProduction added in v1.3.6

func NewProduction(key string, secret string) (API, error)

NewProduction targets GoDaddy production API

func WithClient added in v1.3.1

func WithClient(client *http.Client, config *Config) (API, error)

WithClient returns API using your own `*http.Client`

type APIEnv added in v1.3.18

type APIEnv string

APIEnv represents which endpoint to target (dev|prod)

func (APIEnv) IsValid added in v1.3.20

func (e APIEnv) IsValid() bool

IsValid determines whether or not the given api env is valid

func (APIEnv) String added in v1.3.18

func (e APIEnv) String() string

type APIURL added in v1.3.18

type APIURL string

APIURL represents which URL to target

func (APIURL) IsValid added in v1.3.20

func (u APIURL) IsValid() bool

IsValid determines whether or not the given api url is valid

func (APIURL) String added in v1.3.18

func (u APIURL) String() string

type APIVersion added in v1.3.18

type APIVersion string

APIVersion represents which endpoint version to target (v1|v2)

func (APIVersion) IsValid added in v1.3.20

func (v APIVersion) IsValid() bool

IsValid determines whether or not the given api version is valid

func (APIVersion) String added in v1.3.18

func (v APIVersion) String() string

type AddressMailing added in v1.3.1

type AddressMailing struct {
	Address    string `json:"address1,omitempty"`
	Address2   string `json:"address2,omitempty"`
	City       string `json:"city,omitempty"`
	Country    string `json:"country,omitempty"`
	PostalCode string `json:"postalCode,omitempty"`
	State      string `json:"state,omitempty"`
}

AddressMailing defines a mailing address

func (*AddressMailing) FullAddress added in v1.3.8

func (am *AddressMailing) FullAddress() string

FullAddress returns the full address (Address + Address2)

type Config added in v1.3.2

type Config struct {
	// contains filtered or unexported fields
}

Config holds connection options. Use `.NewConfig` to create a new config

func NewConfig added in v1.3.2

func NewConfig(key, secret string, env APIEnv) *Config

NewConfig creates a new config

type Contact added in v1.3.1

type Contact struct {
	AddressMailing AddressMailing
	Email          string
	Fax            string
	JobTitle       string
	NameFirst      string
	NameLast       string
	NameMiddle     string
	Organization   string
	Phone          string
}

Contact defines the details of a contact

type Domain added in v1.3.1

type Domain interface {
	Records() Records
	GetDetails(ctx context.Context) (*DomainDetails, error)
}

Domain knows how to interact with the Domains GoDaddy Gateway endpoint

type DomainAvailability added in v1.3.8

type DomainAvailability struct {
	Available  bool   `json:"available,omitempty"`
	Currency   string `json:"currency,omitempty"`
	Definitive bool   `json:"definitive,omitempty"`
	Domain     string `json:"domain,omitempty"`
	Period     int    `json:"period,omitempty"`
	Price      int    `json:"price,omitempty"`
}

DomainAvailability holds data about domain availability

type DomainDetails added in v1.3.1

type DomainDetails struct {
	AuthCode               string        `json:"authCode,omitempty"`
	ContactAdmin           Contact       `json:"contactAdmin,omitempty"`
	ContactBilling         Contact       `json:"contactBilling,omitempty"`
	ContactRegistrant      Contact       `json:"contactRegistrant,omitempty"`
	ContactTech            Contact       `json:"contactTech,omitempty"`
	CreatedAt              time.Time     `json:"createdAt,omitempty"`
	DeletedAt              time.Time     `json:"deletedAt,omitempty"`
	TransferAwayEligibleAt time.Time     `json:"transferAwayEligibleAt,omitempty"`
	Domain                 string        `json:"domain,omitempty"`
	DomainID               int           `json:"domainId,omitempty"`
	ExpirationProtected    bool          `json:"expirationProtected,omitempty"`
	Expires                time.Time     `json:"expires,omitempty"`
	ExposeWhois            bool          `json:"exposeWhois,omitempty"`
	HoldRegistrar          bool          `json:"holdRegistrar,omitempty"`
	Locked                 bool          `json:"locked,omitempty"`
	NameServers            []string      `json:"nameServers,omitempty"`
	Privacy                bool          `json:"privacy,omitempty"`
	RenewAuto              bool          `json:"renewAuto,omitempty"`
	RenewDeadline          time.Time     `json:"renewDeadline,omitempty"`
	Status                 string        `json:"status,omitempty"`
	SubAccountID           string        `json:"subAccountId,omitempty"`
	TransferProtected      bool          `json:"transferProtected,omitempty"`
	Verifications          Verifications `json:"verifications,omitempty"`
}

DomainDetails defines the details of a domain

type DomainName added in v1.3.1

type DomainName struct {
	Status string
}

DomainName defines a domain name

type DomainSummary added in v1.3.8

type DomainSummary struct {
	CreatedAt              time.Time
	Domain                 string
	DomainID               int
	ExpirationProtected    bool
	Expires                time.Time
	ExposeWhois            bool
	HoldRegistrar          bool
	Locked                 bool
	NameServers            []string
	Privacy                bool
	RenewAuto              bool
	Renewable              bool
	Status                 string
	TransferAwayEligibleAt time.Time
	TransferProtected      bool
}

DomainSummary is what gets returned when listing all of your domains

type RealName added in v1.3.1

type RealName struct {
	Status string `json:"status,omitempty"`
}

RealName defines the real name

type Record added in v1.3.1

type Record struct {
	Data     string `json:"data,omitempty"`
	Name     string `json:"name,omitempty"`
	Port     int    `json:"port,omitempty"`
	Priority int    `json:"priority,omitempty"`
	Protocol string `json:"protocol,omitempty"`
	Service  string `json:"service,omitempty"`
	TTL      int    `json:"ttl,omitempty"`
	Type     string `json:"type,omitempty"`
	Weight   int    `json:"weight,omitempty"`
}

Record defines a DNS record

type RecordType added in v1.3.18

type RecordType string

RecordType represents a DNS record type

func (RecordType) IsValid added in v1.3.20

func (r RecordType) IsValid() bool

IsValid determines whether or not the given dns recorsd type is valid

func (RecordType) String added in v1.3.18

func (r RecordType) String() string

type Records added in v1.3.1

type Records interface {
	List(ctx context.Context) ([]Record, error)
	Add(ctx context.Context, rec []Record) error
	FindByType(ctx context.Context, t string) ([]Record, error)
	FindByTypeAndName(ctx context.Context, t string, n string) ([]Record, error)
	ReplaceByType(ctx context.Context, t string, rec []Record) error
	ReplaceByTypeAndName(ctx context.Context, t string, n string, rec []Record) error
	Update(ctx context.Context, rec []Record) error
	Delete(ctx context.Context, rec Record) error
}

Records knows how to interact with the Records GoDaddy Gateway endpoint

type V1 added in v1.3.6

type V1 interface {
	Domain(name string) Domain
	ListDomains(ctx context.Context) ([]DomainSummary, error)
	CheckAvailability(ctx context.Context, name string, forTransfer bool) (DomainAvailability, error)
	PurchaseDomain(ctx context.Context, dom DomainDetails) error
}

V1 knows how to interact with GoDaddy Gateway version 1

type V2 added in v1.3.6

type V2 interface{}

V2 knows how to interact with GoDaddy Gateway version 2

type Verifications added in v1.3.1

type Verifications struct {
	DomainName DomainName `json:"domainName,omitempty"`
	RealName   RealName   `json:"realName,omitempty"`
}

Verifications defines who verified purchases, etc..

Jump to

Keyboard shortcuts

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