safedns

package
v1.10.2 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: MIT Imports: 4 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateNoteRequest

type CreateNoteRequest struct {
	connection.APIRequestBodyDefaultValidator

	ContactID int    `json:"contact_id,omitempty"`
	Notes     string `json:"notes" validate:"required"`
}

CreateNoteRequest represents a request to create a SafeDNS note

func (*CreateNoteRequest) Validate

Validate returns an error if struct properties are missing/invalid

type CreateRecordRequest

type CreateRecordRequest struct {
	connection.APIRequestBodyDefaultValidator

	Name       string     `json:"name" validate:"required"`
	TemplateID int        `json:"template_id,omitempty"`
	Type       string     `json:"type" validate:"required"`
	Content    string     `json:"content" validate:"required"`
	TTL        *RecordTTL `json:"ttl,omitempty"`
	Priority   *int       `json:"priority,omitempty"`
}

CreateRecordRequest represents a request to create a SafeDNS record

func (*CreateRecordRequest) Validate

Validate returns an error if struct properties are missing/invalid

type CreateTemplateRequest

type CreateTemplateRequest struct {
	connection.APIRequestBodyDefaultValidator

	Name    string `json:"name" validate:"required"`
	Default bool   `json:"default"`
}

CreateTemplateRequest represents a request to create a SafeDNS template

func (*CreateTemplateRequest) Validate

Validate returns an error if struct properties are missing/invalid

type CreateZoneRequest

type CreateZoneRequest struct {
	connection.APIRequestBodyDefaultValidator

	Name        string `json:"name" validate:"required"`
	Description string `json:"description,omitempty"`
}

CreateZoneRequest represents a request to create a SafeDNS zone

func (*CreateZoneRequest) Validate

Validate returns an error if struct properties are missing/invalid

type CustomAXFRSettings

type CustomAXFRSettings struct {
	Allowed bool                   `json:"allowed"`
	Name    []string               `json:"name"`
	IP      []connection.IPAddress `json:"ip"`
}

CustomAXFRSettings represents SafeDNS account AXFR settings

type Nameserver

type Nameserver struct {
	Name string               `json:"name"`
	IP   connection.IPAddress `json:"ip"`
}

Nameserver represents a SafeDNS nameserver

type Note

type Note struct {
	ID        int                  `json:"id"`
	ContactID int                  `json:"contact_id"`
	Notes     string               `json:"notes"`
	CreatedAt connection.DateTime  `json:"created_at"`
	IP        connection.IPAddress `json:"ip"`
}

Note represents a SafeDNS note

type PatchRecordRequest

type PatchRecordRequest struct {
	Name     string     `json:"name,omitempty"`
	Type     string     `json:"type,omitempty"`
	Content  string     `json:"content,omitempty"`
	TTL      *RecordTTL `json:"ttl,omitempty"`
	Priority *int       `json:"priority,omitempty"`
}

PatchRecordRequest represents a SafeDNS record patch request

func (*PatchRecordRequest) Validate

Validate returns an error if struct properties are missing/invalid

type PatchTemplateRequest

type PatchTemplateRequest struct {
	Name    string `json:"name,omitempty"`
	Default *bool  `json:"default,omitempty"`
}

PatchTemplateRequest represents a SafeDNS template patch request

func (*PatchTemplateRequest) Validate

Validate returns an error if struct properties are missing/invalid

type PatchZoneRequest

type PatchZoneRequest struct {
	Description string `json:"description,omitempty"`
}

PatchZoneRequest represents a SafeDNS zone patch request

func (*PatchZoneRequest) Validate

Validate returns an error if struct properties are missing/invalid

type Record

type Record struct {
	ID         int                 `json:"id"`
	TemplateID int                 `json:"template_id"`
	Name       string              `json:"name"`
	Type       RecordType          `json:"type"`
	Content    string              `json:"content"`
	UpdatedAt  connection.DateTime `json:"updated_at"`
	TTL        RecordTTL           `json:"ttl"`
	Priority   int                 `json:"priority"`
}

