goinwx

package module
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2017 License: MIT Imports: 10 Imported by: 2

README

goinwx

INWX Go API client

This go library implements some parts of the official INWX XML-RPC API.

Full API documentation can be found here

The following parts are implemented:

  • Account
    • Login
    • Logout
    • Lock
    • Unlock (with mobile TAN)
  • Domains
    • Check
    • Register
    • Delete
    • Info
    • GetPrices
    • List
    • Whois
  • Nameservers
    • Check
    • Create
    • Info
    • List
    • CreateRecord
    • UpdateRecord
    • DeleteRecord
    • FindRecordById
  • Contacts
    • List
    • Info
    • Create
    • Update
    • Delete

Your contributions are very appreciated.

Documentation

Index

Constants

View Source
const (
	APIBaseUrl        = "https://api.domrobot.com/xmlrpc/"
	APISandboxBaseUrl = "https://api.ote.domrobot.com/xmlrpc/"
	APILanguage       = "eng"
)

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *Response) error

CheckResponse checks the API response for errors, and returns them if present.

Types

type AccountService added in v0.3.0

type AccountService interface {
	Login() error
	Logout() error
	Lock() error
	Unlock(tan string) error
}

type AccountServiceOp added in v0.3.0

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

func (*AccountServiceOp) Lock added in v0.3.0

func (s *AccountServiceOp) Lock() error

func (*AccountServiceOp) Login added in v0.3.0

func (s *AccountServiceOp) Login() error

func (*AccountServiceOp) Logout added in v0.3.0

func (s *AccountServiceOp) Logout() error

func (*AccountServiceOp) Unlock added in v0.3.0

func (s *AccountServiceOp) Unlock(tan string) error

type Client

type Client struct {
	// HTTP client used to communicate with the INWX API.
	RPCClient *xmlrpc.Client

	// Base URL for API requests.
	BaseURL *url.URL

	// API username
	Username string

	// API password
	Password string

	// User agent for client
	APILanguage string

	// Services used for communicating with the API
	Account     AccountService
	Domains     DomainService
	Nameservers NameserverService
	Contacts    ContactService
}

Client manages communication with INWX API.

func NewClient

func NewClient(username, password string, opts *ClientOptions) *Client

NewClient returns a new INWX API client.

func (*Client) Do

func (c *Client) Do(req Request) (*map[string]interface{}, error)

Do sends an API request and returns the API response.

func (*Client) NewRequest

func (c *Client) NewRequest(serviceMethod string, args map[string]interface{}) *Request

NewRequest creates an API request.

type ClientOptions added in v0.2.1

type ClientOptions struct {
	Sandbox bool
}

type Contact

type Contact struct {
	RoId          int
	Id            string
	Type          string
	Name          string
	Org           string
	Street        string
	City          string
	PostalCode    string `mapstructure:"pc"`
	StateProvince string `mapstructure:"sp"`
	Country       string `mapstructure:"cc"`
	Phone         string `mapstructure:"voice"`
	Fax           string
	Email         string
	Remarks       string
	Protection    int
}

type ContactCreateRequest added in v0.3.2

type ContactCreateRequest struct {
	Type          string `structs:"type"`
	Name          string `structs:"name"`
	Org           string `structs:"org,omitempty"`
	Street        string `structs:"street"`
	City          string `structs:"city"`
	PostalCode    string `structs:"pc"`
	StateProvince string `structs:"sp,omitempty"`
	CountryCode   string `structs:"cc"`
	Voice         string `structs:"voice"`
	Fax           string `structs:"fax,omitempty"`
	Email         string `structs:"email"`
	Remarks       string `structs:"remarks,omitempty"`
	Protection    bool   `structs:"protection,omitempty"`
	Testing       bool   `structs:"testing,omitempty"`
}

type ContactInfoResponse added in v0.3.2

type ContactInfoResponse struct {
	Contact Contact `mapstructure:"contact"`
}

type ContactListResponse added in v0.3.2

type ContactListResponse struct {
	Count    int
	Contacts []Contact `mapstructure:"contact"`
}

type ContactService added in v0.3.2

type ContactService interface {
	Create(*ContactCreateRequest) (int, error)
	Update(*ContactUpdateRequest) error
	Delete(int) error
	Info(int) (*ContactInfoResponse, error)
	List(string) (*ContactListResponse, error)
}

type ContactServiceOp added in v0.3.2

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

func (*ContactServiceOp) Create added in v0.3.2

func (s *ContactServiceOp) Create(request *ContactCreateRequest) (int, error)

