goinwx

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2019 License: MIT Imports: 7 Imported by: 0

README

INWX Go API client

Build Status GoDoc Go Report Card

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

API

package main

import (
	"log"

	"github.com/nrdcg/goinwx"
)

func main() {
	client := goinwx.NewClient("username", "password", &goinwx.ClientOptions{Sandbox: true})

	err := client.Account.Login()
	if err != nil {
		log.Fatal(err)
	}

	defer func() {
		if err := client.Account.Logout(); err != nil {
			log.Printf("inwx: failed to logout: %v", err)
		}
	}()

	var request = &goinwx.NameserverRecordRequest{
		Domain:  "domain.com",
		Name:    "foo.domain.com.",
		Type:    "TXT",
		Content: "aaa",
		Ttl:     300,
	}

	_, err = client.Nameservers.CreateRecord(request)
	if err != nil {
		log.Fatal(err)
	}
}

Supported Features

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

Contributions

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

API information.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountService added in v0.3.0

type AccountService service

AccountService API access to Account.

func (*AccountService) Lock added in v0.3.0

func (s *AccountService) Lock() error

Lock Account lock.

func (*AccountService) Login added in v0.3.0

func (s *AccountService) Login() error

Login Account login.

func (*AccountService) Logout added in v0.3.0

func (s *AccountService) Logout() error

Logout Account logout.

func (*AccountService) Unlock added in v0.3.0

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

Unlock Account unlock.

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

	// Services used for communicating with the API
	Account     *AccountService
	Domains     *DomainService
	Nameservers *NameserverService
	Contacts    *ContactService
	// contains filtered or unexported fields
}

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
}

ClientOptions Options of the API client.

type Contact

type Contact struct {
	RoID          int    `mapstructure:"roId"`
	ID            string `mapstructure:"id"`
	Type          string `mapstructure:"type"`
	Name          string `mapstructure:"name"`
	Org           string `mapstructure:"org"`
	Street        string `mapstructure:"street"`
	City          string `mapstructure:"city"`
	PostalCode    string `mapstructure:"pc"`
	StateProvince string `mapstructure:"sp"`
	Country       string `mapstructure:"cc"`
	Phone         string `mapstructure:"voice"`
	Fax           string `mapstructure:"fax"`
	Email         string `mapstructure:"email"`
	Remarks       string `mapstructure:"remarks"`
	Protection    string `mapstructure:"protection"`
}

Contact API model.

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"`
}

ContactCreateRequest API model.

type ContactInfoResponse added in v0.3.2

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

ContactInfoResponse API model.

type ContactListResponse added in v0.3.2

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

ContactListResponse API model.

type ContactService added in v0.3.2

type ContactService service

ContactService API access to Contact.

func (*ContactService) Create added in v0.3.2

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

Create Creates a contact.

func (*ContactService) Delete added in v0.3.2

func (s *ContactService) Delete(roID int) error

Delete Deletes a contact.

func (*ContactService) Info added in v0.3.2

func (s *ContactService) Info(contactID int) (*ContactInfoResponse, error)

Info Get information about a contact.

func (*ContactService) List added in v0.3.2

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

List Search contacts.

func (*ContactService) Update added in v0.3.2

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

Update Updates a contact.

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"`
}

ContactUpdateRequest API model.

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"`
}

DomainCheckResponse API model.

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"`
}

DomainInfoResponse API model.

type DomainList

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

DomainList API model.

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"`
}

DomainListRequest API model.

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"`
}

DomainPriceResponse API model.

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"`
}

DomainRegisterRequest API model.

type DomainRegisterResponse

type DomainRegisterResponse struct {
	RoID     int     `mapstructure:"roId"`
	Price    float32 `mapstructure:"price"`
	Currency string  `mapstructure:"currency"`
}

DomainRegisterResponse API model.

type DomainService

type DomainService service

DomainService API access to Domain.

func (*DomainService) Check

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

Check Checks domains.

func (*DomainService) Delete

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

