timeweb

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2025 License: MIT Imports: 8 Imported by: 2

README

Timeweb DNS for libdns

Go Reference

This package implements the libdns interfaces for Timeweb DNS API, allowing you to manage DNS records.

Authorize

To authorize you need to use Timeweb Authorization.

Example

Minimal working example of getting DNS zone records.

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/libdns/libdns/timeweb-libdns"
)

func main() {

	provider = timeweb.Provider{
		ApiURL:   os.Getenv("TIMEWEB_URL"),
		ApiToken: os.Getenv("TIMEWEB_API_TOKEN"),
	}
	zone = os.Getenv("TIMEWEB_ZONE")
	ctx = context.Background()

	records, err := provider.GetRecords(ctx, zone)
	if err != nil {
		fmt.Printf("Error: %s", err)
		return
	}

	fmt.Println(records)
}

Always yours @Riskful

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	ApiURL   string
	ApiToken string
}

func (*Provider) AppendRecords

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

func (*Provider) DeleteRecords

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

func (*Provider) GetRecords

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

func (*Provider) SetRecords

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

type Record

type Record struct {
	Subdomain string `json:"subdomain"`
	Type      string `json:"type"`
	Value     string `json:"value"`
}

type RecordResponse

type RecordResponse struct {
	Data struct {
		Priority uint   `json:"priority,omitempty"`
		Value    string `json:"value"`
	} `json:"data"`
	ID   uint   `json:"id"`
	Type string `json:"type"`
	Fqdn string `json:"fqdn"`
}

type RecordsResponse

type RecordsResponse struct {
	Meta struct {
		Total int `json:"total"`
	} `json:"meta"`
	DNSRecords []RecordResponse `json:"dns_records"`
}

type SavedRecord

type SavedRecord struct {
	DNSRecord struct {
		ID   uint   `json:"id"`
		Type string `json:"type"`
		Data struct {
			Priority  uint   `json:"priority,omitempty"`
			Value     string `json:"value"`
			Subdomain string `json:"subdomain"`
		}
	} `json:"dns_record"`
}

Jump to

Keyboard shortcuts

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