Record represents a SafeDNS record

type RecordTTL

type RecordTTL int

RecordTTL represents the record TTL time in seconds

func (RecordTTL) Duration

func (r RecordTTL) Duration() time.Duration

Duration returns the record TTL duration (seconds)

func (RecordTTL) String

func (r RecordTTL) String() string

func (RecordTTL) Time

func (r RecordTTL) Time() time.Time

Time returns the record TTL time

type RecordType

type RecordType string
const (
	RecordTypeA     RecordType = "A"
	RecordTypeAAAA  RecordType = "AAAA"
	RecordTypeCAA   RecordType = "CAA"
	RecordTypeCNAME RecordType = "CNAME"
	RecordTypeMX    RecordType = "MX"
	RecordTypeSPF   RecordType = "SPF"
	RecordTypeSRV   RecordType = "SRV"
	RecordTypeTXT   RecordType = "TXT"
	RecordTypeNS    RecordType = "NS"
	RecordTypeSOA   RecordType = "SOA"
	RecordTypeAXFR  RecordType = "AXFR"
)

func (RecordType) String

func (s RecordType) String() string

type SafeDNSService

type SafeDNSService interface {
	GetZones(parameters connection.APIRequestParameters) ([]Zone, error)
	GetZonesPaginated(parameters connection.APIRequestParameters) (*connection.Paginated[Zone], error)
	GetZone(zoneName string) (Zone, error)
	CreateZone(req CreateZoneRequest) error
	PatchZone(zoneName string, req PatchZoneRequest) error
	DeleteZone(zoneName string) error
	GetZoneRecords(zoneName string, parameters connection.APIRequestParameters) ([]Record, error)
	GetZoneRecordsPaginated(zoneName string, parameters connection.APIRequestParameters) (*connection.Paginated[Record], error)
	GetZoneRecord(zoneName string, recordID int) (Record, error)
	CreateZoneRecord(zoneName string, req CreateRecordRequest) (int, error)
	UpdateZoneRecord(zoneName string, record Record) (int, error)
	PatchZoneRecord(zoneName string, recordID int, patch PatchRecordRequest) (int, error)
	DeleteZoneRecord(zoneName string, recordID int) error
	GetZoneNotes(zoneName string, parameters connection.APIRequestParameters) ([]Note, error)
	GetZoneNotesPaginated(zoneName string, parameters connection.APIRequestParameters) (*connection.Paginated[Note], error)
	GetZoneNote(zoneName string, noteID int) (Note, error)
	CreateZoneNote(zoneName string, req CreateNoteRequest) (int, error)
	GetTemplates(parameters connection.APIRequestParameters) ([]Template, error)
	GetTemplatesPaginated(parameters connection.APIRequestParameters) (*connection.Paginated[Template], error)
	GetTemplate(templateID int) (Template, error)
	CreateTemplate(req CreateTemplateRequest) (int, error)
	PatchTemplate(templateID int, patch PatchTemplateRequest) (int, error)
	DeleteTemplate(templateID int) error
	GetTemplateRecords(templateID int, parameters connection.APIRequestParameters) ([]Record, error)
	GetTemplateRecordsPaginated(templateID int, parameters connection.APIRequestParameters) (*connection.Paginated[Record], error)
	GetTemplateRecord(templateID int, recordID int) (Record, error)
	CreateTemplateRecord(templateID int, req CreateRecordRequest) (int, error)
	PatchTemplateRecord(templateID int, recordID int, patch PatchRecordRequest) (int, error)
	DeleteTemplateRecord(templateID int, recordID int) error
	GetSettings() (Settings, error)
}

SafeDNSService is an interface for managing SafeDNS

type Service

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

Service implements SafeDNSService for managing SafeDNS via the UKFast API

func NewService

func NewService(connection connection.Connection) *Service

NewService returns a new instance of SafeDNSService