func (*ContactServiceOp) Delete added in v0.3.2

func (s *ContactServiceOp) Delete(roId int) error

func (*ContactServiceOp) Info added in v0.3.2

func (s *ContactServiceOp) Info(contactId int) (*ContactInfoResponse, error)

func (*ContactServiceOp) List added in v0.3.2

func (s *ContactServiceOp) List(search string) (*ContactListResponse, error)

func (*ContactServiceOp) Update added in v0.3.2

func (s *ContactServiceOp) Update(request *ContactUpdateRequest) error

type ContactUpdateRequest added in v0.3.2

type ContactUpdateRequest struct {
	Id            int    `structs:"id"`
	Name          string `structs:"name,omitempty"`
	Org           string `structs:"org,omitempty"`
	Street        string `structs:"street,omitempty"`
	City          string `structs:"city,omitempty"`
	PostalCode    string `structs:"pc,omitempty"`
	StateProvince string `structs:"sp,omitempty"`
	CountryCode   string `structs:"cc,omitempty"`
	Voice         string `structs:"voice,omitempty"`
	Fax           string `structs:"fax,omitempty"`
	Email         string `structs:"email,omitempty"`
	Remarks       string `structs:"remarks,omitempty"`
	Protection    bool   `structs:"protection,omitempty"`
	Testing       bool   `structs:"testing,omitempty"`
}

type DomainCheckResponse

type DomainCheckResponse struct {
	Available   int     `mapstructure:"avail"`
	Status      string  `mapstructure:"status"`
	Name        string  `mapstructure:"name"`
	Domain      string  `mapstructure:"domain"`
	TLD         string  `mapstructure:"tld"`
	CheckMethod string  `mapstructure:"checkmethod"`
	Price       float32 `mapstructure:"price"`
	CheckTime   float32 `mapstructure:"checktime"`
}

type DomainInfoResponse

type DomainInfoResponse struct {
	RoId         int                `mapstructure:"roId"`
	Domain       string             `mapstructure:"domain"`
	DomainAce    string             `mapstructure:"domainAce"`
	Period       string             `mapstructure:"period"`
	CrDate       time.Time          `mapstructure:"crDate"`
	ExDate       time.Time          `mapstructure:"exDate"`
	UpDate       time.Time          `mapstructure:"upDate"`
	ReDate       time.Time          `mapstructure:"reDate"`
	ScDate       time.Time          `mapstructure:"scDate"`
	TransferLock int                `mapstructure:"transferLock"`
	Status       string             `mapstructure:"status"`
	AuthCode     string             `mapstructure:"authCode"`
	RenewalMode  string             `mapstructure:"renewalMode"`
	TransferMode string             `mapstructure:"transferMode"`
	Registrant   int                `mapstructure:"registrant"`
	Admin        int                `mapstructure:"admin"`
	Tech         int                `mapstructure:"tech"`
	Billing      int                `mapstructure:"billing"`
	Nameservers  []string           `mapstructure:"ns"`
	NoDelegation string             `mapstructure:"noDelegation"`
	Contacts     map[string]Contact `mapstructure:"contact"`
}

type DomainList

type DomainList struct {
	Count   int
	Domains []DomainInfoResponse `mapstructure:"domain"`
}

type DomainListRequest

type DomainListRequest struct {
	Domain       string `structs:"domain,omitempty"`
	RoId         int    `structs:"roId,omitempty"`
	Status       int    `structs:"status,omitempty"`
	Registrant   int    `structs:"registrant,omitempty"`
	Admin        int    `structs:"admin,omitempty"`
	Tech         int    `structs:"tech,omitempty"`
	Billing      int    `structs:"billing,omitempty"`
	RenewalMode  int    `structs:"renewalMode,omitempty"`
	TransferLock int    `structs:"transferLock,omitempty"`
	NoDelegation int    `structs:"noDelegation,omitempty"`
	Tag          int    `structs:"tag,omitempty"`
	Order        int    `structs:"order,omitempty"`
	Page         int    `structs:"page,omitempty"`
	Pagelimit    int    `structs:"pagelimit,omitempty"`
}

type DomainPriceResponse added in v0.3.2

