begetapi

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ErrTemplate = `{"status":"%s","answer":{"status":"%s","errors":[{"error_code":"%s","error_text":%s}]}}`
View Source
const TXTDataKey = "txtdata"
View Source
const TXTKey = "TXT"

Variables

This section is empty.

Functions

func PopTXTRecordByValue

func PopTXTRecordByValue(r Records, txtData string) int

func PushTXTRecord

func PushTXTRecord(r Records, txtData string) error

Types

type ApiClient

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

func NewApiClient

func NewApiClient(apiURL *url.URL) *ApiClient

func (*ApiClient) ChangeRecords

func (a *ApiClient) ChangeRecords(fqdn string, records Records, credentials Credentials) error

func (*ApiClient) GetData

func (a *ApiClient) GetData(fqdn string, credentials Credentials) (Records, error)

type BegetApiMock

type BegetApiMock struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Simplified API-mock, accepting json POST's

func NewBegetApiMock

func NewBegetApiMock(login string, passwd string) *BegetApiMock

func (*BegetApiMock) DnsChangeRecords

func (b *BegetApiMock) DnsChangeRecords(w http.ResponseWriter, req *http.Request)

func (*BegetApiMock) DnsGetData

func (b *BegetApiMock) DnsGetData(w http.ResponseWriter, req *http.Request)

The real API gives back results only if the domain is created in beget's panel

func (*BegetApiMock) Run

func (b *BegetApiMock) Run(addr string) error

func (*BegetApiMock) RunDns

func (b *BegetApiMock) RunDns(port string)

func (*BegetApiMock) Stop

func (b *BegetApiMock) Stop(ctx context.Context) error

func (*BegetApiMock) StopDns

func (b *BegetApiMock) StopDns(_ context.Context) error

type ChangeRecordsRequest

type ChangeRecordsRequest struct {
	FQDN    string  `json:"fqdn"`
	Records Records `json:"records"`
}

type ChangeRecordsResponse

type ChangeRecordsResponse struct {
	Status string `json:"status"`
	Answer struct {
		Status string `json:"status"`
		Result bool   `json:"result"`
	} `json:"answer"`
}

type Credentials

type Credentials struct {
	Login  string
	Passwd string
}

type GetDataRequest

type GetDataRequest struct {
	FQDN string `json:"fqdn"`
}

type GetDataResponse

type GetDataResponse struct {
	Status string `json:"status"`
	Answer struct {
		Status string        `json:"status"`
		Result GetDataResult `json:"result"`
	} `json:"answer"`
}

type GetDataResult

type GetDataResult struct {
	// along with other fields
	FQDN    string  `json:"fqdn"`
	Records Records `json:"records"`
}

type Records

type Records map[string][]map[string]interface{}

To persist every record and every possible field in it

Jump to

Keyboard shortcuts

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