nodion

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: MPL-2.0 Imports: 11 Imported by: 6

README

Go library for accessing the Nodion DNS API

Build Status PkgGoDev Go Report Card

A Nodion API client written in Go.

nodion is a Go client library for accessing the Nodion DNS API.

Examples

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/nrdcg/nodion"
)

const apiToken = "xxx"

func main() {
	client, err := nodion.NewClient(apiToken)
	if err != nil {
		log.Fatal(err)
	}

	ctx := context.Background()

	zones, err := client.CreateZone(ctx, "example.com")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(zones)
}

API Documentation

Documentation

Overview

Package nodion contains a client of the DNS API of Nodion.

Index

Constants

View Source
const (
	TypeA     = "a"
	TypeAAAA  = "aaaa"
	TypeNS    = "ns"
	TypeALIAS = "alias"
	TypeCNAME = "cname"
	TypeMX    = "mx"
	TypeTXT   = "txt"
	TypePTR   = "ptr"
	TypeSRV   = "srv"
)

Record types.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int      `json:"status"`
	Message    string   `json:"error"`
	Errors     []string `json:"errors"`
}

APIError is the error returned by the server.

func (*APIError) Error

func (a *APIError) Error() string

type Client

type Client struct {
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

Client the Nodion API client.

func NewClient

func NewClient(apiToken string) (*Client, error)

NewClient creates a new Client.

func (Client) CreateRecord

func (c Client) CreateRecord(ctx context.Context, zoneID string, record Record) (*Record, error)

CreateRecord To create a new Record for a DNS zone. https://www.nodion.com/en/docs/dns/api/#post-dns-record

func (Client) CreateZone

func (c Client) CreateZone(ctx context.Context, name string) (*Zone, error)

CreateZone To create a new DNS Zone. https://www.nodion.com/en/docs/dns/api/#post-dns-zone

func (Client) DeleteRecord

func (c Client) DeleteRecord(ctx context.Context, zoneID, recordID string) (bool, error)

DeleteRecord To delete an existing Record for a DNS zone. https://www.nodion.com/en/docs/dns/api/#delete-dns-record

func (Client) DeleteZone

func (c Client) DeleteZone(ctx context.Context, zoneID string) (bool, error)

DeleteZone To delete an existing DNS Zone. https://www.nodion.com/en/docs/dns/api/#delete-dns-zone

func (Client) GetRecords

func (c Client) GetRecords(ctx context.Context, zoneID string, filter *RecordsFilter) ([]Record, error)

GetRecords To list all existing Records of a DNS zone. https://www.nodion.com/en/docs/dns/api/#get-dns-records

func (Client) GetZones

func (c Client) GetZones(ctx context.Context, filter *ZonesFilter) ([]Zone, error)

GetZones To list all existing DNS zones. https://www.nodion.com/en/docs/dns/api/#get-dns-zones

type DeleteResponse

type DeleteResponse struct {
	Deleted bool `json:"deleted"`
}

DeleteResponse represents the response of the API endpoints related to deletion of zone or record.

type Record

type Record struct {
	ID         string    `json:"id,omitempty"`
	RecordType string    `json:"record_type,omitempty"` // a, aaaa, ns, alias, cname, mx, txt, ptr, srv. Case-sensitive must be in lowercase.
	Name       string    `json:"name,omitempty"`
	Content    string    `json:"content,omitempty"`
	TTL        int       `json:"ttl,omitempty"` // a number between 60 and 86400.
	ZoneID     string    `json:"zone_id,omitempty"`
	CreatedAt  time.Time `json:"created_at,omitempty"`
	UpdatedAt  time.Time `json:"updated_at,omitempty"`
}

Record contains all the information related to a DNS record.

type RecordResponse

type RecordResponse struct {
	Record Record `json:"record"`
}

RecordResponse represents the response of the CreateRecord API endpoint.

type RecordsFilter

type RecordsFilter struct {
	Name       string `url:"name"`
	RecordType string `url:"record_type"`
	Content    string `url:"content"`
}

RecordsFilter is filter criteria for records.

type RecordsResponse

type RecordsResponse struct {
	Records []Record `json:"records"`
}

RecordsResponse represents the response of the GetRecords API endpoint.

type Zone

type Zone struct {
	ID        string    `json:"id,omitempty"`
	Name      string    `json:"name,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	Records   []Record  `json:"records,omitempty"`
}

Zone contains all the information related to a zone.

type ZoneResponse

type ZoneResponse struct {
	Zone Zone `json:"dns_zone"`
}

ZoneResponse represents the response of the CreateZone API endpoint.

type ZonesFilter

type ZonesFilter struct {
	Name string `url:"name"` // must be the exact name and no FQDN
}

ZonesFilter is filter criteria for zones.

type ZonesResponse

type ZonesResponse struct {
	Zones []Zone `json:"dns_zones"`
}

ZonesResponse represents the response of the GetZones API endpoint.

Jump to

Keyboard shortcuts

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