totaluptime

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2022 License: MIT Imports: 12 Imported by: 1

README

Total Uptime for libdns

Go Reference

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

Authenticating

This package supports basic authentication with Total Uptime's API. It's recommended that you create a role and user specific to API use, so that you can ensure least-privilege access to the account. Listed below are the steps to achieve this using Total Uptime's management portal:

  • Settings -> Roles & Security -> Role Management -> Add

    • Name: API_User_Role
    • DNS: Enabled
      • Information: Read
      • Domains: Full
    • (all other access set to "Disabled")
  • Settings -> Users -> Add

    • First Name: API
    • Last Name: User
    • User Name (Email): apiuser@mydomain.com (can be anything and does not need to receive mail)
    • Active: [ X ] (checked)
    • Role: API_User_Role
    • API Account: [ X ] (checked)

Example

Here's a minimal example of how to list all DNS records using this libdns provider (see examples/main.go for more examples)

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/libdns/totaluptime"
)

func main() func main() {
	provider := totaluptime.Provider{
		Username: "USERNAME", // provider API username
		Password: "PASSWORD", // provider API password
	}

	zone := "DNS_ZONE" // zone in provider account
	ctx := context.Background()

	result, err := provider.GetRecords(ctx, zone)
	if err != nil {
		log.Fatalln(err)
	}

	fmt.Println(result)
}

Documentation

Overview

Package totaluptime implements a DNS record management client compatible with the libdns interfaces for Total Uptime. based on https://api.totaluptime.com/api-docs/index.html#!/Cloud32DNS32Calls

Index

Constants

This section is empty.

Variables

View Source
var (
	// APIbase is the base provider API URL.
	APIbase = "https://api.totaluptime.com/CloudDNS/Domain"

	// DomainIDs is a cache of domain-to-ID cross-references.
	DomainIDs map[string]string

	// RecordIDs is a cache of domain/record-to-ID cross-references.
	RecordIDs map[string]string

	// Client is the currently-active HTTP client.
	Client http.Client
)

Functions

This section is empty.

Types

type Domains

type Domains struct {
	Rows []struct {
		DomainName string `json:"domainName"`
		ID         string `json:"id"`
	} `json:"rows"`
}

Domains type stores details about all domains in the account.

type Provider

type Provider struct {
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
}

Provider facilitates DNS record manipulation with Total Uptime.

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. It returns the records that were deleted.

func (*Provider) GetRecords

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

GetRecords lists all (supported type) records in the zone.

func (*Provider) ModifyRecord

func (p *Provider) ModifyRecord(ctx context.Context, zone string, rec libdns.Record) (libdns.Record, error)

ModifyRecord will modify a single pre-existing record in the specified zone. It returns the updated record.

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 TotalUptimeRecords

