Update dns_manager.go

Slightly changed API
This commit is contained in:
2025-01-14 21:58:20 +03:00
parent 85e42ef70c
commit a31877a751

View File

@ -1,28 +1,28 @@
package dns_manager package dns_manager
type RecordType int type RecordType string
const ( const (
None RecordType = iota None RecordType = "None essential"
A A RecordType = "A"
AAAA AAAA RecordType = "AAAA"
MX MX RecordType = "MX"
CNAME CNAME RecordType = "CNAME"
TXT TXT RecordType = "TXT"
) )
type Record struct { type Record struct {
Type RecordType Type RecordType `json:"type,omitempty"`
Host string Name string `json:"name,omitempty"`
Content string Content string `json:"content,omitempty"`
TTL uint16 TTL uint `json:"ttl,omitempty"`
} }
type Actions interface { type Actions interface {
AddRecord(Record) Response AddRecord(*Record) (error, *Response)
DeleteRecord() Response DeleteRecord(*Record) (error, *Response)
UpdateRecord(Record) Response UpdateRecord(*Record) (error, *Response)
ReadRecords() (error, *[]Record) GetRecords() (error, []*Record)
} }
type manager interface { type manager interface {
@ -30,8 +30,17 @@ type manager interface {
} }
type Response struct { type Response struct {
error string Error string `json:"error"`
message string Message string `json:"message"`
}
func (rt RecordType) Check() bool {
switch rt {
case None, A, AAAA, MX, CNAME, TXT:
return true
default:
return false
}
} }
func New(manager_config manager) Actions { func New(manager_config manager) Actions {