@@ -14,7 +14,8 @@ const (
14
14
)
15
15
16
16
type Api struct {
17
- Auth Auth
17
+ Auth Auth
18
+ Throttler Throttler
18
19
}
19
20
20
21
func (p Api ) Ping () error {
@@ -24,6 +25,7 @@ func (p Api) Ping() error {
24
25
}
25
26
26
27
response := pingRes {}
28
+ p .Throttler .WaitForPermit ()
27
29
err := makeRequest (PING , p .Auth , & response )
28
30
if err != nil {
29
31
return err
@@ -39,6 +41,7 @@ func (p Api) RetrieveRecords(domain string) ([]porkbun.Record, error) {
39
41
}
40
42
41
43
response := listRes {}
44
+ p .Throttler .WaitForPermit ()
42
45
err := makeRequest (RETRIEVE + "/" + domain , p .Auth , & response )
43
46
if err != nil {
44
47
return nil , err
@@ -70,6 +73,7 @@ func (p Api) CreateRecord(domain string, toCreate porkbun.Record) (string, error
70
73
request .Name = trimDomain (toCreate .Name , domain )
71
74
72
75
response := createRes {}
76
+ p .Throttler .WaitForPermit ()
73
77
err := makeRequest (CREATE + "/" + domain , request , & response )
74
78
if err != nil {
75
79
return "" , err
@@ -80,6 +84,7 @@ func (p Api) CreateRecord(domain string, toCreate porkbun.Record) (string, error
80
84
81
85
func (p Api ) DeleteRecord (domain string , id string ) error {
82
86
response := baseRes {}
87
+ p .Throttler .WaitForPermit ()
83
88
err := makeRequest (DELETE + "/" + domain + "/" + id , p .Auth , & response )
84
89
if err != nil {
85
90
return err
0 commit comments