lbapi

package module
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2017 License: MIT Imports: 7 Imported by: 4

README

LogicBoxes API tools Build Status

Go SDK and tools for the LogicBoxes API used by ResellerClub and other domain registrars.

Who is it for?

This is only useful if you have a reseller account with anyone using the LogicBoxes system and its APIs, and would like to manage customers, domains and DNS from the command line.

The planned backend server will also be useful if you need to expose DNS management or other simpler management to users, either via web or custom clients.

Features (work in progress)

  • Manage customers: Look up account details, sign up new ones, reset passwords, edit details, suspend and delete, authenticate passwords (for making backend services).
  • Manage domains: Look up domains per customer, list all, edit details, toggle locks, transfer, renew, change name servers.
  • Manage DNS for domains: Add, remove and change all records.

Planned features

The following features take a lower priority than getting the three major parts of the API supported (customers, domains and DNS) with a command line tool to handle everything implemented.

  • Backend server: REST layer between frontends and the LB API to make it easier to set up your own custom website, rather than using LB's Supersite.
  • Client tool for DNS management via the backend server.

These planned features are things I will be dogfooding. Likely to be implemented soon, depending on when the main features are done.

Possible features

  • Managing other products than just domains
  • Reseller management
  • Interactive mode using a fancy terminal interface.

Dependencies

  1. Go, currently tested with v1.8.x+.
  2. go-flags
  3. columnize
  4. gorilla/mux
  5. countries
  6. slog
  7. x/crypto/sha3

Platforms

Should work anywhere Go compiles to. The server tools are mainly tested on Linux but work on macOS. The command line tools and SDK should be universal, but currently needs a few lines of code for Windows support.

Licence

MIT.

Documentation

Overview

Utility functions used while parsing the somewhat convoluted JSON returned by LogicBoxes API calls.

Index

Constants

View Source
const (
	// APIURL is the default LogicBoxes API URL.
	APIURL = "https://httpapi.com/api/"
	// APITESTURL is the LogicBoxes API URL used for test accounts.
	APITESTURL = "https://test.httpapi.com/api/"

	// apiDomainsSearch is the source of all domain order information.
	APIDomainsSearch = "api/domains/search.json"
	APIDNSAddIPv4    = "api/dns/manage/add-ipv4-record.json"
	APIDNSAddIPv6    = "api/dns/manage/add-ipv6-record.json"
	APIDNSAddCNAME   = "api/dns/manage/add-cname-record.json"
	APIDNSAddMX      = "api/dns/manage/add-mx-record.json"
	APIDNSAddNS      = "api/dns/manage/add-ns-record.json"
	APIDNSAddTXT     = "api/dns/manage/add-txt-record.json"
	APIDNSAddSRV     = "api/dns/manage/add-srv-record.json"

	APIDNSDeleteIPv4  = "api/dns/manage/delete-ipv4-record.json"
	APIDNSDeleteIPv6  = "api/dns/manage/delete-ipv6-record.json"
	APIDNSDeleteCNAME = "api/dns/manage/delete-cname-record.json"
	APIDNSDeleteMX    = "api/dns/manage/delete-mx-record.json"
	APIDNSDeleteNS    = "api/dns/manage/delete-ns-record.json"
	APIDNSDeleteTXT   = "api/dns/manage/delete-txt-record.json"
	APIDNSDeleteSRV   = "api/dns/manage/delete-srv-record.json"

	APIDNSUpdateIPv4  = "api/dns/manage/update-ipv4-record.json"
	APIDNSUpdateIPv6  = "api/dns/manage/update-ipv6-record.json"
	APIDNSUpdateCNAME = "api/dns/manage/update-cname-record.json"
	APIDNSUpdateMX    = "api/dns/manage/update-mx-record.json"
	APIDNSUpdateNS    = "api/dns/manage/update-ns-record.json"
	APIDNSUpdateTXT   = "api/dns/manage/update-txt-record.json"
	APIDNSUpdateSRV   = "api/dns/manage/update-srv-record.json"
	APIDNSUpdateSOA   = "api/dns/manage/update-soa-record.json"
)

Variables

This section is empty.

Functions

func Atoi

func Atoi(s string) int64

func GetResponse

func GetResponse(c http.Client, url string) (*maplist, error)

GetReponse fetches a URL's JSON, decode it into a maplist and returns it as a map of strings.

func ParseBool

func ParseBool(b string) bool

func ParseDate

func ParseDate(s string) time.Time

