dnssdk

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 14 Imported by: 2

README

EdgeCenter DNS API Golang SDK

The purpose of this project is to cover EdgeCenter DNS API methods related with EdgeCenter Terraform plugin (https://github.com/Edge-Center/terraform-provider-edgecenter).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BearerAuth

func BearerAuth(token string) func() authHeader

BearerAuth by header

func ContentFromValue

func ContentFromValue(recordType, content string) []interface{}

ContentFromValue convertor from flat value to valid for api

func PermanentAPIKeyAuth

func PermanentAPIKeyAuth(token string) func() authHeader

PermanentAPIKeyAuth by header

Types

type APIError

type APIError struct {
	StatusCode int    `json:"-"`
	Message    string `json:"error,omitempty"`
}

APIError customization for API calls

func (APIError) Error

func (a APIError) Error() string

Error implementation

type AddZone

type AddZone struct {
	Name string `json:"name"`
}

AddZone dto to create new zone

type AddZoneOpt

type AddZoneOpt func(*RRSet)

AddZoneOpt setup RRSet

func WithFilters

func WithFilters(filters ...RecordFilter) AddZoneOpt

WithFilters add filters to RRSet

type Client

type Client struct {
	HTTPClient *http.Client
	UserAgent  string
	BaseURL    *url.URL

	Debug bool
	// contains filtered or unexported fields
}

Client for DNS API.

func NewClient

func NewClient(authorizer func() authHeader, opts ...func(*Client)) *Client

NewClient constructor of Client.

func (*Client) AddZoneRRSet

func (c *Client) AddZoneRRSet(ctx context.Context,
	zone, recordName, recordType string,
	values []ResourceRecord, ttl int, opts ...AddZoneOpt) error

AddZoneRRSet create or extend resource record.

func (*Client) CreateRRSet

func (c *Client) CreateRRSet(ctx context.Context, zone, name, recordType string, record RRSet) error

CreateRRSet https://apidocs.edgecenter.ru/dns#tag/rrsets/operation/CreateRRSet

func (*Client) CreateZone

func (c *Client) CreateZone(ctx context.Context, name string) (uint64, error)

CreateZone add new zone. https://apidocs.edgecenter.ru/dns#tag/zones/operation/CreateZone

func (*Client) DeleteRRSet

func (c *Client) DeleteRRSet(ctx context.Context, zone, name, recordType string) error

DeleteRRSet removes RRSet type records. https://apidocs.edgecenter.ru/dns#tag/rrsets/operation/DeleteRRSet

func (*Client) DeleteRRSetRecord

func (c *Client) DeleteRRSetRecord(ctx context.Context, zone, name, recordType string, contents ...string) error

DeleteRRSetRecord removes RRSet record.

func (*Client) DeleteZone

func (c *Client) DeleteZone(ctx context.Context, name string) error

DeleteZone gets zone information. https://apidocs.edgecenter.ru/dns#tag/zones/operation/DeleteZone

func (*Client) RRSet

func (c *Client) RRSet(ctx context.Context, zone, name, recordType string) (RRSet, error)

RRSet gets RRSet item. https://apidocs.edgecenter.ru/dns#tag/rrsets/operation/RRSet

func (*Client) UpdateRRSet

func (c *Client) UpdateRRSet(ctx context.Context, zone, name, recordType string, record RRSet) error

UpdateRRSet https://apidocs.edgecenter.ru/dns#tag/rrsets/operation/UpdateRRSet

func (*Client) Zone

func (c *Client) Zone(ctx context.Context, name string) (Zone, error)

Zone gets zone information. https://apidocs.edgecenter.ru/dns#tag/zones/operation/Zone

func (*Client) Zones

func (c *Client) Zones(ctx context.Context, filters ...func(zone *ZonesFilter)) ([]Zone, error)

Zones gets all zones. https://apidocs.edgecenter.ru/dns#tag/zones/operation/Zones

func (*Client) ZonesWithRecords

func (c *Client) ZonesWithRecords(ctx context.Context, filters ...func(zone *ZonesFilter)) ([]Zone, error)

ZonesWithRecords gets all zones with records information.

type CreateResponse

type CreateResponse struct {
	ID    uint64 `json:"id,omitempty"`
	Error string `json:"error,omitempty"`
}

CreateResponse dto to create new zone

type FailoverMeta added in v0.1.1

type FailoverMeta struct {
	Protocol       string `json:"protocol"`
	Port           int    `json:"port"`
	Frequency      int    `json:"frequency"`
	Timeout        int    `json:"timeout"`
	Method         string `json:"method,omitempty"`
	Url            string `json:"url,omitempty"`
	Tls            bool   `json:"tls,omitempty"`
	Regexp         string `json:"regexp,omitempty"`
	HTTPStatusCode int    `json:"http_status_code,omitempty"`
	Host           string `json:"host,omitempty"`
	Verify         bool   `json:"verify,omitempty"`
}

FailoverMeta

type ListZones

type ListZones struct {
	Zones []Zone `json:"zones"`
}

ListZones dto to read list of zones from API

type Meta added in v0.1.1

type Meta struct {
	Failover *FailoverMeta `json:"failover,omitempty"`
}

Meta dto to read meta

type RRSet

type RRSet struct {
	TTL     int              `json:"ttl"`
	Records []ResourceRecord `json:"resource_records"`
	Filters []RecordFilter   `json:"filters"`
	Meta    *Meta            `json:"meta,omitempty"`
}

RRSet dto as part of zone info from API

func (*RRSet) AddFilter

func (rr *RRSet) AddFilter(filters ...RecordFilter) *RRSet

AddFilter to RRSet

type RecordFilter

type RecordFilter struct {
	Limit  uint   `json:"limit"`
	Type   string `json:"type"`
	Strict bool   `json:"strict"`
}

RecordFilter describe Filters in RRSet

func NewDefaultFilter

func NewDefaultFilter(limit uint, strict bool) RecordFilter

NewDefaultFilter for RRSet

func NewFirstNFilter

func NewFirstNFilter(limit uint, strict bool) RecordFilter

NewFirstNFilter for RRSet

func NewGeoDNSFilter

func NewGeoDNSFilter(limit uint, strict bool) RecordFilter

NewGeoDNSFilter for RRSet

func NewGeoDistanceFilter

func NewGeoDistanceFilter(limit uint, strict bool) RecordFilter

NewGeoDistanceFilter for RRSet

func NewIsHealthyFilter added in v0.1.1

func NewIsHealthyFilter(limit uint, strict bool) RecordFilter

NewIsHealthyFilter for RRSet

type RecordType

type RecordType interface {
	ToContent() []interface{}
}

RecordType contract

func ToRecordType

func ToRecordType(rType, content string) RecordType

ToRecordType builder

type RecordTypeAny

type RecordTypeAny string

RecordTypeAny as type of record

func (RecordTypeAny) ToContent

func (any RecordTypeAny) ToContent() []interface{}

ToContent convertor

type RecordTypeCAA

type RecordTypeCAA string

RecordTypeCAA as type of record

func (RecordTypeCAA) ToContent

func (caa RecordTypeCAA) ToContent() []interface{}

ToContent convertor

type RecordTypeMX

type RecordTypeMX string

RecordTypeMX as type of record

func (RecordTypeMX) ToContent

func (mx RecordTypeMX) ToContent() []interface{}

ToContent convertor

type RecordTypeSRV

type RecordTypeSRV string

RecordTypeSRV as type of record

func (RecordTypeSRV) ToContent

func (srv RecordTypeSRV) ToContent() []interface{}

ToContent convertor

type ResourceMeta

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

ResourceMeta for ResourceRecord

func NewResourceMetaAsn

func NewResourceMetaAsn(asn ...uint64) ResourceMeta

NewResourceMetaAsn for asn meta

func NewResourceMetaContinents

func NewResourceMetaContinents(continents ...string) ResourceMeta

NewResourceMetaContinents for continents meta

func NewResourceMetaCountries

func NewResourceMetaCountries(countries ...string) ResourceMeta

NewResourceMetaCountries for Countries meta

func NewResourceMetaDefault

func NewResourceMetaDefault() ResourceMeta

NewResourceMetaDefault for default meta

func NewResourceMetaIP

func NewResourceMetaIP(ips ...string) ResourceMeta

NewResourceMetaIP for ip meta

func NewResourceMetaLatLong

func NewResourceMetaLatLong(latlong string) ResourceMeta

NewResourceMetaLatLong for lat long meta

func NewResourceMetaNotes

func NewResourceMetaNotes(notes ...string) ResourceMeta

NewResourceMetaNotes for notes meta

func (ResourceMeta) Valid

func (rm ResourceMeta) Valid() error

Valid error

type ResourceRecord

type ResourceRecord struct {
	Content []interface{}          `json:"content"`
	Meta    map[string]interface{} `json:"meta"`
	Enabled bool                   `json:"enabled"`
}

ResourceRecord dto describe records in RRSet

func (*ResourceRecord) AddMeta

func (r *ResourceRecord) AddMeta(meta ResourceMeta) *ResourceRecord

AddMeta to ResourceRecord

func (ResourceRecord) ContentToString

func (r ResourceRecord) ContentToString() string

ContentToString as short value

func (*ResourceRecord) SetContent

func (r *ResourceRecord) SetContent(recordType, val string) *ResourceRecord

SetContent to ResourceRecord

type Zone

type Zone struct {
	Name    string       `json:"name"`
	Records []ZoneRecord `json:"records"`
}

Zone dto to read info from API

type ZoneRecord

type ZoneRecord struct {
	Name         string   `json:"name"`
	Type         string   `json:"type"`
	TTL          uint     `json:"ttl"`
	ShortAnswers []string `json:"short_answers"`
}

ZoneRecord dto describe records in Zone

type ZonesFilter

type ZonesFilter struct {
	Names []string
}

ZonesFilter find zones

Jump to

Keyboard shortcuts

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