-
Notifications
You must be signed in to change notification settings - Fork 0
/
deleterecord.go
51 lines (43 loc) · 1.04 KB
/
deleterecord.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package cfdns
import (
"context"
"fmt"
"net/http"
"net/url"
"github.com/simplesurance/cfdns/log"
)
// DeleteRecord deletes a DNS record on CloudFlare.
//
// API Reference: https://developers.cloudflare.com/api/operations/dns-records-for-a-zone-delete-dns-record
func (c *Client) DeleteRecord(
ctx context.Context,
req *DeleteRecordRequest,
) (*DeleteRecordResponse, error) {
_, err := sendRequestRetry[*deleteRecordAPIResponse](
ctx,
c,
c.logger.SubLogger(log.WithPrefix("DeleteDNSRecord")),
&request{
method: http.MethodDelete,
path: fmt.Sprintf("zones/%s/dns_records/%s",
url.PathEscape(req.ZoneID),
url.PathEscape(req.RecordID)),
queryParams: url.Values{},
body: nil,
})
if err != nil {
return nil, err
}
c.logger.D(func(log log.DebugFn) {
log(fmt.Sprintf("Record %s deleted", req.RecordID))
})
return &DeleteRecordResponse{}, err
}
type DeleteRecordRequest struct {
ZoneID string
RecordID string
}
type DeleteRecordResponse struct{}
type deleteRecordAPIResponse struct {
cfResponseCommon
}