Thanks to visit codestin.com
Credit goes to pkg.go.dev

alidns

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 22 Imported by: 12

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 (Current schema version is already v3, v2 will be archived. ).

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/libdns/alidns"
)

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

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

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

For complete demo check _demo/demo.go

Documentation

Index

Constants

View Source
const (
	VersionPrefix             = "version_"
	EditionEnterpriseAdvanced = instanceEdition(VersionPrefix + "enterprise_advanced")
	EditionEnterpriseBasic    = instanceEdition(VersionPrefix + "enterprise_basic")
	EditionPersonal           = instanceEdition(VersionPrefix + "personal")
	EditionFree               = instanceEdition("mianfei")
)

Variables

This section is empty.

Functions

func OpError added in v1.0.6

func OpError(op string, err error) error

func OpErrors added in v1.0.6

func OpErrors(op string) *opErrors

Types

type CredentialInfo added in v1.0.6

type CredentialInfo struct {
	// The API Key ID Required by Aliyun's for accessing the Aliyun's API
	AccessKeyID string `json:"access_key_id"`
	// The API Key Secret Required by Aliyun's for accessing the Aliyun's API
	AccessKeySecret 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"`
	// The Security Token Required If you enabled the Aliyun's STS(SecurityToken) for accessing the Aliyun's API
	SecurityToken string `json:"security_token,omitempty"`
}

CredentialInfo implements param of the crediential

type DomainRecord added in v1.0.6

type DomainRecord struct {
	Type     string
	Name     string
	Value    string
	TTL      ttl_t
	Priority ttl_t
	ID       string
}

func (DomainRecord) RR added in v1.0.6

func (r DomainRecord) RR() libdns.RR

type Provider

type Provider struct {
	CredentialInfo
	// 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