huaweicloud

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: MIT Imports: 11 Imported by: 2

README

Huawei Cloud for libdns

Go Reference

This package implements the libdns interfaces for Huawei Cloud DNS, allowing you to manage DNS records.

Authenticating

To authenticate you need to supply your AccessKeyId and SecretAccessKey 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/huaweicloud"
)

func main() {
	provider := huaweicloud.Provider{
		AccessKeyId: "<AccessKeyId form your huaweicloud console>",
		SecretAccessKey: "<SecretAccessKey form your huaweicloud 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 _example/main.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	// AccessKeyId is required by the Huawei Cloud API for authentication.
	AccessKeyId string `json:"access_key_id,omitempty"`
	// SecretAccessKey is required by the Huawei Cloud API for authentication.
	SecretAccessKey string `json:"secret_access_key,omitempty"`
	// RegionId is optional and defaults to "cn-south-1".
	RegionId string `json:"region_id,omitempty"`
}

Provider facilitates DNS record manipulation with Huawei Cloud

func (*Provider) AppendRecords

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

DeleteRecords deletes the records from the zone. 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, records []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.

Jump to

Keyboard shortcuts

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