type DomainPriceResponse struct {
	Tld                 string  `mapstructure:"tld"`
	Currency            string  `mapstructure:"currency"`
	CreatePrice         float32 `mapstructure:"createPrice"`
	MonthlyCreatePrice  float32 `mapstructure:"monthlyCreatePrice"`
	TransferPrice       float32 `mapstructure:"transferPrice"`
	RenewalPrice        float32 `mapstructure:"renewalPrice"`
	MonthlyRenewalPrice float32 `mapstructure:"monthlyRenewalPrice"`
	UpdatePrice         float32 `mapstructure:"updatePrice"`
	TradePrice          float32 `mapstructure:"tradePrice"`
	TrusteePrice        float32 `mapstructure:"trusteePrice"`
	MonthlyTrusteePrice float32 `mapstructure:"monthlyTrusteePrice"`
	CreatePeriod        int     `mapstructure:"createPeriod"`
	TransferPeriod      int     `mapstructure:"transferPeriod"`
	RenewalPeriod       int     `mapstructure:"renewalPeriod"`
	TradePeriod         int     `mapstructure:"tradePeriod"`
}

type DomainRegisterRequest

type DomainRegisterRequest struct {
	Domain        string   `structs:"domain"`
	Period        string   `structs:"period,omitempty"`
	Registrant    int      `structs:"registrant"`
	Admin         int      `structs:"admin"`
	Tech          int      `structs:"tech"`
	Billing       int      `structs:"billing"`
	Nameservers   []string `structs:"ns,omitempty"`
	TransferLock  string   `structs:"transferLock,omitempty"`
	RenewalMode   string   `structs:"renewalMode,omitempty"`
	WhoisProvider string   `structs:"whoisProvider,omitempty"`
	WhoisUrl      string   `structs:"whoisUrl,omitempty"`
	ScDate        string   `structs:"scDate,omitempty"`
	ExtDate       string   `structs:"extDate,omitempty"`
	Asynchron     string   `structs:"asynchron,omitempty"`
	Voucher       string   `structs:"voucher,omitempty"`
	Testing       string   `structs:"testing,omitempty"`
}

type DomainRegisterResponse

type DomainRegisterResponse struct {
	RoId     int
	Price    float32
	Currency string
}

type DomainService

type DomainService interface {
	Check(domains []string) ([]DomainCheckResponse, error)
	Register(request *DomainRegisterRequest) (*DomainRegisterResponse, error)
	Delete(domain string, scheduledDate time.Time) error
	Info(domain string, roId int) (*DomainInfoResponse, error)
	GetPrices(tlds []string) ([]DomainPriceResponse, error)
	List(*DomainListRequest) (*DomainList, error)
	Whois(domain string) (string, error)
}

type DomainServiceOp

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

func (*DomainServiceOp) Check

func (s *DomainServiceOp) Check(domains []string) ([]DomainCheckResponse, error)

func (*DomainServiceOp) Delete

func (s *DomainServiceOp) Delete(domain string, scheduledDate time.Time) error

func (*DomainServiceOp) GetPrices added in v0.3.2

func (s *DomainServiceOp) GetPrices(tlds []string) ([]DomainPriceResponse, error)

func (*DomainServiceOp) Info

func (s *DomainServiceOp) Info(domain string, roId int) (*DomainInfoResponse, error)

func (*DomainServiceOp) List

func (s *DomainServiceOp) List(request *DomainListRequest) (*DomainList, error)

func (*DomainServiceOp) Register

func (*DomainServiceOp) Whois

func (s *DomainServiceOp) Whois(domain string) (string, error)

type ErrorResponse

type ErrorResponse struct {
	Code       int    `xmlrpc:"code"`
	Message    string `xmlrpc:"msg"`
	ReasonCode string `xmlrpc:"reasonCode"`
	Reason     string `xmlrpc:"reason"`
}

An ErrorResponse reports the error caused by an API request

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type NameserverCheckResponse

type NameserverCheckResponse struct {
	Details []string
	Status  string
}

type NameserverCreateRequest added in v0.3.2

type NameserverCreateRequest struct {
	Domain                 string   `structs:"domain"`
	Type                   string   `structs:"type"`
	Nameservers            []string `structs:"ns,omitempty"`
	MasterIp               string   `structs:"masterIp,omitempty"`
	Web                    string   `structs:"web,omitempty"`
	Mail                   string   `structs:"mail,omitempty"`
	SoaEmail               string   `structs:"soaEmail,omitempty"`
	UrlRedirectType        string   `structs:"urlRedirectType,omitempty"`
	UrlRedirectTitle       string   `structs:"urlRedirectTitle,omitempty"`
	UrlRedirectDescription string   `structs:"urlRedirectDescription,omitempty"`
	UrlRedirectFavIcon     string   `structs:"urlRedirectFavIcon,omitempty"`
	UrlRedirectKeywords    string   `structs:"urlRedirectKeywords,omitempty"`
	Testing                bool     `structs:"testing,omitempty"`
}