func (*Service) CreateTemplate

func (s *Service) CreateTemplate(req CreateTemplateRequest) (int, error)

CreateTemplate creates a new SafeDNS template

func (*Service) CreateTemplateRecord

func (s *Service) CreateTemplateRecord(templateID int, req CreateRecordRequest) (int, error)

CreateTemplateRecord creates a new SafeDNS zone record

func (*Service) CreateZone

func (s *Service) CreateZone(req CreateZoneRequest) error

CreateZone creates a new SafeDNS zone

func (*Service) CreateZoneNote

func (s *Service) CreateZoneNote(zoneName string, req CreateNoteRequest) (int, error)

CreateZoneNote creates a new SafeDNS zone note

func (*Service) CreateZoneRecord

func (s *Service) CreateZoneRecord(zoneName string, req CreateRecordRequest) (int, error)

CreateZoneRecord creates a new SafeDNS zone record

func (*Service) DeleteTemplate

func (s *Service) DeleteTemplate(templateID int) error

DeleteTemplate removes a SafeDNS template

func (*Service) DeleteTemplateRecord

func (s *Service) DeleteTemplateRecord(templateID int, recordID int) error

DeleteTemplateRecord removes a SafeDNS template record

func (*Service) DeleteZone

func (s *Service) DeleteZone(zoneName string) error

DeleteZone removes a SafeDNS zone

func (*Service) DeleteZoneRecord

func (s *Service) DeleteZoneRecord(zoneName string, recordID int) error

DeleteZoneRecord removes a SafeDNS zone record

func (*Service) GetSettings

func (s *Service) GetSettings() (Settings, error)

GetSettings retrieves account settings

func (*Service) GetTemplate

func (s *Service) GetTemplate(templateID int) (Template, error)

GetTemplate retrieves a single template by ID

func (*Service) GetTemplateRecord

func (s *Service) GetTemplateRecord(templateID int, recordID int) (Record, error)

GetTemplateRecord retrieves a single zone record by ID

func (*Service) GetTemplateRecords

func (s *Service) GetTemplateRecords(templateID int, parameters connection.APIRequestParameters) ([]Record, error)

GetTemplateRecords retrieves a list of records

func (*Service) GetTemplateRecordsPaginated

func (s *Service) GetTemplateRecordsPaginated(templateID int, parameters connection.APIRequestParameters) (*connection.Paginated[Record], error)

GetTemplateRecordsPaginated retrieves a paginated list of templates

func (*Service) GetTemplates

func (s *Service) GetTemplates(parameters connection.APIRequestParameters) ([]Template, error)

GetTemplates retrieves a list of templates

func (*Service) GetTemplatesPaginated

func (s *Service) GetTemplatesPaginated(parameters connection.APIRequestParameters) (*connection.Paginated[Template], error)

GetTemplatesPaginated retrieves a paginated list of templates

func (*Service) GetZone

func (s *Service) GetZone(zoneName string) (Zone, error)

GetZone retrieves a single zone by name

func (*Service) GetZoneNote

func (s *Service) GetZoneNote(zoneName string, noteID int) (Note, error)

GetZoneNote retrieves a single zone note by ID

func (*Service) GetZoneNotes

func (s *Service) GetZoneNotes(zoneName string, parameters connection.APIRequestParameters) ([]Note, error)

GetZoneNotes retrieves a list of notes

func (*Service) GetZoneNotesPaginated

func (s *Service) GetZoneNotesPaginated(zoneName string, parameters connection.APIRequestParameters) (*connection.Paginated[Note], error)

GetZoneNotesPaginated retrieves a paginated list of zones

func (*Service) GetZoneRecord

func (s *Service) GetZoneRecord(zoneName string, recordID int) (Record, error)

GetZoneRecord retrieves a single zone record by ID

func (*Service) GetZoneRecords

func (s *Service) GetZoneRecords(zoneName string, parameters connection.APIRequestParameters) ([]Record, error)