Delete Deletes a domain.

func (*DomainService) GetPrices added in v0.3.2

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

GetPrices Gets TLDS prices.

func (*DomainService) Info

func (s *DomainService) Info(domain string, roID int) (*DomainInfoResponse, error)

Info Gets information about a domain.

func (*DomainService) List

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

List List domains.

func (*DomainService) Register

Register Register a domain.

func (*DomainService) Whois

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

Whois Whois about a domains.

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
}

NameserverCheckResponse API model.

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"`
}

NameserverCreateRequest API model.

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"`
}

NameserverDomain API model.

type NameserverInfoRequest added in v0.4.0

type NameserverInfoRequest struct {
	Domain   string `structs:"domain,omitempty"`
	RoID     int    `structs:"roId,omitempty"`
	RecordID int    `structs:"recordId,omitempty"`
	Type     string `structs:"type,omitempty"`
	Name     string `structs:"name,omitempty"`
	Content  string `structs:"content,omitempty"`
	TTL      int    `structs:"ttl,omitempty"`
	Priority int    `structs:"prio,omitempty"`
}

NameserverInfoRequest API model.

type NameserverRecord

type NameserverRecord struct {
	ID                     int    `mapstructure:"id"`
	Name                   string `mapstructure:"name"`
	Type                   string `mapstructure:"type"`
	Content                string `mapstructure:"content"`
	TTL                    int    `mapstructure:"TTL"`
	Priority               int    `mapstructure:"prio"`
	URLRedirectType        string `mapstructure:"urlRedirectType"`
	URLRedirectTitle       string `mapstructure:"urlRedirectTitle"`
	URLRedirectDescription string `mapstructure:"urlRedirectDescription"`
	URLRedirectKeywords    string `mapstructure:"urlRedirectKeywords"`
	URLRedirectFavIcon     string `mapstructure:"urlRedirectFavIcon"`
}

NameserverRecord API model.

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"`
}

NameserverRecordRequest API model.

type NameserverService

type NameserverService service

NameserverService API access to Nameservers.

func (*NameserverService) Check

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

Check Checks a domain on nameservers.

func (*NameserverService) Create added in v0.3.2

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

Create Creates a namesever.

func (*NameserverService) CreateRecord

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

CreateRecord Creates a DNS record.

func (*NameserverService) DeleteRecord

func (s *NameserverService) DeleteRecord(recID int) error

DeleteRecord Deletes a DNS record.

func (*NameserverService) FindRecordByID added in v0.6.0

func (s *NameserverService) FindRecordByID(recID int) (*NameserverRecord, *NameserverDomain, error)

FindRecordByID Search a DNS record by ID.

func (*NameserverService) Info

Info Gets informations.

func (*NameserverService) List added in v0.2.0

List List nameservers for a domain.

func (*NameserverService) UpdateRecord

func (s *NameserverService) UpdateRecord(recID int, request *NameserverRecordRequest) error

UpdateRecord Updates a DNS record.

type NamserverInfoResponse

type NamserverInfoResponse struct {
	RoID          int                `mapstructure:"roId"`
	Domain        string             `mapstructure:"domain"`
	Type          string             `mapstructure:"type"`
	MasterIP      string             `mapstructure:"masterIp"`
	LastZoneCheck time.Time          `mapstructure:"lastZoneCheck"`
	SlaveDNS      []SlaveInfo        `mapstructure:"slaveDns"`
	SOASerial     string             `mapstructure:"SOAserial"`
	Count         int                `mapstructure:"count"`
	Records       []NameserverRecord `mapstructure:"record"`
}

NamserverInfoResponse API model.

type NamserverListResponse added in v0.2.0

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

NamserverListResponse API model.

type Request

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

Request The representation of an API request.

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.

type SlaveInfo added in v0.6.0

type SlaveInfo struct {
	Name string `mapstructure:"name"`
	IP   string `mapstructure:"ip"`
}

SlaveInfo API model.

Jump to

Keyboard shortcuts

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