Help us shape the future of Go! Take the 2026 Go Developer Survey

desec

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: MPL-2.0 Imports: 8 Imported by: 24

README

Go library for accessing the deSEC API

GoDoc Build Status Go Report Card

An deSEC API client written in Go.

desec is a Go client library for accessing the deSEC API.

Examples

package main

import (
	"fmt"

	"github.com/nrdcg/desec"
)

func main() {
	client := desec.NewClient("token")

	newDomain, err := client.Domains.Create("example.com")
	if err != nil {
		panic(err)
	}

	fmt.Println(newDomain)
}
package main

import (
	"fmt"

	"github.com/nrdcg/desec"
)

func main() {
	client := desec.NewClient("")
	registration := desec.Registration{
		Email:    "email@example.com",
		Password: "secret",
		Captcha: &desec.Captcha{
			ID:       "00010203-0405-0607-0809-0a0b0c0d0e0f",
			Solution: "12H45",
		},
	}

	err := client.Account.Register(registration)
	if err != nil {
		panic(err)
	}
}
package main

import (
	"fmt"

	"github.com/nrdcg/desec"
)

func main() {
	client := desec.NewClient("")

	_, err := client.Account.Login("email@example.com", "secret")
	if err != nil {
		panic(err)
	}

	domains, err := client.Domains.GetAll()
	if err != nil {
		panic(err)
	}

	fmt.Println(domains)

	err = client.Account.Logout()
	if err != nil {
		panic(err)
	}
}

API Documentation

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError added in v0.2.0

type APIError struct {
	StatusCode int
	// contains filtered or unexported fields
}

APIError error from API.

func (APIError) Error added in v0.2.0

func (e APIError) Error() string

func (APIError) Unwrap added in v0.2.0

func (e APIError) Unwrap() error

Unwrap unwraps error.

type Account

type Account struct {
	Email        string     `json:"email"`
	Password     string     `json:"password"`
	LimitDomains int        `json:"limit_domains,omitempty"`
	Created      *time.Time `json:"created,omitempty"`
}

Account an account representation.

type AccountService added in v0.2.0

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

AccountService handles communication with the account related methods of the deSEC API.

https://desec.readthedocs.io/en/latest/auth/account.html

func (*AccountService) ChangeEmail added in v0.2.0

func (s *AccountService) ChangeEmail(email, password string, newEmail string) error

ChangeEmail changes email address. https://desec.readthedocs.io/en/latest/auth/account.html#change-email-address

func (*AccountService) Delete added in v0.2.0

func (s *AccountService) Delete(email, password string) error

Delete deletes account. https://desec.readthedocs.io/en/latest/auth/account.html#delete-account

func (*AccountService) Login added in v0.2.0

func (s *AccountService) Login(email, password string) (*Token, error)

Login Log in. https://desec.readthedocs.io/en/latest/auth/account.html#log-in

func (*AccountService) Logout added in v0.2.0

func (s *AccountService) Logout() error

Logout log out (= delete current token). https://desec.readthedocs.io/en/latest/auth/account.html#log-out

func (*AccountService) ObtainCaptcha added in v0.2.0

func (s *AccountService) ObtainCaptcha() (*Captcha, error)

ObtainCaptcha Obtain a captcha. https://desec.readthedocs.io/en/latest/auth/account.html#obtain-a-captcha

func (*AccountService) PasswordReset added in v0.2.0

func (s *AccountService) PasswordReset(email string, captcha Captcha) error

PasswordReset password reset and password change. https://desec.readthedocs.io/en/latest/auth/account.html#password-reset https://desec.readthedocs.io/en/latest/auth/account.html#password-change

func (*AccountService) Register added in v0.2.0

func (s *AccountService) Register(registration Registration) error

Register register account. https://desec.readthedocs.io/en/latest/auth/account.html#register-account

func (*AccountService) RetrieveInformation added in v0.2.0

func (s *AccountService) RetrieveInformation() (*Account, error)

RetrieveInformation retrieve account information. https://desec.readthedocs.io/en/latest/auth/account.html#retrieve-account-information

type Captcha

type Captcha struct {
	ID        string `json:"id,omitempty"`
	Challenge string `json:"challenge,omitempty"`
	Solution  string `json:"solution,omitempty"`
}

Captcha a captcha representation.

type Client

type Client struct {
	// HTTP client used to communicate with the API.
	HTTPClient *http.Client

	// Base URL for API requests.
	BaseURL string

	// Services used for talking to different parts of the deSEC API.
	Account *AccountService
	Tokens  *TokensService
	Records *RecordsService
	Domains *DomainsService
	// contains filtered or unexported fields
}

Client deSEC API client.

func NewClient

func NewClient(token string) *Client

NewClient creates a new Client.

type Domain

type Domain struct {
	Name       string      `json:"name,omitempty"`
	MinimumTTL int         `json:"minimum_ttl,omitempty"`
	Keys       []DomainKey `json:"keys,omitempty"`
	Created    *time.Time  `json:"created,omitempty"`
	Published  *time.Time  `json:"published,omitempty"`
}

