From 1d263c4dd6c3574b8dbf86ff2a06730b6861a666 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Tue, 2 Jun 2020 06:53:41 -0400 Subject: [PATCH] Vendor github.com/mittwald/go-powerdns --- go.mod | 1 + go.sum | 7 +++ .../mittwald/go-powerdns/apis/zones/client.go | 13 +++++ .../mittwald/go-powerdns/apis/zones/doc.go | 6 +++ .../go-powerdns/apis/zones/interface.go | 45 ++++++++++++++++ .../mittwald/go-powerdns/apis/zones/types.go | 22 ++++++++ .../apis/zones/types_rrsetchangetype.go | 35 +++++++++++++ .../go-powerdns/apis/zones/types_zone.go | 51 +++++++++++++++++++ .../go-powerdns/apis/zones/types_zonekind.go | 40 +++++++++++++++ .../go-powerdns/apis/zones/types_zonetype.go | 29 +++++++++++ .../apis/zones/zones_addrecordset.go | 21 ++++++++ .../go-powerdns/apis/zones/zones_create.go | 28 ++++++++++ .../go-powerdns/apis/zones/zones_delete.go | 13 +++++ .../go-powerdns/apis/zones/zones_export.go | 28 ++++++++++ .../go-powerdns/apis/zones/zones_get.go | 27 ++++++++++ .../go-powerdns/apis/zones/zones_list.go | 33 ++++++++++++ .../apis/zones/zones_notifyslaves.go | 13 +++++ .../go-powerdns/apis/zones/zones_rectify.go | 13 +++++ .../apis/zones/zones_removerecordset.go | 24 +++++++++ .../apis/zones/zones_retrievemaster.go | 13 +++++ .../go-powerdns/apis/zones/zones_verify.go | 13 +++++ 21 files changed, 475 insertions(+) create mode 100644 vendor/github.com/mittwald/go-powerdns/apis/zones/client.go create mode 100644 vendor/github.com/mittwald/go-powerdns/apis/zones/doc.go create mode 100644 vendor/github.com/mittwald/go-powerdns/apis/zones/interface.go create mode 100644 vendor/github.com/mittwald/go-powerdns/apis/zones/types.go create mode 100644 vendor/github.com/mittwald/go-powerdns/apis/zones/types_rrsetchangetype.go create mode 100644 vendor/github.com/mittwald/go-powerdns/apis/zones/types_zone.go create mode 100644 vendor/github.com/mittwald/go-powerdns/apis/zones/types_zonekind.go create mode 100644 vendor/github.com/mittwald/go-powerdns/apis/zones/types_zonetype.go create mode 100644 vendor/github.com/mittwald/go-powerdns/apis/zones/zones_addrecordset.go create mode 100644 vendor/github.com/mittwald/go-powerdns/apis/zones/zones_create.go create mode 100644 vendor/github.com/mittwald/go-powerdns/apis/zones/zones_delete.go create mode 100644 vendor/github.com/mittwald/go-powerdns/apis/zones/zones_export.go create mode 100644 vendor/github.com/mittwald/go-powerdns/apis/zones/zones_get.go create mode 100644 vendor/github.com/mittwald/go-powerdns/apis/zones/zones_list.go create mode 100644 vendor/github.com/mittwald/go-powerdns/apis/zones/zones_notifyslaves.go create mode 100644 vendor/github.com/mittwald/go-powerdns/apis/zones/zones_rectify.go create mode 100644 vendor/github.com/mittwald/go-powerdns/apis/zones/zones_removerecordset.go create mode 100644 vendor/github.com/mittwald/go-powerdns/apis/zones/zones_retrievemaster.go create mode 100644 vendor/github.com/mittwald/go-powerdns/apis/zones/zones_verify.go diff --git a/go.mod b/go.mod index 78a008912..9d90db916 100644 --- a/go.mod +++ b/go.mod @@ -35,6 +35,7 @@ require ( github.com/ovh/go-ovh v0.0.0-20181109152953-ba5adb4cf014 github.com/philhug/opensrs-go v0.0.0-20171126225031-9dfa7433020d github.com/pkg/errors v0.9.1 + github.com/psampaz/go-mod-outdated v0.6.0 // indirect github.com/renier/xmlrpc v0.0.0-20170708154548-ce4a1a486c03 // indirect github.com/robertkrimen/otto v0.0.0-20191219234010-c382bd3c16ff github.com/sergi/go-diff v1.1.0 // indirect diff --git a/go.sum b/go.sum index 9aef648be..be41a5db7 100644 --- a/go.sum +++ b/go.sum @@ -224,6 +224,9 @@ github.com/malexdev/utfutil v0.0.0-20180510171754-00c8d4a8e7a8 h1:A6SLdFpRzUUF5v github.com/malexdev/utfutil v0.0.0-20180510171754-00c8d4a8e7a8/go.mod h1:UtpLyb/EupVKXF/N0b4NRe1DNg+QYJsnsHQ038romhM= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/miekg/dns v1.1.29 h1:xHBEhR+t5RzcFJjBLJlax2daXOrTYtr9z4WdKEfWFzg= github.com/miekg/dns v1.1.29/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= @@ -245,6 +248,8 @@ github.com/namedotcom/go v0.0.0-20180403034216-08470befbe04/go.mod h1:5sN+Lt1CaY github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8= +github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA= github.com/ovh/go-ovh v0.0.0-20181109152953-ba5adb4cf014 h1:37VE5TYj2m/FLA9SNr4z0+A0JefvTmR60Zwf8XSEV7c= github.com/ovh/go-ovh v0.0.0-20181109152953-ba5adb4cf014/go.mod h1:joRatxRJaZBsY3JAOEMcoOp05CnZzsx4scTxi95DHyQ= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= @@ -259,6 +264,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/psampaz/go-mod-outdated v0.6.0 h1:DXS6rdsz4rpezbPsckQflqrYSEBvsF5GAmUWP+UvnQo= +github.com/psampaz/go-mod-outdated v0.6.0/go.mod h1:r78NYWd1z+F9Zdsfy70svgXOz363B08BWnTyFSgEESs= github.com/renier/xmlrpc v0.0.0-20170708154548-ce4a1a486c03 h1:Wdi9nwnhFNAlseAOekn6B5G/+GMtks9UKbvRU/CMM/o= github.com/renier/xmlrpc v0.0.0-20170708154548-ce4a1a486c03/go.mod h1:gRAiPF5C5Nd0eyyRdqIu9qTiFSoZzpTq727b5B8fkkU= github.com/robertkrimen/otto v0.0.0-20191219234010-c382bd3c16ff h1:+6NUiITWwE5q1KO6SAfUX918c+Tab0+tGAM/mtdlUyA= diff --git a/vendor/github.com/mittwald/go-powerdns/apis/zones/client.go b/vendor/github.com/mittwald/go-powerdns/apis/zones/client.go new file mode 100644 index 000000000..4150905d0 --- /dev/null +++ b/vendor/github.com/mittwald/go-powerdns/apis/zones/client.go @@ -0,0 +1,13 @@ +package zones + +import "github.com/mittwald/go-powerdns/pdnshttp" + +type client struct { + httpClient *pdnshttp.Client +} + +func New(hc *pdnshttp.Client) Client { + return &client{ + httpClient: hc, + } +} diff --git a/vendor/github.com/mittwald/go-powerdns/apis/zones/doc.go b/vendor/github.com/mittwald/go-powerdns/apis/zones/doc.go new file mode 100644 index 000000000..613439d1b --- /dev/null +++ b/vendor/github.com/mittwald/go-powerdns/apis/zones/doc.go @@ -0,0 +1,6 @@ +// 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 +package zones diff --git a/vendor/github.com/mittwald/go-powerdns/apis/zones/interface.go b/vendor/github.com/mittwald/go-powerdns/apis/zones/interface.go new file mode 100644 index 000000000..6fc7b3ace --- /dev/null +++ b/vendor/github.com/mittwald/go-powerdns/apis/zones/interface.go @@ -0,0 +1,45 @@ +package zones + +import "context" + +// Client defines the interface for Zone operations. +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) (*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. + AddRecordSetToZone(ctx context.Context, serverID string, zoneID string, set ResourceRecordSet) error + + // RemoveRecordSetFromZone removes a record set from a zone. The record set is matched + // by name and type. + RemoveRecordSetFromZone(ctx context.Context, serverID string, zoneID string, name string, recordType string) 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 +} diff --git a/vendor/github.com/mittwald/go-powerdns/apis/zones/types.go b/vendor/github.com/mittwald/go-powerdns/apis/zones/types.go new file mode 100644 index 000000000..a03b49285 --- /dev/null +++ b/vendor/github.com/mittwald/go-powerdns/apis/zones/types.go @@ -0,0 +1,22 @@ +package zones + +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 Record struct { + Content string `json:"content"` + Disabled bool `json:"disabled"` + SetPTR bool `json:"set-ptr,omitempty"` +} + +type Comment struct { + Content string `json:"content"` + Account string `json:"account"` + ModifiedAt int `json:"modified_at"` +} diff --git a/vendor/github.com/mittwald/go-powerdns/apis/zones/types_rrsetchangetype.go b/vendor/github.com/mittwald/go-powerdns/apis/zones/types_rrsetchangetype.go new file mode 100644 index 000000000..24bda402f --- /dev/null +++ b/vendor/github.com/mittwald/go-powerdns/apis/zones/types_rrsetchangetype.go @@ -0,0 +1,35 @@ +package zones + +import "fmt" + +type RecordSetChangeType int + +const ( + _ = iota + ChangeTypeDelete RecordSetChangeType = iota + ChangeTypeReplace +) + +func (k RecordSetChangeType) MarshalJSON() ([]byte, error) { + switch k { + case ChangeTypeDelete: + return []byte(`"DELETE"`), nil + case ChangeTypeReplace: + return []byte(`"REPLACE"`), nil + default: + return nil, fmt.Errorf("unsupported change type: %d", k) + } +} + +func (k *RecordSetChangeType) UnmarshalJSON(input []byte) error { + switch string(input) { + case `"DELETE"`: + *k = ChangeTypeDelete + case `"REPLACE"`: + *k = ChangeTypeReplace + default: + return fmt.Errorf("unsupported change type: %s", string(input)) + } + + return nil +} diff --git a/vendor/github.com/mittwald/go-powerdns/apis/zones/types_zone.go b/vendor/github.com/mittwald/go-powerdns/apis/zones/types_zone.go new file mode 100644 index 000000000..baeba2632 --- /dev/null +++ b/vendor/github.com/mittwald/go-powerdns/apis/zones/types_zone.go @@ -0,0 +1,51 @@ +package zones + +import "encoding/json" + +// 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 +type ZoneNameservers []string + +// MarshalJSON implements the `json.Marshaler` interface +func (z ZoneNameservers) MarshalJSON() ([]byte, error) { + if z == nil { + return []byte("[]"), nil + } + + return json.Marshal([]string(z)) +} + +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 (z *Zone) GetRecordSet(name, recordType string) *ResourceRecordSet { + for i := range z.ResourceRecordSets { + if z.ResourceRecordSets[i].Name == name && z.ResourceRecordSets[i].Type == recordType { + return &z.ResourceRecordSets[i] + } + } + + return nil +} diff --git a/vendor/github.com/mittwald/go-powerdns/apis/zones/types_zonekind.go b/vendor/github.com/mittwald/go-powerdns/apis/zones/types_zonekind.go new file mode 100644 index 000000000..c70a20825 --- /dev/null +++ b/vendor/github.com/mittwald/go-powerdns/apis/zones/types_zonekind.go @@ -0,0 +1,40 @@ +package zones + +import "fmt" + +type ZoneKind int + +const ( + _ = iota + ZoneKindNative ZoneKind = iota + ZoneKindMaster + ZoneKindSlave +) + +func (k ZoneKind) MarshalJSON() ([]byte, error) { + switch k { + case ZoneKindNative: + return []byte(`"Native"`), nil + case ZoneKindMaster: + return []byte(`"Master"`), nil + case ZoneKindSlave: + return []byte(`"Slave"`), nil + default: + return nil, fmt.Errorf("unsupported zone kind: %d", k) + } +} + +func (k *ZoneKind) UnmarshalJSON(input []byte) error { + switch string(input) { + case `"Native"`: + *k = ZoneKindNative + case `"Master"`: + *k = ZoneKindMaster + case `"Slave"`: + *k = ZoneKindSlave + default: + return fmt.Errorf("unsupported zone kind: %s", string(input)) + } + + return nil +} diff --git a/vendor/github.com/mittwald/go-powerdns/apis/zones/types_zonetype.go b/vendor/github.com/mittwald/go-powerdns/apis/zones/types_zonetype.go new file mode 100644 index 000000000..b57794cef --- /dev/null +++ b/vendor/github.com/mittwald/go-powerdns/apis/zones/types_zonetype.go @@ -0,0 +1,29 @@ +package zones + +import "fmt" + +type ZoneType int + +const ( + ZoneTypeZone ZoneType = iota +) + +func (k ZoneType) MarshalJSON() ([]byte, error) { + switch k { + case ZoneTypeZone: + return []byte(`"Zone"`), nil + default: + return nil, fmt.Errorf("unsupported zone type: %d", k) + } +} + +func (k *ZoneType) UnmarshalJSON(input []byte) error { + switch string(input) { + case `"Zone"`: + *k = ZoneTypeZone + default: + return fmt.Errorf("unsupported zone type: %s", string(input)) + } + + return nil +} diff --git a/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_addrecordset.go b/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_addrecordset.go new file mode 100644 index 000000000..ce85f21e7 --- /dev/null +++ b/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_addrecordset.go @@ -0,0 +1,21 @@ +package zones + +import ( + "context" + "fmt" + "github.com/mittwald/go-powerdns/pdnshttp" + "net/url" +) + +func (c *client) AddRecordSetToZone(ctx context.Context, serverID string, zoneID string, set ResourceRecordSet) error { + path := fmt.Sprintf("/api/v1/servers/%s/zones/%s", url.PathEscape(serverID), url.PathEscape(zoneID)) + + set.ChangeType = ChangeTypeReplace + patch := Zone{ + ResourceRecordSets: []ResourceRecordSet{ + set, + }, + } + + return c.httpClient.Patch(ctx, path, nil, pdnshttp.WithJSONRequestBody(&patch)) +} diff --git a/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_create.go b/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_create.go new file mode 100644 index 000000000..8b5b6d7c3 --- /dev/null +++ b/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_create.go @@ -0,0 +1,28 @@ +package zones + +import ( + "context" + "fmt" + "net/url" + + "github.com/mittwald/go-powerdns/pdnshttp" +) + +func (c *client) CreateZone(ctx context.Context, serverID string, zone Zone) (*Zone, error) { + created := Zone{} + path := fmt.Sprintf("/api/v1/servers/%s/zones", url.PathEscape(serverID)) + + zone.ID = "" + zone.Type = ZoneTypeZone + + if zone.Kind == 0 { + zone.Kind = ZoneKindNative + } + + err := c.httpClient.Post(ctx, path, &created, pdnshttp.WithJSONRequestBody(&zone)) + if err != nil { + return nil, err + } + + return &created, nil +} diff --git a/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_delete.go b/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_delete.go new file mode 100644 index 000000000..9519db2f9 --- /dev/null +++ b/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_delete.go @@ -0,0 +1,13 @@ +package zones + +import ( + "context" + "fmt" + "net/url" +) + +func (c *client) DeleteZone(ctx context.Context, serverID string, zoneID string) error { + path := fmt.Sprintf("/api/v1/servers/%s/zones/%s", url.PathEscape(serverID), url.PathEscape(zoneID)) + + return c.httpClient.Delete(ctx, path, nil) +} diff --git a/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_export.go b/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_export.go new file mode 100644 index 000000000..1db217927 --- /dev/null +++ b/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_export.go @@ -0,0 +1,28 @@ +package zones + +import ( + "bytes" + "context" + "fmt" + "github.com/mittwald/go-powerdns/pdnshttp" + "net/http" + "net/url" +) + +func (c *client) ExportZone(ctx context.Context, serverID, zoneID string) ([]byte, error) { + output := bytes.Buffer{} + path := fmt.Sprintf("/api/v1/servers/%s/zones/%s/export", url.PathEscape(serverID), url.PathEscape(zoneID)) + + err := c.httpClient.Get(ctx, path, &output) + if err != nil { + if e, ok := err.(pdnshttp.ErrUnexpectedStatus); ok { + if e.StatusCode == http.StatusUnprocessableEntity { + return nil, pdnshttp.ErrNotFound{} + } + } + + return nil, err + } + + return output.Bytes(), nil +} diff --git a/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_get.go b/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_get.go new file mode 100644 index 000000000..73918633b --- /dev/null +++ b/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_get.go @@ -0,0 +1,27 @@ +package zones + +import ( + "context" + "fmt" + "github.com/mittwald/go-powerdns/pdnshttp" + "net/http" + "net/url" +) + +func (c *client) GetZone(ctx context.Context, serverID, zoneID string) (*Zone, error) { + zone := Zone{} + path := fmt.Sprintf("/api/v1/servers/%s/zones/%s", url.PathEscape(serverID), url.PathEscape(zoneID)) + + err := c.httpClient.Get(ctx, path, &zone) + if err != nil { + if e, ok := err.(pdnshttp.ErrUnexpectedStatus); ok { + if e.StatusCode == http.StatusUnprocessableEntity { + return nil, pdnshttp.ErrNotFound{} + } + } + + return nil, err + } + + return &zone, nil +} diff --git a/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_list.go b/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_list.go new file mode 100644 index 000000000..5e733876b --- /dev/null +++ b/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_list.go @@ -0,0 +1,33 @@ +package zones + +import ( + "context" + "fmt" + "net/url" + + "github.com/mittwald/go-powerdns/pdnshttp" +) + +func (c *client) ListZones(ctx context.Context, serverID string) ([]Zone, error) { + zones := make([]Zone, 0) + path := fmt.Sprintf("/api/v1/servers/%s/zones", url.PathEscape(serverID)) + + err := c.httpClient.Get(ctx, path, &zones) + if err != nil { + return nil, err + } + + return zones, nil +} + +func (c *client) ListZone(ctx context.Context, serverID string, zoneID string) ([]Zone, error) { + zones := make([]Zone, 0) + path := fmt.Sprintf("/api/v1/servers/%s/zones", url.PathEscape(serverID)) + + err := c.httpClient.Get(ctx, path, &zones, pdnshttp.WithQueryValue("zone", zoneID)) + if err != nil { + return nil, err + } + + return zones, nil +} diff --git a/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_notifyslaves.go b/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_notifyslaves.go new file mode 100644 index 000000000..953471837 --- /dev/null +++ b/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_notifyslaves.go @@ -0,0 +1,13 @@ +package zones + +import ( + "context" + "fmt" + "net/url" +) + +func (c *client) NotifySlaves(ctx context.Context, serverID string, zoneID string) error { + path := fmt.Sprintf("/api/v1/servers/%s/zones/%s/notify", url.PathEscape(serverID), url.PathEscape(zoneID)) + + return c.httpClient.Put(ctx, path, nil) +} diff --git a/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_rectify.go b/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_rectify.go new file mode 100644 index 000000000..0bcfd14b0 --- /dev/null +++ b/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_rectify.go @@ -0,0 +1,13 @@ +package zones + +import ( + "context" + "fmt" + "net/url" +) + +func (c *client) RectifyZone(ctx context.Context, serverID string, zoneID string) error { + path := fmt.Sprintf("/api/v1/servers/%s/zones/%s/rectify", url.PathEscape(serverID), url.PathEscape(zoneID)) + + return c.httpClient.Put(ctx, path, nil) +} diff --git a/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_removerecordset.go b/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_removerecordset.go new file mode 100644 index 000000000..959deeff5 --- /dev/null +++ b/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_removerecordset.go @@ -0,0 +1,24 @@ +package zones + +import ( + "context" + "fmt" + "github.com/mittwald/go-powerdns/pdnshttp" + "net/url" +) + +func (c *client) RemoveRecordSetFromZone(ctx context.Context, serverID string, zoneID string, name string, recordType string) error { + path := fmt.Sprintf("/api/v1/servers/%s/zones/%s", url.PathEscape(serverID), url.PathEscape(zoneID)) + + set := ResourceRecordSet{ + Name: name, + Type: recordType, + ChangeType: ChangeTypeDelete, + } + + patch := Zone{ + ResourceRecordSets: []ResourceRecordSet{set}, + } + + return c.httpClient.Patch(ctx, path, nil, pdnshttp.WithJSONRequestBody(&patch)) +} diff --git a/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_retrievemaster.go b/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_retrievemaster.go new file mode 100644 index 000000000..968ce5696 --- /dev/null +++ b/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_retrievemaster.go @@ -0,0 +1,13 @@ +package zones + +import ( + "context" + "fmt" + "net/url" +) + +func (c *client) RetrieveFromMaster(ctx context.Context, serverID string, zoneID string) error { + path := fmt.Sprintf("/api/v1/servers/%s/zones/%s/axfr-retrieve", url.PathEscape(serverID), url.PathEscape(zoneID)) + + return c.httpClient.Put(ctx, path, nil) +} diff --git a/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_verify.go b/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_verify.go new file mode 100644 index 000000000..baf956ab9 --- /dev/null +++ b/vendor/github.com/mittwald/go-powerdns/apis/zones/zones_verify.go @@ -0,0 +1,13 @@ +package zones + +import ( + "context" + "fmt" + "net/url" +) + +func (c *client) VerifyZone(ctx context.Context, serverID string, zoneID string) error { + path := fmt.Sprintf("/api/v1/servers/%s/zones/%s/check", url.PathEscape(serverID), url.PathEscape(zoneID)) + + return c.httpClient.Get(ctx, path, nil) +}