type TotalUptimeRecords struct {
	StatusCode  interface{} `json:"StatusCode"`
	Type        interface{} `json:"Type"`
	A6Record    interface{} `json:"A6Record"`
	AAAARecord  interface{} `json:"AAAARecord"`
	AFSDBRecord interface{} `json:"AFSDBRecord"`
	ARecord     struct {
		Message interface{} `json:"message"`
		Page    int         `json:"page"`
		Rows    []struct {
			StatusCode   interface{} `json:"StatusCode"`
			Type         interface{} `json:"Type"`
			AALFPac      string      `json:"aALFPac"`
			AALFPacID    string      `json:"aALFPacId"`
			AFailover    string      `json:"aFailover"`
			AFailoverID  string      `json:"aFailoverId"`
			AGeoZone     string      `json:"aGeoZone"`
			AGeoZoneID   string      `json:"aGeoZoneId"`
			AHostName    string      `json:"aHostName"`
			AIPAddress   string      `json:"aIPAddress"`
			AStamp       string      `json:"aStamp"`
			ATTL         string      `json:"aTTL"`
			AltIPAddress interface{} `json:"altIPAddress"`
			DomainID     interface{} `json:"domainID"`
			DomainName   interface{} `json:"domainName"`
			Errors       string      `json:"errors"`
			ID           string      `json:"id"`
			IsSameTTL    bool        `json:"isSameTTL"`
			Status       string      `json:"status"`
		} `json:"rows"`
		Status       string `json:"status"`
		Totalpages   int    `json:"totalpages"`
		Totalrecords int    `json:"totalrecords"`
		Userdata     string `json:"userdata"`
	} `json:"ARecord"`
	ATMARecord  interface{} `json:"ATMARecord"`
	CAARecord   interface{} `json:"CAARecord"`
	CNAMERecord struct {
		Message interface{} `json:"message"`
		Page    int         `json:"page"`
		Rows    []struct {
			StatusCode    interface{} `json:"StatusCode"`
			Type          interface{} `json:"Type"`
			CnameAliasFor string      `json:"cnameAliasFor"`
			CnameName     string      `json:"cnameName"`
			CnameStamp    string      `json:"cnameStamp"`
			CnameTTL      string      `json:"cnameTTL"`
			DomainID      interface{} `json:"domainID"`
			Errors        string      `json:"errors"`
			ID            string      `json:"id"`
			IsSameTTL     bool        `json:"isSameTTL"`
			Status        string      `json:"status"`
		} `json:"rows"`
		Status       string `json:"status"`
		Totalpages   int    `json:"totalpages"`
		Totalrecords int    `json:"totalrecords"`
		Userdata     string `json:"userdata"`
	} `json:"CNAMERecord"`
	DNAMERecord interface{} `json:"DNAMERecord"`
	DSRecord    interface{} `json:"DSRecord"`
	HINFORecord interface{} `json:"HINFORecord"`
	ISDNRecord  interface{} `json:"ISDNRecord"`
	LOCRecord   interface{} `json:"LOCRecord"`
	MBRecord    interface{} `json:"MBRecord"`
	MGRecord    interface{} `json:"MGRecord"`
	MINFORecord interface{} `json:"MINFORecord"`
	MRRecord    interface{} `json:"MRRecord"`
	MXRecord    struct {
		Message interface{} `json:"message"`
		Page    int         `json:"page"`
		Rows    []struct {
			StatusCode   interface{} `json:"StatusCode"`
			Type         interface{} `json:"Type"`
			DomainID     interface{} `json:"domainID"`
			Errors       string      `json:"errors"`
			ID           string      `json:"id"`
			IsSameTTL    bool        `json:"isSameTTL"`
			MxDomainName string      `json:"mxDomainName"`
			MxMailServer string      `json:"mxMailServer"`
			MxPreference string      `json:"mxPreference"`
			MxStamp      string      `json:"mxStamp"`
			MxTTL        string      `json:"mxTTL"`
			Status       string      `json:"status"`
		} `json:"rows"`
		Status       string `json:"status"`
		Totalpages   int    `json:"totalpages"`
		Totalrecords int    `json:"totalrecords"`
		Userdata     string `json:"userdata"`
	} `json:"MXRecord"`
	NAPTRRecord interface{} `json:"NAPTRRecord"`
	NSAPRecord  interface{} `json:"NSAPRecord"`
	NSRecord    struct {
		Message interface{} `json:"message"`
		Page    int         `json:"page"`
		Rows    []struct {
			StatusCode interface{} `json:"StatusCode"`
			Type       interface{} `json:"Type"`
			DomainID   interface{} `json:"domainID"`
			Errors     string      `json:"errors"`
			ID         string      `json:"id"`
			IsSameTTL  bool        `json:"isSameTTL"`
			NsHostName string      `json:"nsHostName"`
			NsName     string      `json:"nsName"`
			NsStamp    string      `json:"nsStamp"`
			NsTTL      string      `json:"nsTTL"`
			Status     string      `json:"status"`
		} `json:"rows"`
		Status       string `json:"status"`
		Totalpages   int    `json:"totalpages"`
		Totalrecords int    `json:"totalrecords"`
		Userdata     string `json:"userdata"`
	} `json:"NSRecord"`
	PTRRecord interface{} `json:"PTRRecord"`
	RPRecord  interface{} `json:"RPRecord"`
	RTRecord  interface{} `json:"RTRecord"`
	SOARecord struct {
		Message interface{} `json:"message"`
		Page    int         `json:"page"`
		Rows    []struct {
			StatusCode          interface{} `json:"StatusCode"`
			Type                interface{} `json:"Type"`
			DomainID            interface{} `json:"domainID"`
			Errors              string      `json:"errors"`
			ID                  string      `json:"id"`
			SoaExpireTime       string      `json:"soaExpireTime"`
			SoaMinDefaultTTL    string      `json:"soaMinDefaultTTL"`
			SoaPrimaryDNS       string      `json:"soaPrimaryDNS"`
			SoaRefreshInterval  string      `json:"soaRefreshInterval"`
			SoaResponsibleEmail string      `json:"soaResponsibleEmail"`
			SoaRetryInterval    string      `json:"soaRetryInterval"`
			SoaSerialNumber     string      `json:"soaSerialNumber"`
			SoaStamp            string      `json:"soaStamp"`
			SoaTTL              string      `json:"soaTTL"`
			SoaVersionNumber    string      `json:"soaVersionNumber"`
			Status              string      `json:"status"`
		} `json:"rows"`
		Status       string `json:"status"`
		Totalpages   int    `json:"totalpages"`
		Totalrecords int    `json:"totalrecords"`
		Userdata     string `json:"userdata"`
	} `json:"SOARecord"`
	SPFRecord interface{} `json:"SPFRecord"`
	SRVRecord struct {
		Message interface{} `json:"message"`
		Page    int         `json:"page"`
		Rows    []struct {
			StatusCode    interface{} `json:"StatusCode"`
			Type          interface{} `json:"Type"`
			DomainID      interface{} `json:"domainID"`
			Errors        string      `json:"errors"`
			ID            string      `json:"id"`
			IsSameTTL     bool        `json:"isSameTTL"`
			Port          string      `json:"port"`
			Priority      string      `json:"priority"`
			SrvDomainName string      `json:"srvDomainName"`
			SrvStamp      string      `json:"srvStamp"`
			SrvTTL        string      `json:"srvTTL"`
			Status        string      `json:"status"`
			Target        string      `json:"target"`
			Weight        string      `json:"weight"`
		} `json:"rows"`
		Status       string `json:"status"`
		Totalpages   int    `json:"totalpages"`
		Totalrecords int    `json:"totalrecords"`
		Userdata     string `json:"userdata"`
	} `json:"SRVRecord"`
	TLSARecord interface{} `json:"TLSARecord"`
	TXTRecord  struct {
		Message interface{} `json:"message"`
		Page    int         `json:"page"`
		Rows    []struct {
			StatusCode  interface{} `json:"StatusCode"`
			Type        interface{} `json:"Type"`
			DomainID    interface{} `json:"domainID"`
			Errors      string      `json:"errors"`
			ID          string      `json:"id"`
			IsSameTTL   bool        `json:"isSameTTL"`
			Status      string      `json:"status"`
			TxtHostName string      `json:"txtHostName"`
			TxtStamp    string      `json:"txtStamp"`
			TxtTTL      string      `json:"txtTTL"`
			TxtText     string      `json:"txtText"`
		} `json:"rows"`
		Status       string `json:"status"`
		Totalpages   int    `json:"totalpages"`
		Totalrecords int    `json:"totalrecords"`
		Userdata     string `json:"userdata"`
	} `json:"TXTRecord"`
	Type257Record     interface{} `json:"Type257Record"`
	WebRedirectRecord struct {
		Message interface{} `json:"message"`
		Page    int         `json:"page"`
		Rows    []struct {
			StatusCode       interface{} `json:"StatusCode"`
			Type             interface{} `json:"Type"`
			CarryPath        string      `json:"CarryPath"`
			Dest             string      `json:"Dest"`
			HostName         string      `json:"HostName"`
			RedirectType     string      `json:"RedirectType"`
			WebRedirectStamp string      `json:"WebRedirectStamp"`
			DomainID         interface{} `json:"domainID"`
			Errors           string      `json:"errors"`
			ID               string      `json:"id"`
			Status           string      `json:"status"`
		} `json:"rows"`
		Status       string `json:"status"`
		Totalpages   int    `json:"totalpages"`
		Totalrecords int    `json:"totalrecords"`
		Userdata     string `json:"userdata"`
	} `json:"WebRedirectRecord"`
	X25Record interface{} `json:"X25Record"`
	Message   interface{} `json:"message"`
	Status    string      `json:"status"`
	Userdata  interface{} `json:"userdata"`
}

TotalUptimeRecords type stores details about resource records in a domain.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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