alidns

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: MIT Imports: 19 Imported by: 0

README

AliDNS for libdns

Go Reference

This package implements the libdns interfaces, allowing you to manage DNS records with the AliDNS API ( which has a nice Go SDK implementation here )

The metadata of AliDNS API here.

The document of request and signing processing are v2 and v3 (I'll upgrade the request and signing processing to v3 later.).

Authenticating

To authenticate you need to supply our AccessKeyId and AccessKeySecret to the Provider.

Example

Here's a minimal example of how to get all your DNS records using this libdns provider

package main

import (
        "context"
        "fmt"
        "github.com/omengye/alidns"
)

func main() {
        provider := alidns.Provider{
               AccKeyID: "<AccessKeyId form your aliyun console>",
               AccKeySecret: "<AccessKeySecret form your aliyun console>",
        }

        records, err  := provider.GetRecords(context.TODO(), "example.com")
        if err != nil {
                fmt.Println(err.Error())
        }

        for _, record := range records {
                fmt.Printf("%s %v %s %s\n", record.Name, record.TTL.Seconds(), record.Type, record.Value)
        }
}

For complete demo check _demo/demo.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpError

func OpError(op string, err error) error

func OpErrors

func OpErrors(op string) *opErrors

Types

type CredentialInfo

type CredentialInfo struct {
	AccessKeyID     string `json:"access_key_id"`
	AccessKeySecret string `json:"access_key_secret"`
	RegionID        string `json:"region_id,omitempty"`
	SecurityToken   string `json:"security_token,omitempty"`
}

CredentialInfo implements param of the crediential

func NewCredentialInfo

func NewCredentialInfo(accessKeyID, accessKeySecret, regionID string) *CredentialInfo

type KeyPairs

type KeyPairs []keyPair

func (KeyPairs) Append

func (p KeyPairs) Append(key, value string) (KeyPairs, error)

func (KeyPairs) Len

func (p KeyPairs) Len() int

func (KeyPairs) Less

func (p KeyPairs) Less(i, j int) bool

func (KeyPairs) Swap

func (p KeyPairs) Swap(i, j int)

func (KeyPairs) Update

func (p KeyPairs) Update(key, value string) error

func (KeyPairs) UrlEncodedString

func (p KeyPairs) UrlEncodedString() string

type Provider

type Provider struct {

	// The API Key ID Required by Aliyun's for accessing the Aliyun's API
	AccKeyID string `json:"access_key_id"`
	// The API Key Secret Required by Aliyun's for accessing the Aliyun's API
	AccKeySecret string `json:"access_key_secret"`
	// Optional for identifing the region of the Aliyun's Service,The default is zh-hangzhou
	RegionID string `json:"region_id,omitempty"`
	// contains filtered or unexported fields
}

Provider implements the libdns interfaces for Alicloud.

func (*Provider) AppendRecords

func (p *Provider) AppendRecords(ctx context.Context, zone string, recs []libdns.Record) ([]libdns.Record, 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, recs []libdns.Record) ([]libdns.Record, error)

DeleteRecords deletes the records from the zone. If a record does not have an ID, it will be looked up. It returns the records that were deleted.

func (*Provider) GetRecords

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

GetRecords lists all the records in the zone.

func (*Provider) SetRecords

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

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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