godaddygo

package module
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2020 License: MIT Imports: 9 Imported by: 8

README

godaddygo

Check us out on pkg.go.dev *seems to be a little behind a lot of the time


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`)

	// eg: godaddy.Domain("xyz.com").Records().List(ctx)
	//     godaddy.Domain("xyz.com").Records().Add(ctx, someDNSRecord)
	//     godaddy.Domain("xyz.com").Records().FindByType(ctx, godaddygo.RecordTypeA)
	//     godaddy.Domain("xyz.com").GetDetails(ctx)
	//     godaddy.ListDomains(ctx)
	//     godaddy.CheckAvailability(ctx, "dom.com")
	//     godaddy.Purchase(ctx, someDomain)
	// etc...
}
Custom Client
package main

import (
	"net/http"

	"github.com/oze4/godaddygo"
)

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

	// 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`)

	// eg: godaddy.Domain("xyz.com").Records().List(ctx)
	//     godaddy.Domain("xyz.com").Records().Add(ctx, someDNSRecord)
	//     godaddy.Domain("xyz.com").Records().FindByType(ctx, godaddygo.RecordTypeA)
	//     godaddy.Domain("xyz.com").GetDetails(ctx)
	//     godaddy.ListDomains(ctx)
	//     godaddy.CheckAvailability(ctx, "dom.com")
	//     godaddy.Purchase(ctx, someDomain)
	// 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 (

	// APIProdEnv targets the production Gateway
	APIProdEnv = "prod"
	// APIDevEnv targets the development Gateway
	APIDevEnv = "dev"

	// APIVersion1 specifies version 1
	APIVersion1 = "v1"
	// APIVersion2 specifies version 2
	APIVersion2 = "v2"

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

	// MethodGet is global shortcut for http.MethodGet
	MethodGet = http.MethodGet
	// MethodPost is global shortcut for http.MethodPost
	MethodPost = http.MethodPost
	// MethodPut is global shortcut for http.MethodPut
	MethodPut = http.MethodPut
	// MethodPatch is global shortcut for http.MethodPatch
	MethodPatch = http.MethodPatch
	// MethodDelete is global shortcut for http.MethodDelete
	MethodDelete = http.MethodDelete
)

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 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

func NewConfig added in v1.3.2

func NewConfig(key, secret, env string) *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 Records added in v1.3.1

type Records interface {
	List(ctx context.Context) ([]Record, error)
	FindByType(ctx context.Context, t string) ([]Record, error)
	FindByTypeAndName(ctx context.Context, t string, n string) ([]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