vercel

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2021 License: MIT Imports: 10 Imported by: 4

README

Vercel DNS for libdns

This package implements the libdns interfaces for the Vercel DNS API

Authenticating

To authenticate you need to supply a Vercel APIToken. For Testing purposes you can get a Testing Token from your Vercel dashboard.

Please keep in mind that Vercel has a hard Rate-Limit of 100 API Calls per Hour.

⚠️⚠️ You currently can't retrieve TTL values for your records with the Vercel API ⚠️⚠️

package main

import (
	"context"
	"fmt"
	"os"
	"time"

	"github.com/libdns/vercel"
)

func main() {
	token := os.Getenv("LIBDNS_VERCEL_TOKEN")
	if token == "" {
		fmt.Printf("LIBDNS_VERCEL_TOKEN not set\n")
		return
	}

	zone := os.Getenv("LIBDNS_VERCEL_ZONE")
	if token == "" {
		fmt.Printf("LIBDNS_VERCEL_ZONE not set\n")
		return
	}

	p := &vercel.Provider{
		AuthAPIToken: token,
	}

	records, err := p.GetRecords(context.WithTimeout(context.Background(), time.Duration(15*time.Second)), zone)
	if err != nil {
        fmt.Printf("Error: %s", err.Error())
        return
	}

	fmt.Println(records)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	// AuthAPIToken is the Vercel Authentication Token - see https://vercel.com/docs/api#api-basics/authentication
	AuthAPIToken string `json:"auth_api_token"`
}

Provider implements the libdns interfaces for Vercel

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.

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.

type VercelRecord

type VercelRecord struct {
	Id    string `json:"id,omitempty"`
	Type  string `json:"type"`
	Name  string `json:"name"`
	Value string `json:"value"`
	TTL   int    `json:"ttl"`
}

Jump to

Keyboard shortcuts

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