goinwx

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2017 License: MIT Imports: 10 Imported by: 2

README

goinwx

INWX Go API client

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 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
	Domains     DomainService
	Nameservers NameserverService
}

Client manages communication with INWX API.

func NewClient

func NewClient(username, password string) *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) Login

func (c *Client) Login() error

func (*Client) Logout

func (c *Client) Logout() error

func (*Client) NewRequest

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

NewRequest creates an API request.

type Contact

type Contact struct {
	RoId          int
	Id            int
	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 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 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)
	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) 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 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)
	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
}

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

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

func (*NameserverServiceOp) DeleteRecord

func (s *NameserverServiceOp) DeleteRecord(recId int) 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