namecheap

package module
v0.0.0-...-2eea33f Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2021 License: MIT Imports: 5 Imported by: 12

README

Namecheap for libdns

Go Reference

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

Usage

See namecheap api docs for details on how to get setup with using the namecheap API.

Once you have an API Key and have whitelisted your client IP, you can begin using this library. There's a simple integration test under ./internal/testing that can be used for testing with this library and serves as an exmpale for usage. You can pass in your credentials through command line flags:

go test ./internal/testing/... -api-key <your_api_key> -username <your_username> -domain example.com.

By default the sandbox URL is used but you can also pass the production endpint with the -endpoint <url> flag.

Testing

Unit tests are run with go tooling and gofmt should be run prior to submitting patches.

go test -race ./internal/namecheap/...
go fmt ./...

Documentation

Overview

Package namecheap implements a DNS record management client compatible with the libdns interfaces for namecheap.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	// APIKey is your namecheap API key.
	// See: https://www.namecheap.com/support/api/intro/
	// for more details.
	APIKey string `json:"api_key,omitempty"`

	// User is your namecheap API user. This can be the same as your username.
	User string `json:"user,omitempty"`

	// APIEndpoint to use. If testing, you can use the "sandbox" endpoint
	// instead of the production one.
	APIEndpoint string `json:"api_endpoint,omitempty"`

	// ClientIP is the IP address of the requesting client.
	// If this is not set, a discovery service will be
	// used to determine the public ip of the machine.
	// You must first whitelist your IP in the namecheap console
	// before using the API.
	ClientIP string `json:"client_ip,omitempty"`
	// contains filtered or unexported fields
}

Provider facilitates DNS record manipulation with namecheap. The libdns methods that return updated structs do not have their ID fields set since this information is not returned by the namecheap API.

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. Note that the records returned do NOT have their IDs set as the namecheap API does not return this info.

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. Note that the records returned do NOT have their IDs set as the namecheap API does not return this info.

func (*Provider) GetRecords

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

GetRecords lists all the records in the zone. This method does return records with the ID field set.

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. Note that this method may alter the IDs of existing records on the server but may return records without their IDs set or with their old IDs set.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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