type NameserverDomain added in v0.2.0

type NameserverDomain struct {
	RoId     int    `mapstructure:"roId"`
	Domain   string `mapstructure:"domain"`
	Type     string `mapstructure:"type"`
	MasterIp string `mapstructure:"masterIp"`
	Mail     string `mapstructure:"mail"`
	Web      string `mapstructure:"web"`
	Url      string `mapstructure:"url"`
	Ipv4     string `mapstructure:"ipv4"`
	Ipv6     string `mapstructure:"ipv6"`
}

type NameserverRecord

type NameserverRecord struct {
	Id                     int
	Name                   string
	Type                   string
	Content                string
	Ttl                    int
	Prio                   int
	UrlRedirectType        string
	UrlRedirectTitle       string
	UrlRedirectDescription string
	UrlRedirectKeywords    string
	UrlRedirectFavIcon     string
}

type NameserverRecordRequest

type NameserverRecordRequest struct {
	RoId                   int    `structs:"roId,omitempty"`
	Domain                 string `structs:"domain,omitempty"`
	Type                   string `structs:"type"`
	Content                string `structs:"content"`
	Name                   string `structs:"name,omitempty"`
	Ttl                    int    `structs:"ttl,omitempty"`
	Priority               int    `structs:"prio,omitempty"`
	UrlRedirectType        string `structs:"urlRedirectType,omitempty"`
	UrlRedirectTitle       string `structs:"urlRedirectTitle,omitempty"`
	UrlRedirectDescription string `structs:"urlRedirectDescription,omitempty"`
	UrlRedirectFavIcon     string `structs:"urlRedirectFavIcon,omitempty"`
	UrlRedirectKeywords    string `structs:"urlRedirectKeywords,omitempty"`
}

type NameserverService

type NameserverService interface {
	Check(domain string, nameservers []string) (*NameserverCheckResponse, error)
	Create(*NameserverCreateRequest) (int, error)
	Info(domain string, domainId int) (*NamserverInfoResponse, error)
	List(domain string) (*NamserverListResponse, error)
	CreateRecord(*NameserverRecordRequest) (int, error)
	UpdateRecord(recId int, request *NameserverRecordRequest) error
	DeleteRecord(recId int) error
	FindRecordById(recId int) (*NameserverRecord, *NameserverDomain, error)
}

type NameserverServiceOp

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

func (*NameserverServiceOp) Check

func (s *NameserverServiceOp) Check(domain string, nameservers []string) (*NameserverCheckResponse, error)

func (*NameserverServiceOp) Create added in v0.3.2

func (s *NameserverServiceOp) Create(request *NameserverCreateRequest) (int, error)

func (*NameserverServiceOp) CreateRecord

func (s *NameserverServiceOp) CreateRecord(request *NameserverRecordRequest) (int, error)

func (*NameserverServiceOp) DeleteRecord

func (s *NameserverServiceOp) DeleteRecord(recId int) error

func (*NameserverServiceOp) FindRecordById added in v0.2.1

func (s *NameserverServiceOp) FindRecordById(recId int) (*NameserverRecord, *NameserverDomain, error)

func (*NameserverServiceOp) Info

func (s *NameserverServiceOp) Info(domain string, domainId int) (*NamserverInfoResponse, error)

func (*NameserverServiceOp) List added in v0.2.0

func (*NameserverServiceOp) UpdateRecord

func (s *NameserverServiceOp) UpdateRecord(recId int, request *NameserverRecordRequest) error

type NamserverInfoResponse

type NamserverInfoResponse struct {
	RoId          int
	Domain        string
	Type          string
	MasterIp      string
	LastZoneCheck time.Time
	SlaveDns      interface{}
	SOAserial     string
	Count         int
	Records       []NameserverRecord `mapstructure:"record"`
}

type NamserverListResponse added in v0.2.0

type NamserverListResponse struct {
	Count   int
	Domains []NameserverDomain `mapstructure:"domains"`
}

type Request

type Request struct {
	ServiceMethod string
	Args          map[string]interface{}
}

type Response

type Response struct {
	Code         int                    `xmlrpc:"code"`
	Message      string                 `xmlrpc:"msg"`
	ReasonCode   string                 `xmlrpc:"reasonCode"`
	Reason       string                 `xmlrpc:"reason"`
	ResponseData map[string]interface{} `xmlrpc:"resData"`
}

Response is a INWX API response. This wraps the standard http.Response returned from INWX.

Jump to

Keyboard shortcuts

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