u_sdk/email/
ip_protection.rs1use super::utils::parse_json_response;
2use super::{Client, Error, GetIpProtectionResult};
3use bon::Builder;
4use std::collections::HashMap;
5use u_sdk_common::helper::into_header_map;
6use u_sdk_common::open_api_sign::{SignParams, get_openapi_request_header};
7
8#[derive(Builder)]
9pub struct GetIpProtection<'a> {
10 #[builder(start_fn)]
11 client: &'a Client,
12}
13
14impl GetIpProtection<'_> {
15 pub async fn send(&self) -> Result<GetIpProtectionResult, Error> {
16 let client = self.client;
17 let creds = client.credentials_provider.load().await?;
18
19 let sign_params = SignParams {
20 req_method: "GET",
21 host: &client.host,
22 query_map: HashMap::<&str, &str>::new(),
23 x_acs_action: "GetIpProtection",
24 x_acs_version: "2015-11-23",
25 x_acs_security_token: creds.sts_security_token.as_deref(),
26 request_body: None,
27 style: &client.style,
28 };
29
30 let (headers, url_) =
31 get_openapi_request_header(&creds.access_key_secret, &creds.access_key_id, sign_params)
32 .map_err(|e| Error::Common(format!("get_common_headers error: {}", e)))?;
33 let resp = self
34 .client
35 .http_client
36 .get(url_)
37 .headers(into_header_map(headers))
38 .send()
39 .await?;
40
41 let resp = parse_json_response(resp).await?;
42 Ok(resp)
43 }
44}