func PostResponse

func PostResponse(c http.Client, url string) (*maplist, error)

PostResponse does pretty much the same as getResponse(), but with the POST method.

Types

type Client

type Client struct {
	http.Client
	// URL of the API, usually https://httpapi.com.
	URL string
	// ID of the reseller.
	ID string
	// Key to authenticate with.
	Key string
}

Client is the structure for reseller API access to LogicBoxes systems.

func NewClient

func NewClient(api string, resellerid int64, apikey string) *Client

NewClient creates a client structure with a HTTP client for the specified API.

func (*Client) AddARecord

func (c *Client) AddARecord(domain, address, host string, ttl int64, six bool) error

AddARecord adds A or AAAA records.

func (*Client) AddCNAME

func (c *Client) AddCNAME(domain, value, host string, ttl int64) error

AddCNAME does exactly that.

func (*Client) AddMX

func (c *Client) AddMX(domain, value, host string, ttl int64, priority uint16) error

AddMX adds MX records for mail servers.

func (*Client) AddNS

func (c *Client) AddNS(domain, value, host string, ttl int64, priority uint16) error

AddNS adds name server records.

func (*Client) AddSRV

func (c *Client) AddSRV(domain, value, host string, ttl int64, priority, port, weight uint16) error

AddSRV adds SRV records.

func (*Client) AddTXT

func (c *Client) AddTXT(domain, value, host string, ttl int64, priority uint16) error

AddTXT adds TXT records.

func (*Client) Authenticate

func (c *Client) Authenticate(username, password string) (*CustomerDetails, error)

func (*Client) CustomerByID

func (c *Client) CustomerByID(cid int64) (*CustomerDetails, error)

func (*Client) Customers

func (c *Client) Customers(page int) (*CustomerList, error)

func (*Client) DNSActive

func (c *Client) DNSActive(id string) bool

DNSActive reports if an order has activated DNS yet. This is normally on by default, but will be activated when this is called otherwise.

func (*Client) DeleteARecord

func (c *Client) DeleteARecord(domain, value, host string, six bool) error

DeleteARecord deletes A or AAAA records.

func (*Client) DeleteCNAME

func (c *Client) DeleteCNAME(domain, value, host string) error

DeleteCNAME does exactly that.

func (*Client) DeleteMX

func (c *Client) DeleteMX(domain, value, host string) error

DeleteMX holds no surprises.

func (*Client) DeleteNS

func (c *Client) DeleteNS(domain, value, host string) error

DeleteNS is as boring as the above.

func (*Client) DeleteSRV

func (c *Client) DeleteSRV(domain, value, host string, port, weight uint16) error

DeleteSRV deletes SRV records.

func (*Client) DeleteTXT

func (c *Client) DeleteTXT(domain, value, host string) error

DeleteTXT deletes TXT records.

func (*Client) Domain

func (c *Client) Domain(name string) (*Domain, error)

func (*Client) DomainsFor

func (c *Client) DomainsFor(customer string, page int) (*DomainList, error)

DomainsFor customer, starting on a specified page. Up to 500 records are returned. Compare Count and MaxRecords to tell if another page exists.

func (*Client) EditARecord

func (c *Client) EditARecord(domain, oldip, newip, host string, ttl int64, six bool) error

EditARecord modifies A or AAAA records.

func (*Client) EditCNAME

func (c *Client) EditCNAME(domain, oldip, newip, host string, ttl int64) error

EditCNAME modifies CNAME (canonical name) records.

func (*Client) EditMX

func (c *Client) EditMX(domain, oldip, newip, host string, ttl int64, priority uint16) error

EditMX modifies MX (mail server) records.

func (*Client) EditNS

func (c *Client) EditNS(domain, oldip, newip, host string, ttl int64) error

EditNS modifies NS (nameserver) records.

func (*Client) EditSOA

func (c *Client) EditSOA(domain, person string, refresh, retry, expire, ttl int64) error

EditSOA modifies a SOA (Start of Authority) record.

func (*Client) EditSRV

func (c *Client) EditSRV(domain, oldval, newval, host string, ttl int64, priority, port, weight uint) error

EditSRV modifies a SRV (service) record.

func (*Client) EditTXT

func (c *Client) EditTXT(domain, oldip, newip, host string, ttl int64) error

EditTXT modfies TXT records.

func (*Client) GetDNSRecords

func (c *Client) GetDNSRecords(domain, value, host, t string, page int) (*DNSRecordList, error)

