zones

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: Apache-2.0 Imports: 7 Imported by: 11

Documentation

Overview

This package contains a specialized client for interacting with PowerDNS' "Zones" API.

More information

Official API documentation: https://doc.powerdns.com/authoritative/http-api/zone.html

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// ListZones lists known zones for a given serverID
	ListZones(ctx context.Context, serverID string) ([]Zone, error)

	// ListZone list known zone for a given serverID and zoneID
	ListZone(ctx context.Context, serverID string, zoneID string) ([]Zone, error)

	// CreateZone creates a new zone for a given server.
	CreateZone(ctx context.Context, serverID string, zone Zone) (*Zone, error)

	// GetZone returns an existing zone by ID. If not found, the first returned value
	// will be nil, and the error return value will be an instance of "pdnshttp.ErrNotFound".
	GetZone(ctx context.Context, serverID string, zoneID string, opts ...GetZoneOption) (*Zone, error)

	// DeleteZone deletes a zone. No shit.
	DeleteZone(ctx context.Context, serverID string, zoneID string) error

	// AddRecordSetToZone will add a new set of records to a zone. Existing record sets for
	// the exact name/type combination will be replaced.
	//
	// Deprecated: Superceded by AddRecordSetsToZone
	AddRecordSetToZone(ctx context.Context, serverID string, zoneID string, set ResourceRecordSet) error

	// AddRecordSetsToZone will add new sets of records to a zone. Existing record sets for
	// the exact name/type combination will be replaced.
	AddRecordSetsToZone(ctx context.Context, serverID string, zoneID string, sets []ResourceRecordSet) error

	// RemoveRecordSetFromZone removes a record set from a zone. The record set is matched
	// by name and type.
	//
	// Deprecated: Superceded by RemoveRecordSetsFromZone
	RemoveRecordSetFromZone(ctx context.Context, serverID string, zoneID string, name string, recordType string) error

	// RemoveRecordSetsFromZone removes record sets from a zone. The record sets are matched
	// by name and type.
	RemoveRecordSetsFromZone(ctx context.Context, serverID string, zoneID string, sets []ResourceRecordSet) error

	// RetrieveFromMaster retrieves a slave zone from its master
	RetrieveFromMaster(ctx context.Context, serverID string, zoneID string) error

	// NotifySlaves sends a DNS NOTIFY to all slaves
	NotifySlaves(ctx context.Context, serverID string, zoneID string) error

	// ExportZone exports the entire zone in AXFR format
	ExportZone(ctx context.Context, serverID string, zoneID string) ([]byte, error)

	// VerifyZone verifies a zone's configuration
	VerifyZone(ctx context.Context, serverID string, zoneID string) error

	// RectifyZone rectifies the zone data
	RectifyZone(ctx context.Context, serverID string, zoneID string) error
}

Client defines the interface for Zone operations.

func New

func New(hc *pdnshttp.Client) Client

type Comment

type Comment struct {
	Content    string `json:"content"`
	Account    string `json:"account"`
	ModifiedAt int    `json:"modified_at"`
}

type GetZoneOption added in v0.6.1

type GetZoneOption interface {
	ApplyToGetZoneRequest(req *http.Request) error
}

func WithResourceRecordSetFilter added in v0.6.1

func WithResourceRecordSetFilter(name, recordType string) GetZoneOption

func WithoutResourceRecordSets added in v0.6.1

func WithoutResourceRecordSets() GetZoneOption

type Record

type Record struct {
	Content  string `json:"content"`
	Disabled bool   `json:"disabled"`
	SetPTR   bool   `json:"set-ptr,omitempty"`
}

type RecordSetChangeType

type RecordSetChangeType int
const (
	ChangeTypeDelete RecordSetChangeType = iota
	ChangeTypeReplace
)

func (RecordSetChangeType) MarshalJSON

func (k RecordSetChangeType) MarshalJSON() ([]byte, error)

func (*RecordSetChangeType) UnmarshalJSON

func (k *RecordSetChangeType) UnmarshalJSON(input []byte) error

type ResourceRecordSet

type ResourceRecordSet struct {
	Name       string              `json:"name"`
	Type       string              `json:"type"`
	TTL        int                 `json:"ttl"`
	ChangeType RecordSetChangeType `json:"changetype,omitempty"`
	Records    []Record            `json:"records"`
	Comments   []Comment           `json:"comments"`
}

type Zone

type Zone struct {
	ID                 string              `json:"id,omitempty"`
	Name               string              `json:"name"`
	Type               ZoneType            `json:"type"`
	URL                string              `json:"url,omitempty"`
	Kind               ZoneKind            `json:"kind,omitempty"`
	ResourceRecordSets []ResourceRecordSet `json:"rrsets,omitempty"`
	Serial             int                 `json:"serial,omitempty"`
	NotifiedSerial     int                 `json:"notified_serial,omitempty"`
	Masters            []string            `json:"masters,omitempty"`
	DNSSec             bool                `json:"dnssec,omitempty"`
	NSec3Param         string              `json:"nsec3param,omitempty"`
	NSec3Narrow        bool                `json:"nsec3narrow,omitempty"`
	Presigned          bool                `json:"presigned,omitempty"`
	SOAEdit            string              `json:"soa_edit,omitempty"`
	SOAEditAPI         string              `json:"soa_edit_api,omitempty"`
	APIRectify         bool                `json:"api_rectify,omitempty"`
	Zone               string              `json:"zone,omitempty"`
	Account            string              `json:"account,omitempty"`
	Nameservers        ZoneNameservers     `json:"nameservers"`
	TSIGMasterKeyIDs   []string            `json:"tsig_master_key_ids,omitempty"`
	TSIGSlaveKeyIDs    []string            `json:"tsig_slave_key_ids,omitempty"`
}

func (*Zone) GetRecordSet

func (z *Zone) GetRecordSet(name, recordType string) *ResourceRecordSet

type ZoneKind

type ZoneKind int
const (
	ZoneKindNative ZoneKind = iota
	ZoneKindMaster
	ZoneKindSlave
	ZoneKindProducer
	ZoneKindConsumer
)

func (ZoneKind) MarshalJSON

func (k ZoneKind) MarshalJSON() ([]byte, error)

func (*ZoneKind) UnmarshalJSON

func (k *ZoneKind) UnmarshalJSON(input []byte) error

type ZoneNameservers added in v0.3.0

type ZoneNameservers []string

ZoneNameservers is a special list type to represent the nameservers of a zone. When nil, this type will still serialize to an empty JSON list. See https://github.com/mittwald/go-powerdns/issues/4 for more information

func (ZoneNameservers) MarshalJSON added in v0.3.0

func (z ZoneNameservers) MarshalJSON() ([]byte, error)

MarshalJSON implements the `json.Marshaler` interface

type ZoneType

type ZoneType int
const (
	ZoneTypeZone ZoneType = iota
)

func (ZoneType) MarshalJSON

func (k ZoneType) MarshalJSON() ([]byte, error)

func (*ZoneType) UnmarshalJSON

func (k *ZoneType) UnmarshalJSON(input []byte) error

Jump to

Keyboard shortcuts

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