Categorygithub.com/libdns/namedotcom
modulepackage
0.3.3
Repository: https://github.com/libdns/namedotcom.git
Documentation: pkg.go.dev

# README

name.com for libdns

Go Reference

This package implements the libdns interfaces for name.com, allowing you to manage DNS records.

Authenticating

To initiate the provider you need to supply the following parameters:

provider := namedotcom.Provider {
	Token : "NAMEDOTCOM_API_TOKEN",
	User :  "NAMEDOTCOM_USER_NAME",
	Server: "https://api.name.com", // full url scheme expected here..
}

Example

Here's a basic example of how to list, update and delete records using this provider

package main

import (
	"context"
	"github.com/libdns/libdns"
	"os"
	"github.com/libdns/namedotcom"
	"log"
)

func main() {
	ctx := context.Background()

	zone := "example.com."

	// configure the name.com DNS provider 
	provider := namedotcom.Provider{
		Token : os.GetEnv("NAMEDOTCOM_API_TOKEN"),
		User :     os.GetEnv("NAMEDOTCOM_USER_NAME"),
		Server:    os.GetEnv("NAMEDOTCOM_SERVER"),
	}

	// list and iterate through all records
	recs, err := provider.GetRecords(ctx, zone)
	if err != nil {
		log.Fatal(err)
	}

	for _, rec := range recs {
		log.Println(rec)
	}


	// attempts an upsert, PUT or POST for the given record
	newRecs, err = provider.SetRecords(ctx, zone, []libdns.Record{
		Type:  "A",
		Name:  "sub",
		Value: "1.2.3.4",
	})

	// delete records deletes the given record by ID.
	deletedRecs, err = provider.DeleteRecords(ctx, zone, []libdns.Record{
		Type:  "A",
		Name:  "sub",
		Value: "1.2.3.4",
	})

}

# Functions

NewNameDotComClient returns a new name.com client struct.

# Constants

default timeout for the http request handler (seconds).

# Structs

Provider implements the libdns interface for namedotcom.