goname

package module
v0.0.0-...-33cca33 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2019 License: MIT Imports: 6 Imported by: 1

README

goname

Build Status Maintainability Test Coverage GoDoc

A Go library for interacting with the Name.com API

For a CLI implementation, see namedns.

Author

Documentation

Index

Constants

View Source
const (
	// NameAPIBaseURL Base URL to the production Name.com API
	NameAPIBaseURL = "https://api.name.com"

	// NameAPIBaseDevURL Base URL to the dev Name.com API
	NameAPIBaseDevURL = "https://api.dev.name.com"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountResponse

type AccountResponse struct {
	Result        Result    `json:"result"`
	Username      string    `json:"username"`
	CreateDate    string    `json:"create_date"`
	DomainCount   string    `json:"domain_count"`
	AccountCredit string    `json:"account_credit"`
	Contacts      []Contact `json:"contacts"`
}

AccountResponse response from /api/account/get

type BasicResponse

type BasicResponse struct {
	Result Result `json:"result"`
}

BasicResponse response with no other details

type Contact

type Contact struct {
	Type         []string `json:"type"`
	FirstName    string   `json:"first_name"`
	LastName     string   `json:"last_name"`
	Organization string   `json:"organization"`
	AddressLine1 string   `json:"addressline1"`
	AddressLine2 string   `json:"addressline2"`
	City         string   `json:"city"`
	State        string   `json:"state"`
	Phone        string   `json:"phone"`
	Fax          string   `json:"fax"`
	Email        string   `json:"email"`
}

Contact account and registrant contact information

type CreateDNSRecordResponse

type CreateDNSRecordResponse struct {
	Result     Result `json:"result"`
	RecordID   int    `json:"record_id"`
	Name       string `json:"name"`
	Type       string `json:"type"`
	Content    string `json:"content"`
	TTL        int    `json:"ttl"`
	CreateDate string `json:"create_date"`
	Priority   int    `json:"priority,omitempty"`
}

CreateDNSRecordResponse response from /api/dns/create/:name

type DNSRecordRequest

type DNSRecordRequest struct {
	RecordID   int    `json:"record_id"`
	Hostname   string `json:"hostname"`
	Type       string `json:"type"`
	Content    string `json:"content"`
	TTL        int    `json:"ttl"`
	CreateDate string `json:"create_date"`
	Priority   int    `json:"priority,omitempty"`
}

DNSRecordRequest DNS record *request* information because the API is stupid

type DNSRecordResponse

type DNSRecordResponse struct {
	RecordID   string `json:"record_id"`
	Name       string `json:"name"`
	Type       string `json:"type"`
	Content    string `json:"content"`
	TTL        string `json:"ttl"`
	CreateDate string `json:"create_date"`
	Priority   string `json:"priority,omitempty"`
}

DNSRecordResponse DNS record information

type Domain

type Domain struct {
	TLD         string   `json:"tld"`
	CreateDate  string   `json:"create_date"`
	ExpireDate  string   `json:"expire_date"`
	Locked      bool     `json:"locked,omitempty"`
	Nameservers []string `json:"nameservers,omitempty"`
	Addons      map[string]struct {
		Price string `json:"price"`
	} `json:"addons,omitempty"`
	WhoisPrivacy struct {
		Enabled    bool   `json:"enabled"`
		ExpireDate string `json:"expire_date"`
	} `json:"whois_privacy,omitempty"`
	Username string    `json:"username,omitempty"`
	Contacts []Contact `json:"contacts,omitempty"`
}

Domain domain information

type GoName

type GoName struct {
	Client       *http.Client
	Username     string
	APIKey       string
	BaseURL      string
	SessionToken string
}

GoName API controller

func New

func New(username, key string) *GoName

New creates a new instance of GoName

func (*GoName) Account

func (n *GoName) Account() (data AccountResponse, err error)

Account retunrs the associated Name.com account information

func (*GoName) CreateDNSRecord

func (n *GoName) CreateDNSRecord(domain string, record DNSRecordRequest) (data CreateDNSRecordResponse, err error)

CreateDNSRecord creates a record on a domain

func (*GoName) DeleteDNSRecord

func (n *GoName) DeleteDNSRecord(domain, recordID string) (data BasicResponse, err error)

DeleteDNSRecord deletes a record on a domain

func (*GoName) Hello

func (n *GoName) Hello() (data HelloResponse, err error)

Hello pings the name.com API

func (*GoName) ListDNSRecords

func (n *GoName) ListDNSRecords(domainName string) (data ListDNSRecordsResponse, err error)

ListDNSRecords retrives records created on supplied domain name

func (*GoName) ListDomains

func (n *GoName) ListDomains() (data ListDomainsResponse, err error)

ListDomains retrieves information about domains owned by an account

func (*GoName) Login

func (n *GoName) Login() error

Login logs the name.com API session in and sets the session token

func (*GoName) Logout

func (n *GoName) Logout() error

Logout logs the name.com API session out

type HelloResponse

type HelloResponse struct {
	Result     Result `json:"result"`
	Service    string `json:"service"`
	ServerDate string `json:"server_date"`
	Version    string `json:"version"`
	Language   string `json:"language"`
	ClientIP   string `json:"client_ip"`
}

HelloResponse response from /api/hello

type ListDNSRecordsResponse

type ListDNSRecordsResponse struct {
	Result  Result              `json:"result"`
	Records []DNSRecordResponse `json:"records"`
}

ListDNSRecordsResponse response from /api/dns/list/:name

type ListDomainsResponse

type ListDomainsResponse struct {
	Result  Result            `json:"result"`
	Domains map[string]Domain `json:"domains"`
}

ListDomainsResponse response from /api/domains/list

type LoginResponse

type LoginResponse struct {
	Result       Result `json:"result"`
	SessionToken string `json:"session_token"`
}

LoginResponse response from /api/login

type Result

type Result struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Result response details

func (*Result) Failed

func (r *Result) Failed() bool

Failed returns true if the API reports the request completed with an error

func (*Result) String

func (r *Result) String() string

Jump to

Keyboard shortcuts

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