westcn

package module
v0.0.0-...-ab62b7a Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2021 License: MIT Imports: 17 Imported by: 1

README

libdns-westcn

west.cn (西部数码) provider for libdns

Example

import (
	westcn "github.com/cnk3x/libdns-westcn"
	"github.com/libdns/libdns"
)

ctx := context.TODO()

zone := "example.com."

// configure the DNS provider (choose any from github.com/libdns)
provider := &westcn.Provider{Username: "user", Password: "api_password"}

// list records
recs, err := provider.GetRecords(ctx, zone)

// create records (AppendRecords is similar)
newRecs, err := provider.SetRecords(ctx, zone, []libdns.Record{
	Type:  "A",
	Name:  "sub",
	Value: "1.2.3.4",
})

// delete records (this example uses provider-assigned ID)
deletedRecs, err := provider.DeleteRecords(ctx, zone, []libdns.Record{
	ID: "foobar",
})

// no matter which provider you use, the code stays the same!
// (some providers have caveats; see their package documentation)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Endpoint string
	Username string
	Password string
}

func (*Client) AddRecord

func (p *Client) AddRecord(ctx context.Context, zone string, record libdns.Record) (libdns.Record, error)

func (*Client) DeleteRecord

func (p *Client) DeleteRecord(ctx context.Context, zone string, record libdns.Record) (libdns.Record, error)

func (*Client) GetRecords

func (p *Client) GetRecords(ctx context.Context, zone string) (records []libdns.Record, err error)

func (*Client) UpdateRecord

func (p *Client) UpdateRecord(ctx context.Context, zone string, record libdns.Record) (libdns.Record, error)

type Provider

type Provider struct {
	Endpoint string
	Username string
	Password string
	// contains filtered or unexported fields
}

Provider implements the libdns interfaces for west.cn

func (*Provider) AppendRecords

func (p *Provider) AppendRecords(ctx context.Context, zone string, records []libdns.Record) (appendedRecords []libdns.Record, err error)

AppendRecords adds records to the zone. It returns the records that were added.

func (*Provider) DeleteRecords

func (p *Provider) DeleteRecords(ctx context.Context, zone string, records []libdns.Record) (deletedRecords []libdns.Record, err error)

DeleteRecords deletes the records from the zone.

func (*Provider) GetRecords

func (p *Provider) GetRecords(ctx context.Context, zone string) (records []libdns.Record, err error)

GetRecords lists all the records in the zone.

func (*Provider) SetRecords

func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) (setRecords []libdns.Record, err error)

SetRecords sets the records in the zone, either by updating existing records or creating new ones. It returns the updated records.

type Result

type Result struct {
	Result   int             `json:"result"`
	ClientID string          `json:"clientid"`
	Msg      string          `json:"msg"`
	ErrCode  int             `json:"errcode"`
	Data     json.RawMessage `json:"data"`
}

func (*Result) Error

func (r *Result) Error() string

Directories

Path Synopsis
caddy module

Jump to

Keyboard shortcuts

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