libwegener

package module
v0.0.0-...-c147f14 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2022 License: MIT Imports: 9 Imported by: 0

README

libwegener

small go lib to interact with the WegenerIT API (Docs)

currently implemented Endpoints

  • Domains
  • Hosting
  • DNS zones

example

package main

import (
	"fmt"
	lw "git.itbyhf.xyz/ha/libwegener"
	"log"
	"os"
)

func main() {
	client := lw.NewClient(
		lw.WithApiKey("API_KEY"),
		lw.WithCustomerId("CUSTOMER_ID"),
		lw.WithUserAgent("lw/custom"),
		lw.WithLogWriter(os.Stderr))

	zones, err := client.Dns.GetAllZones()
	if err != nil {
		log.Fatalf("Failed to get all zones: %s", err.Error())
	}
	fmt.Printf("Got all zones: %v", zones)

	domains, err := client.Domain.GetAll()
	if err != nil {
		log.Fatalf("Failed to get all domains: %s", err.Error())
	}
	fmt.Printf("Got all domains: %v", domains)

	records, err := client.Dns.GetRecords("example.com")
	if err != nil {
		log.Fatalf("Failed to get all records: %s", err.Error())
	}
	fmt.Printf("Got all records: %v", records)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientOption

type ClientOption func(*WegenerClient)

A ClientOption is used to configure a Client.

func WithApiKey

func WithApiKey(apiToken string) ClientOption

WithApiKey configures a Client to use the specified API Key

func WithCustomerId

func WithCustomerId(customerID string) ClientOption

WithCustomerId configures a Client to use the specified customer ID

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) ClientOption

WithHTTPClient configures a Client to perform HTTP requests with httpClient.

func WithLogWriter

func WithLogWriter(debugWriter io.Writer) ClientOption

WithLogWriter configures a Client to print debug information to the given writer. To, for example, print debug information on stderr, set it to os.Stderr.

func WithUserAgent

func WithUserAgent(agent string) ClientOption

WithUserAgent configures a Client to use a specific User Agent

type Dns

type Dns struct {
	Data models.Zones
}

type DnsClient

type DnsClient struct {
	// contains filtered or unexported fields
}

func (*DnsClient) AddRecord

func (d *DnsClient) AddRecord(domainName string, name string, recordType string, content string, ttl int, priority int) (models.CreateRecordResponse, error)

AddRecord adds a given record to a given zone

func (*DnsClient) DeleteRecord

func (d *DnsClient) DeleteRecord(domainName string, recordID int) (models.DeleteRecordResponse, error)

DeleteRecord removes a given record

func (*DnsClient) EditRecord

func (d *DnsClient) EditRecord(domainName string, recordID int, name string, recordType string, content string, ttl int, priority int) (models.CreateRecordResponse, error)

EditRecord edits a given record

func (*DnsClient) GetAllZones

func (d *DnsClient) GetAllZones() (models.Zones, error)

GetAllZones returns all DNS Zones

func (*DnsClient) GetRecords

func (d *DnsClient) GetRecords(domainName string) (models.ZoneRecords, error)

GetRecords returns all records of a Zone based on its name

func (*DnsClient) GetZoneByName

func (d *DnsClient) GetZoneByName(domainName string) (models.DomainResponse, error)

GetZoneByName returns a Zone based on its name

type Domain

type Domain struct {
	Data models.DomainResponse
}

type DomainClient

type DomainClient struct {
	// contains filtered or unexported fields
}

func (*DomainClient) DeleteDomain

func (d *DomainClient) DeleteDomain(domainName string, deletionType int) (models.AuthCodeResponse, error)

DeleteDomain deletes the Domain

func (*DomainClient) EditDomain

EditDomain updates the Domain settings

func (*DomainClient) GetAll

func (d *DomainClient) GetAll() (models.DomainResponse, error)

GetAll returns all domains

func (*DomainClient) GetAuthCode

func (d *DomainClient) GetAuthCode(domainName string) (models.AuthCodeResponse, error)

GetAuthCode requests the Domain Auth code for transfer

func (*DomainClient) GetByName

func (d *DomainClient) GetByName(domainName string) (models.DomainResponse, error)

GetByName returns a name by its Domain Name

func (*DomainClient) RegisterDomain

RegisterDomain registers a new domain

func (*DomainClient) TradeDomain

TradeDomain executes a domain owner change (trade)

func (*DomainClient) TransferDomain

TransferDomain transfers a new domain

type Hosting

type Hosting struct {
	Data models.Hosting
}

type HostingClient

type HostingClient struct {
	// contains filtered or unexported fields
}

func (*HostingClient) CancelContract

func (h *HostingClient) CancelContract(contractID int, date string) (models.CancelContractResponse, error)

func (*HostingClient) ExecuteTask

func (h *HostingClient) ExecuteTask(qStr int) (models.Hosting, error)

ExecuteTask executes a Task by a given Query URL in String form (e.g. ?id=12&action=doSth&domain=5)

func (*HostingClient) GetCancelDate

func (h *HostingClient) GetCancelDate(contractID int) (models.CancelDateResponse, error)

func (*HostingClient) Info

func (h *HostingClient) Info(contractID int) (models.Hosting, error)

Info returns an info about a contract based on its ID

func (*HostingClient) OrderProduct

func (h *HostingClient) OrderProduct(id int, note string) (models.OrderProductResponse, error)

func (*HostingClient) SetNote

func (h *HostingClient) SetNote(id int, note string) (models.CreateNoteResponse, error)

type WegenerClient

type WegenerClient struct {
	Domain  DomainClient
	Hosting HostingClient
	Dns     DnsClient
	// contains filtered or unexported fields
}

func NewClient

func NewClient(options ...ClientOption) *WegenerClient

NewClient creates a new client.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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