sendgrid_api/
ip_access_management.rs

1use crate::Client;
2use crate::ClientResult;
3
4pub struct IpAccessManagement {
5    pub client: Client,
6}
7
8impl IpAccessManagement {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        IpAccessManagement { client }
12    }
13
14    /**
15     * Retrieve a list of currently allowed IPs.
16     *
17     * This function performs a `GET` to the `/access_settings/whitelist` endpoint.
18     *
19     * **This endpoint allows you to retrieve a list of IP addresses that are currently allowed to access your account.**
20     *
21     * Each IP address returned to you will have `created_at` and `updated_at` dates. Each IP will also be associated with an `id` that can be used to remove the address from your allow list.
22     *
23     * **Parameters:**
24     *
25     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
26     */
27    pub async fn get_access_settings_whitelist(
28        &self,
29    ) -> ClientResult<crate::Response<crate::types::IpAccessResponse>> {
30        let url = self.client.url("/access_settings/whitelist", None);
31        self.client
32            .get(
33                &url,
34                crate::Message {
35                    body: None,
36                    content_type: None,
37                },
38            )
39            .await
40    }
41    /**
42     * Add one or more IPs to the allow list.
43     *
44     * This function performs a `POST` to the `/access_settings/whitelist` endpoint.
45     *
46     * **This endpoint allows you to add one or more allowed IP addresses.**
47     *
48     * To allow one or more IP addresses, pass them to this endpoint in an array. Once an IP address is added to your allow list, it will be assigned an `id` that can be used to remove the address. You can retrieve the ID associated with an IP using the "Retrieve a list of currently allowed IPs" endpoint.
49     *
50     * **Parameters:**
51     *
52     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
53     */
54    pub async fn post_access_settings_whitelist(
55        &self,
56        body: &crate::types::PostAccessSettingsWhitelistRequest,
57    ) -> ClientResult<crate::Response<crate::types::IpAccessResponse>> {
58        let url = self.client.url("/access_settings/whitelist", None);
59        self.client
60            .post(
61                &url,
62                crate::Message {
63                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
64                    content_type: Some("application/json".to_string()),
65                },
66            )
67            .await
68    }
69    /**
70     * Remove one or more IPs from the allow list.
71     *
72     * This function performs a `DELETE` to the `/access_settings/whitelist` endpoint.
73     *
74     * **This endpoint allows you to remove one or more IP addresses from your list of allowed addresses.**
75     *
76     * To remove one or more IP addresses, pass this endpoint an array containing the ID(s) associated with the IP(s) you intend to remove. You can retrieve the IDs associated with your allowed IP addresses using the "Retrieve a list of currently allowed IPs" endpoint.
77     *
78     * It is possible to remove your own IP address, which will block access to your account. You will need to submit a [support ticket](https://sendgrid.com/docs/ui/account-and-settings/support/) if this happens. For this reason, it is important to double check that you are removing only the IPs you intend to remove when using this endpoint.
79     *
80     * **Parameters:**
81     *
82     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
83     */
84    pub async fn delete_access_settings_whitelist(
85        &self,
86        body: &crate::types::DeleteAccessSettingsWhitelistRequest,
87    ) -> ClientResult<crate::Response<crate::types::Help>> {
88        let url = self.client.url("/access_settings/whitelist", None);
89        self.client
90            .delete(
91                &url,
92                crate::Message {
93                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
94                    content_type: Some("application/json".to_string()),
95                },
96            )
97            .await
98    }
99    /**
100     * Retrieve all recent access attempts.
101     *
102     * This function performs a `GET` to the `/access_settings/activity` endpoint.
103     *
104     * **This endpoint allows you to retrieve a list of all of the IP addresses that recently attempted to access your account either through the User Interface or the API.**
105     *
106     * **Parameters:**
107     *
108     * * `limit: i64` -- Limits the number of IPs to return.
109     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
110     */
111    pub async fn get_access_settings_activity(
112        &self,
113        limit: i64,
114    ) -> ClientResult<crate::Response<crate::types::GetAccessSettingsActivityResponse>> {
115        let mut query_args: Vec<(String, String)> = Default::default();
116        if limit > 0 {
117            query_args.push(("limit".to_string(), limit.to_string()));
118        }
119        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
120        let url = self
121            .client
122            .url(&format!("/access_settings/activity?{}", query_), None);
123        self.client
124            .get(
125                &url,
126                crate::Message {
127                    body: None,
128                    content_type: None,
129                },
130            )
131            .await
132    }
133    /**
134     * Retrieve a specific allowed IP.
135     *
136     * This function performs a `GET` to the `/access_settings/whitelist/{rule_id}` endpoint.
137     *
138     * **This endpoint allows you to retreive a specific IP address that has been allowed to access your account.**
139     *
140     * You must include the ID for the specific IP address you want to retrieve in your call. You can retrieve the IDs associated with your allowed IP addresses using the "Retrieve a  list of currently allowed IPs" endpoint.
141     *
142     * **Parameters:**
143     *
144     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
145     */
146    pub async fn get_access_settings_whitelist_rule(
147        &self,
148        rule_id: &str,
149    ) -> ClientResult<crate::Response<crate::types::IpAccessResponse>> {
150        let url = self.client.url(
151            &format!(
152                "/access_settings/whitelist/{}",
153                crate::progenitor_support::encode_path(rule_id),
154            ),
155            None,
156        );
157        self.client
158            .get(
159                &url,
160                crate::Message {
161                    body: None,
162                    content_type: None,
163                },
164            )
165            .await
166    }
167    /**
168     * Remove a specific IP from the allowed list.
169     *
170     * This function performs a `DELETE` to the `/access_settings/whitelist/{rule_id}` endpoint.
171     *
172     * **This endpoint allows you to remove a specific IP address from your list of allowed addresses.**
173     *
174     * When removing a specific IP address from your list, you must include the ID in your call.  You can retrieve the IDs associated with your allowed IP addresses using the "Retrieve a list of currently allowed IPs" endpoint.
175     *
176     * **Parameters:**
177     *
178     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
179     */
180    pub async fn delete_access_settings_whitelist_rule(
181        &self,
182        rule_id: &str,
183    ) -> ClientResult<crate::Response<crate::types::Help>> {
184        let url = self.client.url(
185            &format!(
186                "/access_settings/whitelist/{}",
187                crate::progenitor_support::encode_path(rule_id),
188            ),
189            None,
190        );
191        self.client
192            .delete(
193                &url,
194                crate::Message {
195                    body: None,
196                    content_type: None,
197                },
198            )
199            .await
200    }
201}