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

desec

package module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2022 License: MPL-2.0 Imports: 10 Imported by: 24

README

Go library for accessing the deSEC API

Build Status PkgGoDev 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 (
	"context"
	"fmt"

	"github.com/nrdcg/desec"
)

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

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

	fmt.Println(newDomain)
}
package main

import (
	"context"

	"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(context.Background(), registration)
	if err != nil {
		panic(err)
	}
}
package main

import (
	"context"
	"fmt"

	"github.com/nrdcg/desec"
)

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

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

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

	fmt.Println(domains)

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

API Documentation

Documentation

Index

Constants

View Source
const ApexZone = "@"

ApexZone apex zone name. https://desec.readthedocs.io/en/latest/dns/rrsets.html#accessing-the-zone-apex

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(ctx context.Context, email, password, 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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context) 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(ctx context.Context) (*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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context) (*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 {
	// 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 New added in v0.4.0

func New(token string, opts ClientOptions) *Client

New creates a new Client.

type ClientOptions added in v0.4.0

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

	// Maximum number of retries
	RetryMax int

	// Customer logger instance. Can be either Logger or LeveledLogger
	Logger interface{}
}

ClientOptions the options of the Client.

func NewDefaultClientOptions added in v0.4.0

func NewDefaultClientOptions() ClientOptions

NewDefaultClientOptions creates a new ClientOptions with default values.

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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context) ([]Domain, error)

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

func (*DomainsService) GetResponsible added in v0.7.0

func (s *DomainsService) GetResponsible(ctx context.Context, domainName string) (*Domain, error)

GetResponsible returns the responsible domain for a given DNS query name. https://desec.readthedocs.io/en/latest/dns/domains.html#identifying-the-responsible-domain-for-a-dns-name

type NotFoundError added in v0.6.0

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

NotFoundError Not found error.

func (NotFoundError) Error added in v0.6.0

func (n NotFoundError) 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(ctx context.Context, 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(ctx context.Context, domainName, subName, 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(ctx context.Context, domainName, subName, 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(ctx context.Context, 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) Replace added in v0.3.0

func (s *RecordsService) Replace(ctx context.Context, domainName, subName, recordType string, rrSet RRSet) (*RRSet, error)

Replace replaces a RRSet (PUT). https://desec.readthedocs.io/en/latest/dns/rrsets.html#modifying-an-rrset

func (*RecordsService) Update

func (s *RecordsService) Update(ctx context.Context, domainName, subName, recordType string, rrSet RRSet) (*RRSet, error)

Update updates RRSet (PATCH). 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(ctx context.Context, 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(ctx context.Context, tokenID string) error

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

func (*TokensService) GetAll

func (s *TokensService) GetAll(ctx context.Context) ([]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