GetZoneRecords retrieves a list of records

func (*Service) GetZoneRecordsPaginated

func (s *Service) GetZoneRecordsPaginated(zoneName string, parameters connection.APIRequestParameters) (*connection.Paginated[Record], error)

GetZoneRecordsPaginated retrieves a paginated list of zones

func (*Service) GetZones

func (s *Service) GetZones(parameters connection.APIRequestParameters) ([]Zone, error)

GetZones retrieves a list of zones

func (*Service) GetZonesPaginated

func (s *Service) GetZonesPaginated(parameters connection.APIRequestParameters) (*connection.Paginated[Zone], error)

GetZonesPaginated retrieves a paginated list of zones

func (*Service) PatchTemplate

func (s *Service) PatchTemplate(templateID int, patch PatchTemplateRequest) (int, error)

PatchTemplate patches a SafeDNS template

func (*Service) PatchTemplateRecord

func (s *Service) PatchTemplateRecord(templateID int, recordID int, patch PatchRecordRequest) (int, error)

PatchTemplateRecord patches a SafeDNS template record

func (*Service) PatchZone

func (s *Service) PatchZone(zoneName string, req PatchZoneRequest) error

PatchZone patches a SafeDNS zone

func (*Service) PatchZoneRecord

func (s *Service) PatchZoneRecord(zoneName string, recordID int, patch PatchRecordRequest) (int, error)

PatchZoneRecord patches a SafeDNS zone record

func (*Service) UpdateZoneRecord

func (s *Service) UpdateZoneRecord(zoneName string, record Record) (int, error)

UpdateZoneRecord updates a SafeDNS zone record

type Settings

type Settings struct {
	ID                  int                `json:"id"`
	Email               string             `json:"email"`
	Nameservers         []Nameserver       `json:"nameservers"`
	CustomSOAAllowed    bool               `json:"custom_soa_allowed"`
	CustomBaseNSAllowed bool               `json:"custom_base_ns_allowed"`
	CustomAXFR          CustomAXFRSettings `json:"custom_axfr"`
	DelegationAllowed   bool               `json:"delegation_allowed"`
	Product             string             `json:"product"`
}

Settings represents SafeDNS account settings/configuration

type Template

type Template struct {
	ID        int             `json:"id"`
	Name      string          `json:"name"`
	Default   bool            `json:"default"`
	CreatedAt connection.Date `json:"created_at"`
}

Template represents a SafeDNS template

type TemplateNotFoundError

type TemplateNotFoundError struct {
	TemplateID int
}

TemplateNotFoundError indicates a template was not found within SafeDNS

func (*TemplateNotFoundError) Error

func (e *TemplateNotFoundError) Error() string

type TemplateRecordNotFoundError

type TemplateRecordNotFoundError struct {
	TemplateID int
	RecordID   int
}

TemplateRecordNotFoundError indicates a record was not found within SafeDNS

func (*TemplateRecordNotFoundError) Error

type Zone

type Zone struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

Zone represents a SafeDNS zone

type ZoneNotFoundError

type ZoneNotFoundError struct {
	ZoneName string
}

ZoneNotFoundError indicates a zone was not found within SafeDNS

func (*ZoneNotFoundError) Error

func (e *ZoneNotFoundError) Error() string

type ZoneNoteNotFoundError

type ZoneNoteNotFoundError struct {
	ZoneName string
	NoteID   int
}

ZoneNoteNotFoundError indicates a zone note was not found within SafeDNS

func (*ZoneNoteNotFoundError) Error

func (e *ZoneNoteNotFoundError) Error() string

type ZoneRecordNotFoundError

type ZoneRecordNotFoundError struct {
	ZoneName string
	RecordID int
}

ZoneRecordNotFoundError indicates a record was not found within SafeDNS

func (*ZoneRecordNotFoundError) Error

func (e *ZoneRecordNotFoundError) Error() string

Jump to

Keyboard shortcuts

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