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

dns1cloud

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2019 License: MIT Imports: 12 Imported by: 0

README

1cloud DNS API

This unofficial implementation of API of 1cloud DNS hosting

Example

cli := dns1cloud.New("aaaaaaaaaaaaaaa")
record, err := cli.AddRecord(
	context.Background(),
	1234, // id of domain
	dns1cloud.Record{
		TypeRecord: dns1cloud.RecordTypeCNAME,
		HostName: "domain.com",
		MnemonicName: "www",
		TTL: 600,
	},
)

Documentation

Overview

Package dns1cloud implements methods for API of 1Cloud's DNS hosting

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DNS1Cloud

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

DNS1Cloud represents a client for API of 1Cloud's DNS hosting

func New

func New(apiKey string, opts ...OptFunc) *DNS1Cloud

New creates and return new DNS1Cloud

func (*DNS1Cloud) AddRecord

func (c *DNS1Cloud) AddRecord(
	ctx context.Context,
	domainID uint64,
	record Record,
) (Record, error)

AddRecord adds record to domain

func (*DNS1Cloud) DeleteRecord

func (c *DNS1Cloud) DeleteRecord(
	ctx context.Context,
	domainID uint64,
	recordID uint64,
) error

DeleteRecord deletes record from domain

func (*DNS1Cloud) GetDomain

func (c *DNS1Cloud) GetDomain(ctx context.Context, domainID uint64) (Domain, error)

GetDomain returns domain by id

func (*DNS1Cloud) GetRecord

func (c *DNS1Cloud) GetRecord(ctx context.Context, recordID uint64) (Record, error)

GetRecord returns record by id

func (*DNS1Cloud) List

func (c *DNS1Cloud) List(ctx context.Context) ([]Domain, error)

List returns list of domains

func (*DNS1Cloud) UpdateRecord added in v0.2.0

func (c *DNS1Cloud) UpdateRecord(
	ctx context.Context,
	domainID uint64,
	record Record,
) (Record, error)

UpdateRecord updates record

type DateTime

type DateTime struct {
	time.Time
}

DateTime is a wrapper for unmarshaling time from JSON

func (*DateTime) UnmarshalJSON

func (d *DateTime) UnmarshalJSON(b []byte) error

UnmarshalJSON sets time from JSON bytes

type Domain

type Domain struct {
	ID            uint64   `json:"ID"`
	Name          string   `json:"Name"`
	TechName      string   `json:"TechName"`
	State         State    `json:"State"`
	DateCreate    DateTime `json:"DateCreate"`
	IsDelegate    bool     `json:"IsDelegate"`
	LinkedRecords []Record `json:"LinkedRecords"`
}

Domain represents domain

type OptFunc

type OptFunc func(*DNS1Cloud)

OptFunc is type for option function

func WithApiHost

func WithApiHost(apiHost string) OptFunc

WithApiHost is option function for setting API host

func WithHTTPClient

func WithHTTPClient(cli *http.Client) OptFunc

WithHTTPClient is option function for setting HTTP client

type Record

type Record struct {
	ID                   uint64     `json:"ID"`
	TypeRecord           RecordType `json:"TypeRecord"`
	IP                   string     `json:"IP"`
	HostName             string     `json:"HostName"`
	Priority             string     `json:"Priority"`
	Text                 string     `json:"Text"`
	MnemonicName         string     `json:"MnemonicName"`
	ExtHostName          string     `json:"ExtHostName"`
	Weight               string     `json:"Weight"`
	Port                 string     `json:"Port"`
	Target               string     `json:"Target"`
	Proto                string     `json:"Proto"`
	Service              string     `json:"Service"`
	TTL                  uint32     `json:"TTL"`
	State                State      `json:"State"`
	DateCreate           DateTime   `json:"DateCreate"`
	CanonicalDescription string     `json:"CanonicalDescription"`
}

Domain represents record of domain

type RecordType

type RecordType uint8

RecordType is a type of record

const (
	// RecordTypeA is a type "A"
	RecordTypeA RecordType = iota
	// RecordTypeAAAA is a type "AAAA"
	RecordTypeAAAA
	// RecordTypeMX is a type "MX"
	RecordTypeMX
	// RecordTypeCNAME is a type "CNAME"
	RecordTypeCNAME
	// RecordTypeTXT is a type "TXT"
	RecordTypeTXT
	// RecordTypeNS is a type "NS"
	RecordTypeNS
	// RecordTypeSRV is a type "SRV"
	RecordTypeSRV
)

func (*RecordType) UnmarshalJSON

func (r *RecordType) UnmarshalJSON(b []byte) error

UnmarshalJSON sets record type from JSON bytes

type State

type State uint8

State is a state of the domain or record

const (
	StateNew State = iota
	StateActive
)

func (*State) UnmarshalJSON

func (s *State) UnmarshalJSON(b []byte) error

UnmarshalJSON sets state of domain or record from JSON bytes

Jump to

Keyboard shortcuts

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