inwx

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: BSD-3-Clause Imports: 8 Imported by: 0

README

inwx

Package inwx provides easy access to the official INWX JSON-RPC API.

Documentation

Overview

Package inwx provides easy access to the official INWX JSON-RPC API.

Index

Constants

View Source
const (
	A          = "A"
	AAAA       = "AAAA"
	AFSDB      = "AFSDB"
	ALIAS      = "ALIAS"
	CAA        = "CAA"
	Cert       = "CERT"
	CNAME      = "CNAME"
	HINFO      = "HINFO"
	KEY        = "KEY"
	LOC        = "LOC"
	MX         = "MX"
	NAPTR      = "NAPTR"
	NS         = "NS"
	OpenPGPKey = "OPENPGPKEY"
	PTR        = "PTR"
	RP         = "RP"
	SMIMEA     = "SMIMEA"
	SOA        = "SOA"
	SRV        = "SRV"
	SSHFP      = "SSHFP"
	TLSA       = "TLSA"
	TXT        = "TXT"
	URI        = "URI"
	URL        = "URL"
)
View Source
const (
	Permanent URLRdrType = "HEADER301"
	Temporary            = "HEADER302"
	Frame                = "FRAME"
)
View Source
const (
	Success              Status = 1000
	SuccessPending              = 1001
	SuccessNoMsgs               = 1300
	SuccessDequeue              = 1301
	SuccessClosing              = 1500
	WrongPasswd                 = 1200
	UnknownCall                 = 2000
	SyntaxErr                   = 2001
	UseErr                      = 2002
	MissingParam                = 2003
	WrongParamRange             = 2004
	ParamSyntaxErr              = 2005
	UnimplementedCall           = 2101
	UnimplementedOpt            = 2102
	UnimplementedExt            = 2103
	BillingErr                  = 2104
	DenyRenewal                 = 2105
	DenyTransfer                = 2106
	AuthError                   = 2200
	AuthzError                  = 2201
	InvalidAuthzInfo            = 2202
	PendingTransfer             = 2300
	NotPendingTransfer          = 2301
	Exists                      = 2302
	NotExist                    = 2303
	StatusProhibitsOp           = 2304
	AssocProhibitsOp            = 2305
	ParamPolicyErr              = 2306
	UnimplementedService        = 2307
	DataMgmtPolicyErr           = 2308
	CmdErr                      = 2400
	CmdErrClosing               = 2500
	AuthErrClosing              = 2501
	SessionOverClosing          = 2502
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call interface {
	// contains filtered or unexported methods
}

A Call is anything that provides a method name and a list of status codes that indicate basic success. It can be executed through a Client.

type Client

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

A Client is a session handle for the API.

func Login

func Login(endpoint Endpoint, user, passwd string) (*Client, error)

Login creates a new Client and attempts to start a session with the given credentials.

Two-factor authentication is currently not supported, contributions are welcome.

func (*Client) Call

func (c *Client) Call(call Call) (*Response, error)

Call sends a Call to the API endpoint and waits for a response or an error. It returns net.ErrClosed if the Client is closed.

func (*Client) Close

func (c *Client) Close() error

Close closes the Client. Any blocked Calls will return net.ErrClosed.

func (*Client) Closed

func (c *Client) Closed() <-chan struct{}

Closed returns a channel which is closed when the Client is closed.

func (*Client) Endpoint

func (c *Client) Endpoint() Endpoint

Endpoint returns the API endpoint used by the Client for HTTP requests.

func (*Client) WhyClosed

func (c *Client) WhyClosed() error

WhyClosed returns the error that caused the Conn to be closed or nil if the Conn was closed using the Close method. WhyClosed returns nil if the Conn is not closed.

type Endpoint

type Endpoint string

An Endpoint is the server to communicate with.

const (
	// Production is the JSON-RPC production endpoint.
	// Calls can modify real zones. Only use this if you really need it.
	Production Endpoint = "https://api.domrobot.com/jsonrpc/"

	// Sandbox is the JSON-RPC sandbox endpoint.
	// Use this endpoint for experiments or testing of any kind.
	Sandbox = "https://api.ote.domrobot.com/jsonrpc/"
)

type ErrUnexpectedStatus

type ErrUnexpectedStatus struct {
	Expected []Status
	Got      Status
}

ErrUnexpectedStatus indicates that a Call was responded to but the Status doesn't match any of the expected Statuses of the Call.

func (*ErrUnexpectedStatus) Error

func (e *ErrUnexpectedStatus) Error() string

type NSRecord

type NSRecord struct {
	ID int `json:"id"`
	RecordInfo
}

A NSRecord consists of an ID and RecordInfo.

type NSRecordInfoCall

type NSRecordInfoCall struct {
	DomainName string     `json:"domain,omitempty"`
	DomainID   int        `json:"roId,omitempty"`
	RecordID   int        `json:"recordId,omitempty"`
	Type       RecordType `json:"type,omitempty"`
	Name       string     `json:"name,omitempty"`
	Content    string     `json:"content,omitempty"`
	TTL        int        `json:"ttl,omitempty"`
	Priority   int        `json:"prio,omitempty"`
}

A NSRecordInfoCall returns detailed information about a DNS record.

type NSRecordInfoResponse

type NSRecordInfoResponse struct {
	DomainID      int        `json:"roId"`
	DomainName    string     `json:"domain"`
	DomainType    NSType     `json:"type"`
	MasterAddr    string     `json:"masterIp"`
	LastZoneCheck time.Time  `json:"lastZoneCheck"`
	SlaveDNS      SlaveInfo  `json:"slaveDns"`
	SOASerial     string     `json:"SOAserial"`
	RecordCount   int        `json:"count"`
	Records       []NSRecord `json:"record"`
}

A NSRecordInfoResponse contains all NSRecords that match the search.

type NSType

type NSType string

A NSType is either Master or Slave.

const (
	Master NSType = "MASTER"
	Slave         = "SLAVE"
)

type NSUpdateRecordsCall

type NSUpdateRecordsCall struct {
	IDs []int `json:"id"`
	RecordInfo
	TestingMode bool `json:"testing"`
}

A NSUpdateRecordsCall updates one or more DNS records.

type RecordInfo

type RecordInfo struct {
	Name                string     `json:"name,omitempty"`
	Type                RecordType `json:"type,omitempty"`
	Content             string     `json:"content,omitempty"`
	TTL                 int        `json:"ttl,omitempty"`
	Priority            int        `json:"prio,omitempty"`
	URLRedirectType     URLRdrType `json:"urlRedirectType,omitempty"`
	URLRedirectTitle    string     `json:"urlRedirectTitle,omitempty"`
	URLRedirectDesc     string     `json:"urlRedirectDescription,omitempty"`
	URLRedirectKeywords string     `json:"urlRedirectKeywords,omitempty"`
	URLRedirectFavIcon  string     `json:"urlRedirectFavIcon,omitempty"`
	URLAppend           bool       `json:"urlAppend,omitempty"`
}

A RecordInfo contains DNS as well as INWX specific record information.

type RecordType

type RecordType string

A RecordType specifies the type of a DNS record.

type Response

type Response struct {
	StatusCode Status           `json:"code"`
	Data       *json.RawMessage `json:"resData"`
}

A Response contains the Status of a response to a Call as well as the response parameters. Data is nil if there are no response parameters.

func (*Response) Into

func (r *Response) Into(resp any) error

Into unmarshals the Response into a Call specific response struct.

type SlaveInfo

type SlaveInfo struct {
	Hostname string `json:"name"`
	Addr     string `json:"ip"`
}

SlaveInfo is information about a slave nameserver.

type Status

type Status int

A Status contains basic information about whether and how a Call was processed. See https://www.inwx.com/en/help/apidoc/f/ch04.html for descriptions.

type URLRdrType

type URLRdrType string

A URLRdrType specifies which method of HTTP redirection to use.

Jump to

Keyboard shortcuts

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