-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathip_warmup.go
More file actions
79 lines (62 loc) · 1.79 KB
/
ip_warmup.go
File metadata and controls
79 lines (62 loc) · 1.79 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package sendgrid
import (
"context"
"fmt"
"net/url"
)
type InputStartIPWarmup struct {
IP string `json:"ip"`
}
type IPWarmup struct {
IP string `json:"ip,omitempty"`
StartDate int64 `json:"start_date,omitempty"`
}
// see: https://www.twilio.com/docs/sendgrid/api-reference/ip-warmup/start-warming-up-an-ip-address
func (c *Client) StartIPWarmup(ctx context.Context, input *InputStartIPWarmup) ([]*IPWarmup, error) {
req, err := c.NewRequest("POST", "/ips/warmup", input)
if err != nil {
return nil, err
}
var r []*IPWarmup
if err := c.Do(ctx, req, &r); err != nil {
return nil, err
}
return r, nil
}
// see: https://www.twilio.com/docs/sendgrid/api-reference/ip-warmup/stop-warming-up-an-ip-address
func (c *Client) StopIPWarmup(ctx context.Context, ip string) error {
path := fmt.Sprintf("/ips/warmup/%s", url.QueryEscape(ip))
req, err := c.NewRequest("DELETE", path, nil)
if err != nil {
return err
}
if err := c.Do(ctx, req, nil); err != nil {
return err
}
return nil
}
// see: https://www.twilio.com/docs/sendgrid/api-reference/ip-warmup/retrieve-ip-warmup-status
func (c *Client) GetIPWarmupStatus(ctx context.Context, ip string) ([]*IPWarmup, error) {
path := fmt.Sprintf("/ips/warmup/%s", url.QueryEscape(ip))
req, err := c.NewRequest("GET", path, nil)
if err != nil {
return nil, err
}
var r []*IPWarmup
if err := c.Do(ctx, req, &r); err != nil {
return nil, err
}
return r, nil
}
// see: https://www.twilio.com/docs/sendgrid/api-reference/ip-warmup/retrieve-all-ips-currently-in-warmup
func (c *Client) GetAllIPWarmup(ctx context.Context) ([]*IPWarmup, error) {
req, err := c.NewRequest("GET", "/ips/warmup", nil)
if err != nil {
return nil, err
}
var r []*IPWarmup
if err := c.Do(ctx, req, &r); err != nil {
return nil, err
}
return r, nil
}