Domain a domain representation.

type DomainKey

type DomainKey struct {
	DNSKey  string   `json:"dnskey,omitempty"`
	DS      []string `json:"ds,omitempty"`
	Flags   int      `json:"flags,omitempty"`
	KeyType string   `json:"keytype,omitempty"`
}

DomainKey a domain key representation.

type DomainsService

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

DomainsService handles communication with the domain related methods of the deSEC API.

https://desec.readthedocs.io/en/latest/dns/domains.html

func (*DomainsService) Create

func (s *DomainsService) Create(domainName string) (*Domain, error)

Create creating a domain. https://desec.readthedocs.io/en/latest/dns/domains.html#creating-a-domain

func (*DomainsService) Delete

func (s *DomainsService) Delete(domainName string) error

Delete deleting a domain. https://desec.readthedocs.io/en/latest/dns/domains.html#deleting-a-domain

func (*DomainsService) Get

func (s *DomainsService) Get(domainName string) (*Domain, error)

Get retrieving a specific domain. https://desec.readthedocs.io/en/latest/dns/domains.html#retrieving-a-specific-domain

func (*DomainsService) GetAll

func (s *DomainsService) GetAll() ([]Domain, error)

GetAll listing domains. https://desec.readthedocs.io/en/latest/dns/domains.html#listing-domains

type NotFound

type NotFound struct {
	Detail string `json:"detail"`
}

NotFound Not found error.

func (NotFound) Error

func (n NotFound) Error() string

type RRSet

type RRSet struct {
	Name    string     `json:"name,omitempty"`
	Domain  string     `json:"domain,omitempty"`
	SubName string     `json:"subname,omitempty"`
	Type    string     `json:"type,omitempty"`
	Records []string   `json:"records"`
	TTL     int        `json:"ttl,omitempty"`
	Created *time.Time `json:"created,omitempty"`
}

RRSet DNS Record Set.

type RRSetFilter

type RRSetFilter struct {
	Type    string
	SubName string
}

RRSetFilter a RRsets filter.

type RecordsService

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

RecordsService handles communication with the records related methods of the deSEC API.

https://desec.readthedocs.io/en/latest/dns/rrsets.html

func (*RecordsService) Create

func (s *RecordsService) Create(rrSet RRSet) (*RRSet, error)

Create creates a new RRSet. https://desec.readthedocs.io/en/latest/dns/rrsets.html#creating-a-tlsa-rrset

func (*RecordsService) Delete

func (s *RecordsService) Delete(domainName string, subName string, recordType string) error

Delete deletes a RRset. https://desec.readthedocs.io/en/latest/dns/rrsets.html#deleting-an-rrset

func (*RecordsService) Get

func (s *RecordsService) Get(domainName, subName string, recordType string) (*RRSet, error)

Get gets a RRSet. https://desec.readthedocs.io/en/latest/dns/rrsets.html#retrieving-a-specific-rrset

func (*RecordsService) GetAll

func (s *RecordsService) GetAll(domainName string, filter *RRSetFilter) ([]RRSet, error)

GetAll retrieving all RRsets in a zone. https://desec.readthedocs.io/en/latest/dns/rrsets.html#retrieving-all-rrsets-in-a-zone

func (*RecordsService) Update

func (s *RecordsService) Update(domainName string, subName string, recordType string, records []string) (*RRSet, error)

Update updates RRSet records. https://desec.readthedocs.io/en/latest/dns/rrsets.html#modifying-an-rrset

type Registration

type Registration struct {
	Email    string   `json:"email,omitempty"`
	Password string   `json:"password,omitempty"`
	NewEmail string   `json:"new_email,omitempty"`
	Captcha  *Captcha `json:"captcha,omitempty"`
}

Registration a registration representation.

type Token

type Token struct {
	ID      string     `json:"id,omitempty"`
	Name    string     `json:"name,omitempty"`
	Value   string     `json:"token,omitempty"`
	Created *time.Time `json:"created,omitempty"`
}

Token a token representation.

type TokensService

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

TokensService handles communication with the tokens related methods of the deSEC API.

https://desec.readthedocs.io/en/latest/auth/tokens.html

func (*TokensService) Create

func (s *TokensService) Create(name string) (*Token, error)

Create creates additional tokens. https://desec.readthedocs.io/en/latest/auth/tokens.html#create-additional-tokens

func (*TokensService) Delete

func (s *TokensService) Delete(tokenID string) error

Delete deletes tokens. https://desec.readthedocs.io/en/latest/auth/tokens.html#delete-tokens

func (*TokensService) GetAll

func (s *TokensService) GetAll() ([]Token, error)

GetAll retrieving all current tokens. https://desec.readthedocs.io/en/latest/auth/tokens.html#retrieving-all-current-tokens

Jump to

Keyboard shortcuts

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