sendgrid_api/
reverse_dns.rs

1use crate::Client;
2use crate::ClientResult;
3
4pub struct ReverseDns {
5    pub client: Client,
6}
7
8impl ReverseDns {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        ReverseDns { client }
12    }
13
14    /**
15     * Retrieve all reverse DNS records.
16     *
17     * This function performs a `GET` to the `/whitelabel/ips` endpoint.
18     *
19     * **This endpoint allows you to retrieve all of the Reverse DNS records created by this account.**
20     *
21     * You may include a search key by using the `ip` query string parameter. This enables you to perform a prefix search for a given IP segment (e.g., `?ip="192."`).
22     *
23     * Use the `limit` query string parameter to reduce the number of records returned. All records will be returned if you have fewer records than the specified limit.
24     *
25     * The `offset` query string parameter allows you to specify a non-zero index from which records will be returned. For example, if you have ten records, `?offset=5` will return the last five records (at indexes 5 through 9). The list starts at index zero.
26     *
27     * **Parameters:**
28     *
29     * * `limit: i64` -- The maximum number of results to retrieve.
30     * * `offset: i64` -- The point in the list of results to begin retrieving IP addresses from.
31     * * `ip: &str` -- The IP address segment that you'd like to use in a prefix search.
32     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
33     */
34    pub async fn get_whitelabel_ips(
35        &self,
36        limit: i64,
37        offset: i64,
38        ip: &str,
39    ) -> ClientResult<crate::Response<Vec<crate::types::ReverseDns>>> {
40        let mut query_args: Vec<(String, String)> = Default::default();
41        if !ip.is_empty() {
42            query_args.push(("ip".to_string(), ip.to_string()));
43        }
44        if limit > 0 {
45            query_args.push(("limit".to_string(), limit.to_string()));
46        }
47        if offset > 0 {
48            query_args.push(("offset".to_string(), offset.to_string()));
49        }
50        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
51        let url = self
52            .client
53            .url(&format!("/whitelabel/ips?{}", query_), None);
54        self.client
55            .get(
56                &url,
57                crate::Message {
58                    body: None,
59                    content_type: None,
60                },
61            )
62            .await
63    }
64    /**
65     * Retrieve all reverse DNS records.
66     *
67     * This function performs a `GET` to the `/whitelabel/ips` endpoint.
68     *
69     * As opposed to `get_whitelabel_ips`, this function returns all the pages of the request at once.
70     *
71     * **This endpoint allows you to retrieve all of the Reverse DNS records created by this account.**
72     *
73     * You may include a search key by using the `ip` query string parameter. This enables you to perform a prefix search for a given IP segment (e.g., `?ip="192."`).
74     *
75     * Use the `limit` query string parameter to reduce the number of records returned. All records will be returned if you have fewer records than the specified limit.
76     *
77     * The `offset` query string parameter allows you to specify a non-zero index from which records will be returned. For example, if you have ten records, `?offset=5` will return the last five records (at indexes 5 through 9). The list starts at index zero.
78     */
79    pub async fn get_all_whitelabel_ips(
80        &self,
81        offset: i64,
82        ip: &str,
83    ) -> ClientResult<crate::Response<Vec<crate::types::ReverseDns>>> {
84        let mut query_args: Vec<(String, String)> = Default::default();
85        if !ip.is_empty() {
86            query_args.push(("ip".to_string(), ip.to_string()));
87        }
88        if offset > 0 {
89            query_args.push(("offset".to_string(), offset.to_string()));
90        }
91        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
92        let url = self
93            .client
94            .url(&format!("/whitelabel/ips?{}", query_), None);
95        self.client
96            .get_all_pages(
97                &url,
98                crate::Message {
99                    body: None,
100                    content_type: None,
101                },
102            )
103            .await
104    }
105    /**
106     * Set up reverse DNS.
107     *
108     * This function performs a `POST` to the `/whitelabel/ips` endpoint.
109     *
110     * **This endpoint allows you to set up reverse DNS.**
111     *
112     * **Parameters:**
113     *
114     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
115     */
116    pub async fn post_whitelabel_ip(
117        &self,
118        body: &crate::types::PostWhitelabelIpsRequest,
119    ) -> ClientResult<crate::Response<crate::types::ReverseDns>> {
120        let url = self.client.url("/whitelabel/ips", None);
121        self.client
122            .post(
123                &url,
124                crate::Message {
125                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
126                    content_type: Some("application/json".to_string()),
127                },
128            )
129            .await
130    }
131    /**
132     * Validate a reverse DNS record.
133     *
134     * This function performs a `POST` to the `/whitelabel/ips/{id}/validate` endpoint.
135     *
136     * **This endpoint allows you to validate a reverse DNS record.**
137     *
138     * Always check the `valid` property of the response’s `validation_results.a_record` object. This field will indicate whether it was possible to validate the reverse DNS record. If the `validation_results.a_record.valid` is `false`, this indicates only that Twilio SendGrid could not determine the validity your reverse DNS record — it may still be valid.
139     *
140     * If validity couldn’t be determined, you can check the value of `validation_results.a_record.reason` to find out why.
141     *
142     * You can retrieve the IDs associated with all your reverse DNS records using the "Retrieve all reverse DNS records" endpoint.
143     *
144     * **Parameters:**
145     *
146     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
147     */
148    pub async fn post_whitelabel_ips_validate(
149        &self,
150        id: &str,
151    ) -> ClientResult<crate::Response<crate::types::PostWhitelabelIpsValidateResponse>> {
152        let url = self.client.url(
153            &format!(
154                "/whitelabel/ips/{}/validate",
155                crate::progenitor_support::encode_path(id),
156            ),
157            None,
158        );
159        self.client
160            .post(
161                &url,
162                crate::Message {
163                    body: None,
164                    content_type: None,
165                },
166            )
167            .await
168    }
169    /**
170     * Retrieve a reverse DNS record.
171     *
172     * This function performs a `GET` to the `/whitelabel/ips/{id}` endpoint.
173     *
174     * **This endpoint allows you to retrieve a reverse DNS record.**
175     *
176     * You can retrieve the IDs associated with all your reverse DNS records using the "Retrieve all reverse DNS records" endpoint.
177     *
178     * **Parameters:**
179     *
180     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
181     */
182    pub async fn get_whitelabel_ip(
183        &self,
184        id: &str,
185    ) -> ClientResult<crate::Response<crate::types::ReverseDns>> {
186        let url = self.client.url(
187            &format!(
188                "/whitelabel/ips/{}",
189                crate::progenitor_support::encode_path(id),
190            ),
191            None,
192        );
193        self.client
194            .get(
195                &url,
196                crate::Message {
197                    body: None,
198                    content_type: None,
199                },
200            )
201            .await
202    }
203    /**
204     * Delete a reverse DNS record.
205     *
206     * This function performs a `DELETE` to the `/whitelabel/ips/{id}` endpoint.
207     *
208     * **This endpoint allows you to delete a reverse DNS record.**
209     *
210     * A call to this endpoint will respond with a 204 status code if the deletion was successful.
211     *
212     * You can retrieve the IDs associated with all your reverse DNS records using the "Retrieve all reverse DNS records" endpoint.
213     *
214     * **Parameters:**
215     *
216     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
217     */
218    pub async fn delete_whitelabel_ips(
219        &self,
220        id: &str,
221    ) -> ClientResult<crate::Response<crate::types::Help>> {
222        let url = self.client.url(
223            &format!(
224                "/whitelabel/ips/{}",
225                crate::progenitor_support::encode_path(id),
226            ),
227            None,
228        );
229        self.client
230            .delete(
231                &url,
232                crate::Message {
233                    body: None,
234                    content_type: None,
235                },
236            )
237            .await
238    }
239}