sendgrid_api/
ip_warmup.rs

1use crate::Client;
2use crate::ClientResult;
3
4pub struct IpWarmup {
5    pub client: Client,
6}
7
8impl IpWarmup {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        IpWarmup { client }
12    }
13
14    /**
15     * Retrieve all IPs currently in warmup.
16     *
17     * This function performs a `GET` to the `/ips/warmup` endpoint.
18     *
19     * **This endpoint allows you to retrieve all of your IP addresses that are currently warming up.**
20     */
21    pub async fn get_ips_warmup(
22        &self,
23    ) -> ClientResult<crate::Response<Vec<crate::types::IpWarmupResponse>>> {
24        let url = self.client.url("/ips/warmup", None);
25        self.client
26            .get(
27                &url,
28                crate::Message {
29                    body: None,
30                    content_type: None,
31                },
32            )
33            .await
34    }
35    /**
36     * Retrieve all IPs currently in warmup.
37     *
38     * This function performs a `GET` to the `/ips/warmup` endpoint.
39     *
40     * As opposed to `get_ips_warmup`, this function returns all the pages of the request at once.
41     *
42     * **This endpoint allows you to retrieve all of your IP addresses that are currently warming up.**
43     */
44    pub async fn get_all_ips_warmup(
45        &self,
46    ) -> ClientResult<crate::Response<Vec<crate::types::IpWarmupResponse>>> {
47        let url = self.client.url("/ips/warmup", None);
48        self.client
49            .get_all_pages(
50                &url,
51                crate::Message {
52                    body: None,
53                    content_type: None,
54                },
55            )
56            .await
57    }
58    /**
59     * Start warming up an IP address.
60     *
61     * This function performs a `POST` to the `/ips/warmup` endpoint.
62     *
63     * **This endpoint allows you to put an IP address into warmup mode.**
64     */
65    pub async fn post_ips_warmup(
66        &self,
67        body: &crate::types::PostIpsWarmupRequest,
68    ) -> ClientResult<crate::Response<Vec<crate::types::IpWarmupResponse>>> {
69        let url = self.client.url("/ips/warmup", None);
70        self.client
71            .post(
72                &url,
73                crate::Message {
74                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
75                    content_type: Some("application/json".to_string()),
76                },
77            )
78            .await
79    }
80    /**
81     * Retrieve the warmup status for a specific IP address.
82     *
83     * This function performs a `GET` to the `/ips/warmup/{ip_address}` endpoint.
84     *
85     * **This endpoint allows you to retrieve the warmup status for a specific IP address.**
86     *
87     * You can retrieve all of your warming IPs using the "Retrieve all IPs currently in warmup" endpoint.
88     */
89    pub async fn get_ips_warmup_ip_address(
90        &self,
91        ip_address: &str,
92    ) -> ClientResult<crate::Response<Vec<crate::types::IpWarmupResponse>>> {
93        let url = self.client.url(
94            &format!(
95                "/ips/warmup/{}",
96                crate::progenitor_support::encode_path(ip_address),
97            ),
98            None,
99        );
100        self.client
101            .get(
102                &url,
103                crate::Message {
104                    body: None,
105                    content_type: None,
106                },
107            )
108            .await
109    }
110    /**
111     * Retrieve the warmup status for a specific IP address.
112     *
113     * This function performs a `GET` to the `/ips/warmup/{ip_address}` endpoint.
114     *
115     * As opposed to `get_ips_warmup_ip_address`, this function returns all the pages of the request at once.
116     *
117     * **This endpoint allows you to retrieve the warmup status for a specific IP address.**
118     *
119     * You can retrieve all of your warming IPs using the "Retrieve all IPs currently in warmup" endpoint.
120     */
121    pub async fn get_all_ips_warmup_ip_address(
122        &self,
123        ip_address: &str,
124    ) -> ClientResult<crate::Response<Vec<crate::types::IpWarmupResponse>>> {
125        let url = self.client.url(
126            &format!(
127                "/ips/warmup/{}",
128                crate::progenitor_support::encode_path(ip_address),
129            ),
130            None,
131        );
132        self.client
133            .get_all_pages(
134                &url,
135                crate::Message {
136                    body: None,
137                    content_type: None,
138                },
139            )
140            .await
141    }
142    /**
143     * Stop warming up an IP address.
144     *
145     * This function performs a `DELETE` to the `/ips/warmup/{ip_address}` endpoint.
146     *
147     * **This endpoint allows you to remove an IP address from warmup mode.**
148     *
149     * Your request will return a 204 status code if the specified IP was successfully removed from warmup mode. To retrieve details of the IP’s warmup status *before* removing it from warmup mode, call the  "Retrieve the warmpup status for a specific IP address" endpoint.
150     */
151    pub async fn delete_ips_warmup_ip_address(
152        &self,
153        ip_address: &str,
154    ) -> ClientResult<crate::Response<crate::types::Help>> {
155        let url = self.client.url(
156            &format!(
157                "/ips/warmup/{}",
158                crate::progenitor_support::encode_path(ip_address),
159            ),
160            None,
161        );
162        self.client
163            .delete(
164                &url,
165                crate::Message {
166                    body: None,
167                    content_type: None,
168                },
169            )
170            .await
171    }
172}