alidnsslim

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: MIT Imports: 19 Imported by: 0

README

alidnsslim

Alidns Docs

Usage

import "github.com/caiguanhao/alidnsslim"

client := alidnsslim.NewClient(ACCESS_KEY_ID, ACCESS_KEY_SECRET)

ctx := context.Background()

// get all domains:
var domains []string
client.GetAll(ctx, alidnsslim.GetDomains(), &domains, "Domains.Domain.*.DomainName")

// get all records of a domain:
var records []struct {
	Id         string `json:"RecordId"`
	DomainName string
	RR         string
	Type       string
	Value      string
}
client.GetAll(ctx, alidnsslim.GetDomainRecords("example.com", alidnsslim.PageSize(100)), &records, "DomainRecords.Record.*")

// create hello.example.com TXT record:
var recordId string
client.Do(ctx, AddDomainRecord("hello", "example.com", "TXT", "world"), &recordId, "RecordId")

// for other APIs, create your own params:
var domainId string
client.MustDo(ctx, alidnsslim.Params(
	"Action", "AddDomain",
	"DomainName", "foobar.com",
), &domainId, "DomainId")

// which is the same as:
params := url.Values{}
params.Set("Action", "AddDomain")
params.Set("DomainName", "foobar.com")
client.MustDo(ctx, params, &domainId, "DomainId")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddDomainRecord

func AddDomainRecord(record, domainName, typeValue, value string, values ...url.Values) url.Values

AddDomainRecord generates params with AddDomainRecord action.

func DeleteDomainRecord

func DeleteDomainRecord(id string, values ...url.Values) url.Values

DeleteDomainRecord generates params witht DeleteDomainRecord action.

func GetDomainRecord

func GetDomainRecord(id string, values ...url.Values) url.Values

GetDomainRecord generates params with DescribeDomainRecordInfo action.

func GetDomainRecords

func GetDomainRecords(domainName string, values ...url.Values) url.Values

GetDomainRecords generates params with DescribeDomainRecords action.

func GetDomains

func GetDomains(values ...url.Values) url.Values

GetDomains generates params with DescribeDomains action.

func Page

func Page(page int, values ...url.Values) url.Values

Page generates params with PageNumber.

func PageSize

func PageSize(size int, values ...url.Values) url.Values

PageSize generates params with PageSize.

func Params

func Params(keysAndValues ...interface{}) url.Values

Generate url.Values from list of keys and values.

func UpdateDomainRecord

func UpdateDomainRecord(id, record, typeValue, value string, values ...url.Values) url.Values

UpdateDomainRecord generates params with UpdateDomainRecord action.

Types

type Client

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

func NewClient

func NewClient(id, secret string) *Client

NewClient creates a client given access key ID and secret.

func (*Client) Debug

func (client *Client) Debug(debug bool) *Client

Creates a new client with debug (more information printed to stderr).

func (Client) Do

func (client Client) Do(ctx context.Context, params url.Values, dest ...interface{}) error

Do is an alias to Get. Use this to indicate action is destructive.

func (Client) Get

func (client Client) Get(ctx context.Context, params url.Values, dest ...interface{}) error

Get gets resources into destinations. For paginated resources, use GetAll.

func (Client) GetAll

func (client Client) GetAll(ctx context.Context, params url.Values, dest ...interface{}) error

GetAll gets all paginated resources into destinations.

func (Client) MustDo

func (client Client) MustDo(ctx context.Context, params url.Values, dest ...interface{})

MustDo is an alias to MustGet and is like Do. Use this to indicate action is destructive.

func (Client) MustGet

func (client Client) MustGet(ctx context.Context, params url.Values, dest ...interface{})

MustGet is like Get, it gets resources into destinations and panics if operation fails. For paginated resources, use MustGetAll.

func (Client) MustGetAll

func (client Client) MustGetAll(ctx context.Context, params url.Values, dest ...interface{})

MustGetAll is like GetAll, it gets all paginated resources into destinations and panics if operation fails.

type ResponseError

type ResponseError struct {
	Message string
	Code    string
}

func (ResponseError) Error

func (e ResponseError) Error() string

Jump to

Keyboard shortcuts

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