GetDNSRecords gets the first up to 50 records of one type for a domain. Pass a higher page number to get the next set of up to 50.

type Customer

type Customer struct {
	ID            int64
	Email         string
	Name          string
	Company       string
	City          string
	Country       string
	Status        string
	TotalReceipts string

	Websites int64
}

Customer is the simple overview returned by bulk search of customers.

type CustomerDetails

type CustomerDetails struct {
	Created        time.Time
	ID             int64
	ParentReseller int64

	Name          string
	Email         string
	Phone         string
	Address       string
	Zip           string
	City          string
	State         string
	Country       string
	Language      string
	PIN           string
	Status        string
	TotalReceipts string

	Twofactor bool
}

CustomerDetails contains the personal details returned by single-user fetch.

type CustomerList

type CustomerList struct {
	// Count of records returned in this structure.
	Count int64
	// MaxRecords is the total available for this query.
	MaxRecords int64
	// Domains for the specified search query.
	Customers Customers
}

CustomerList is what client software gets. It's not guaranteed to hold all records, so check Count against MaxRecords.

type Customers

type Customers []*Customer

func (Customers) Len

func (slice Customers) Len() int

func (Customers) Less

func (slice Customers) Less(i, j int) bool

func (Customers) Swap

func (slice Customers) Swap(i, j int)

type DNSRecord

type DNSRecord struct {
	TTL      int64  // 7200 is a safe default
	Priority uint16 // Only available for some record types
	Port     uint16 // Only available for some record types
	Weight   uint16 // Only available for some record types
	Host     string // subdomain or @ for the primary domain
	Type     string // A, AAAA, MX etc.
	Value    string // IPv4 or IPv6 address
	Status   string // Normally "Active"
}

DNSRecord is an individual record.

func ParseDNS

func ParseDNS(in interface{}) *DNSRecord

ParseDNS converts a k-v table to a DNSRecord.

type DNSRecordList

type DNSRecordList struct {
	// Count of records returned in this structure.
	Count int64
	// MaxRecords is the total available for this query.
	MaxRecords int64
	// Domains for the specified search query.
	Records DNSRecords
}

DNSRecordList is what client software gets. It's not guaranteed to hold all records, so check Count against MaxRecords.

type DNSRecords

type DNSRecords []*DNSRecord

DNSRecords is a special sortable structure.

func (DNSRecords) Len

func (slice DNSRecords) Len() int

Len reports the number of records.

func (DNSRecords) Less

func (slice DNSRecords) Less(i, j int) bool

Less checks if host name i comes before host name j.

func (DNSRecords) Swap

func (slice DNSRecords) Swap(i, j int)

Swap does what it says.

type Domain

type Domain struct {
	Endtime      time.Time
	CreationTime time.Time
	CreationDT   time.Time
	Timestamp    time.Time

	OrderID     int64
	CustomerID  int64
	EntityID    int64
	TypeID      int64
	Description string
	Status      string
	TypeKey     string
	TypeName    string

	Autorenew    bool
	ResellerLock bool
	CustomerLock bool
	TransferLock bool
}

Domain is the parsed structure from the messy JSON returned by LogicBoxes.

type DomainList

type DomainList struct {
	// Count of records returned in this structure.
	Count int64
	// MaxRecords can be used to calculate pagination.
	MaxRecords int64
	// Domains for the specified search query.
	Domains Domains
}

DomainList is what client software gets. It's not guaranteed to hold all records, so check Count against MaxRecords.

type Domains

type Domains []*Domain

Domains is a sortable list of domains by order ID.

func (Domains) Len

func (slice Domains) Len() int

Len is the number of domains.

func (Domains) Less

func (slice Domains) Less(i, j int) bool

Less compares order IDs for sorting.

func (Domains) Swap

func (slice Domains) Swap(i, j int)

Swap does just that.

type DomainsByName

type DomainsByName []*Domain

DomainsByName uses the name instead.

func (DomainsByName) Len

func (slice DomainsByName) Len() int

Len is the number of domains.

func (DomainsByName) Less

func (slice DomainsByName) Less(i, j int) bool

Less compares domain names for sorting.

func (DomainsByName) Swap

func (slice DomainsByName) Swap(i, j int)

Swap does just that.

Directories

Path Synopsis
cmd
Repeated strings and shorthand.
Repeated strings and shorthand.
The janitor cleans up expired tokens.
The janitor cleans up expired tokens.
api

Jump to

Keyboard shortcuts

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