alidns

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: MIT Imports: 19 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 )

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{
               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

This section is empty.

Types

type CredInfo

type CredInfo struct {
	AccKeyID     string `json:"access_key_id"`
	AccKeySecret string `json:"access_key_secret"`
	RegionID     string `json:"region_id,omitempty"`
}

CredInfo implements param of the crediential

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